summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--00000_index.txt1097
-rw-r--r--00100_all_default-dir-4.0.28.patch11
-rw-r--r--00100_all_default-dir-5.0.19.patch111
-rw-r--r--00100_all_mysql-4.0-my-print-defaults.patch11
-rw-r--r--00300_all_thrssl-4.0.28.patch11
-rw-r--r--00300_all_thrssl-4.1.23.patch11
-rw-r--r--00300_all_thrssl-4.1.patch22
-rw-r--r--00350_x86_asm-pic-fixes-5.1.41.patch30
-rw-r--r--00800_all_slot_script-4.0.patch646
-rw-r--r--00800_all_slot_script-4.1.16.patch532
-rw-r--r--00800_all_slot_script-4.1.23.patch545
-rw-r--r--00800_all_slot_script-5.0.17.patch542
-rw-r--r--00800_all_slot_script-5.0.21.patch545
-rw-r--r--00800_all_slot_script-5.0.34.patch2434
-rw-r--r--00800_all_slot_script-5.1.10.patch539
-rw-r--r--00800_all_slot_script-5.1.12.patch539
-rw-r--r--00800_all_slot_script-5.1.14.patch540
-rw-r--r--00800_all_slot_script-5.1.15.patch540
-rw-r--r--00810_all_slot_manager-5.0.19.patch20
-rw-r--r--00810_all_slot_manager-5.1.10.patch21
-rw-r--r--00810_all_slot_manager-5.1.7.patch21
-rw-r--r--01000_all_bug23427-abi-breakage-5.0.26.patch43
-rw-r--r--01010_all_bootstrap_no_plugin.patch39
-rw-r--r--02000_all_query-logging-bypass-5.0.21.patch208
-rw-r--r--02020_all_embedded-library-compile-5.0.38.patch26
-rw-r--r--02040_all_embedded-library-shared-5.0.76.patch1539
-rw-r--r--02040_all_embedded-library-shared-5.0.77.patch1544
l---------02040_all_embedded-library-shared-5.0.83.patch1
-rw-r--r--02040_all_embedded-library-shared-5.0.92.patch1541
-rw-r--r--02040_all_embedded-library-shared-5.1.39.patch933
-rw-r--r--02040_all_embedded-library-shared-5.1.43.patch1460
-rw-r--r--02040_all_embedded-library-shared-5.1.50.patch2298
-rw-r--r--02040_all_embedded-library-shared-5.1.60.patch2298
-rw-r--r--02040_all_embedded-library-shared-maria-5.1.50.patch2007
-rw-r--r--02040_all_embedded-library-shared-maria-5.2.03.patch1945
-rw-r--r--07010_all_rpl000015-portsobst-fix-4.1.23.patch11
-rw-r--r--07010_all_rpl000015-portsobst-fix-5.0.26.patch11
-rw-r--r--07020_all_trigger-rename-fail-as-root-5.0.26.patch35
-rw-r--r--07020_all_trigger-rename-fail-as-root-5.0.34.patch35
-rw-r--r--07040_all_disable_mybug_9735_test.patch30
-rw-r--r--07050_all_we-are-in-2007-now.patch19
-rw-r--r--07060_all_fix-nullpointer-dos.patch27
-rw-r--r--07070_all_fix-nullpointer-dos-testcase.patch71
-rw-r--r--07080_all_mysql_client_test-fix-pointer-aliasing-mysqlbug27383.patch127
-rw-r--r--07090_all_innodb_spatial_crash_mybug_32125_5.0.patch112
-rw-r--r--07090_all_innodb_spatial_crash_mybug_32125_5.1.patch90
-rw-r--r--07100_all_respect_tmpdir_filesort_mybug_30287_5.0.patch128
-rw-r--r--07100_all_respect_tmpdir_filesort_mybug_30287_5.1.patch131
-rw-r--r--07110_all_mysql_gcc-4.2.patch3483
-rw-r--r--07110_all_mysql_gcc-4.2_5.0.54.patch5360
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.39.patch7917
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.41.patch3460
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.42.patch3465
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.43.patch3444
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.46.patch3444
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.49.patch3428
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.50.patch4070
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.51.patch4061
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.56.patch3729
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.57.patch3696
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.58.patch3859
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.60.patch3859
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.62.patch3850
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.65.patch3838
-rw-r--r--07110_all_mysql_gcc-4.2_5.1.69.patch3837
-rw-r--r--07120_all_openssl_handshake_mybug_33050.patch74
-rw-r--r--07130_all_mysqldump-hang-33057_5.0.52.patch31
-rw-r--r--07190_all_disallow_database_ops_without_super_mybug_27440.patch210
-rw-r--r--07210_all_encode_html_entities-5.0.70.patch68
-rw-r--r--07210_all_encode_html_entities_testcase-5.0.72.patch34
-rw-r--r--07210_all_encode_html_entities_testcase-5.0.76.patch35
-rw-r--r--07270_all_charset_boot_fix-5.1.43.patch204
-rw-r--r--07270_all_charset_boot_fix-5.1.44.patch70
-rw-r--r--07271_all_charset_init_fix-5.1.44.patch28
-rw-r--r--07280_all_stdbool-maria-5.1.42.patch98
-rw-r--r--07290_all_myisam_cast_warning_issue_gcc43.patch44
-rw-r--r--07300_all_mysql_embedded_compilefix-5.0.91.patch13
-rw-r--r--07310_all_mysql_gcc45-disable-abicheck.patch34
-rw-r--r--07320_all_mysql_mycompiler_header.patch28
-rw-r--r--07330_all_mysql_itemfunc_stacksize_bug57386.patch89
-rw-r--r--07340_all_mysql_hardened_x86_strings-5.1.69.patch424
-rw-r--r--07340_all_mysql_hardened_x86_strings.patch424
-rw-r--r--07341_all_mariadb_hardened_x86_strings.patch517
-rw-r--r--07341_all_mysql_hardened_x86_strings.patch517
-rw-r--r--07342_all_mysql_auth_bypass-5.1.62.patch29
l---------10010_all_show_patches-percona-5.0.75-b12.patch1
l---------10010_all_show_patches-percona-5.0.77-b13.patch1
l---------10010_all_show_patches-percona-5.0.83-b17-20090706.patch1
l---------10010_all_show_patches-percona-5.0.84-b18-20090811.patch1
l---------10010_all_show_patches-percona-5.0.87-b20-20091116.patch1
l---------10020_all_microslow_innodb-percona-5.0.75-b12.patch1
l---------10020_all_microslow_innodb-percona-5.0.77-b13.patch1
l---------10020_all_microslow_innodb-percona-5.0.83-b17-20090706.patch1
l---------10020_all_microslow_innodb-percona-5.0.84-b18-20090811.patch1
l---------10020_all_microslow_innodb-percona-5.0.87-b20-20091116.patch1
l---------10021_all_profiling_slow-percona-5.0.83-b17-20090706.patch1
l---------10021_all_profiling_slow-percona-5.0.84-b18-20090811.patch1
l---------10021_all_profiling_slow-percona-5.0.87-b20-20091116.patch1
l---------10030_all_userstatv2-percona-5.0.75-b12.patch1
l---------10030_all_userstatv2-percona-5.0.77-b13.patch1
l---------10030_all_userstatv2-percona-5.0.83-b17-20090706.patch1
l---------10030_all_userstatv2-percona-5.0.84-b18-20090811.patch1
l---------10030_all_userstatv2-percona-5.0.87-b20-20091116.patch1
-rw-r--r--10030_all_userstatv2-percona-5.0.92.patch4376
l---------10040_all_microsec_process-percona-5.0.75-b12.patch1
l---------10040_all_microsec_process-percona-5.0.77-b13.patch1
l---------10040_all_microsec_process-percona-5.0.83-b17-20090706.patch1
l---------10040_all_microsec_process-percona-5.0.84-b18-20090811.patch1
l---------10040_all_microsec_process-percona-5.0.87-b20-20091116.patch1
l---------10050_all_innodb_io_patches-percona-5.0.75-b12.patch1
l---------10050_all_innodb_io_patches-percona-5.0.77-b13.patch1
l---------10050_all_innodb_io_patches-percona-5.0.83-b17-20090706.patch1
l---------10050_all_innodb_io_patches-percona-5.0.84-b18-20090811.patch1
l---------10050_all_innodb_io_patches-percona-5.0.87-b20-20091116.patch1
l---------10060_all_mirror_binlog-percona-5.0.75-b12.patch1
l---------10060_all_mirror_binlog-percona-5.0.77-b13.patch1
l---------10060_all_mirror_binlog-percona-5.0.83-b17-20090706.patch1
l---------10070_all_mysqld_safe_syslog-percona-5.0.75-b12.patch1
l---------10070_all_mysqld_safe_syslog-percona-5.0.77-b13.patch1
l---------10070_all_mysqld_safe_syslog-percona-5.0.83-b17-20090706.patch1
l---------10070_all_mysqld_safe_syslog-percona-5.0.84-b18-20090811.patch1
l---------10070_all_mysqld_safe_syslog-percona-5.0.87-b20-20091116.patch1
l---------10080_all_innodb_locks_held-percona-5.0.75-b12.patch1
l---------10080_all_innodb_locks_held-percona-5.0.77-b13.patch1
l---------10080_all_innodb_locks_held-percona-5.0.83-b17-20090706.patch1
l---------10080_all_innodb_locks_held-percona-5.0.84-b18-20090811.patch1
l---------10080_all_innodb_locks_held-percona-5.0.87-b20-20091116.patch1
l---------10090_all_innodb_show_bp-percona-5.0.75-b12.patch1
l---------10090_all_innodb_show_bp-percona-5.0.77-b13.patch1
l---------10090_all_innodb_show_bp-percona-5.0.83-b17-20090706.patch1
l---------10090_all_innodb_show_bp-percona-5.0.84-b18-20090811.patch1
l---------10090_all_innodb_show_bp-percona-5.0.87-b20-20091116.patch1
l---------10100_all_innodb_show_hashed_memory-percona-5.0.75-b12.patch1
l---------10100_all_innodb_show_hashed_memory-percona-5.0.77-b13.patch1
l---------10110_all_innodb_check_fragmentation-percona-5.0.75-b12.patch1
l---------10110_all_innodb_check_fragmentation-percona-5.0.77-b13.patch1
l---------10110_all_innodb_check_fragmentation-percona-5.0.83-b17-20090706.patch1
l---------10110_all_innodb_check_fragmentation-percona-5.0.84-b18-20090811.patch1
l---------10110_all_innodb_check_fragmentation-percona-5.0.87-b20-20091116.patch1
l---------10120_all_innodb_io_pattern-percona-5.0.75-b12.patch1
l---------10120_all_innodb_io_pattern-percona-5.0.77-b13.patch1
l---------10120_all_innodb_io_pattern-percona-5.0.83-b17-20090706.patch1
l---------10120_all_innodb_io_pattern-percona-5.0.84-b18-20090811.patch1
l---------10120_all_innodb_io_pattern-percona-5.0.87-b20-20091116.patch1
l---------10130_all_innodb_fsync_source-percona-5.0.75-b12.patch1
l---------10130_all_innodb_fsync_source-percona-5.0.77-b13.patch1
l---------10130_all_innodb_fsync_source-percona-5.0.83-b17-20090706.patch1
l---------10130_all_innodb_fsync_source-percona-5.0.84-b18-20090811.patch1
l---------10130_all_innodb_fsync_source-percona-5.0.87-b20-20091116.patch1
l---------10139_all_innodb_show_hashed_memory-percona-5.0.83-b17-20090706.patch1
l---------10139_all_innodb_show_hashed_memory-percona-5.0.84-b18-20090811.patch1
l---------10139_all_innodb_show_hashed_memory-percona-5.0.87-b20-20091116.patch1
l---------10140_all_innodb_dict_size_limit-percona-5.0.77-b13.patch1
l---------10140_all_innodb_dict_size_limit-percona-5.0.83-b17-20090706.patch1
l---------10140_all_innodb_dict_size_limit-percona-5.0.84-b18-20090811.patch1
l---------10140_all_innodb_dict_size_limit-percona-5.0.87-b20-20091116.patch1
l---------10160_all_innodb_extra_rseg-percona-5.0.83-b17-20090706.patch1
l---------10160_all_innodb_extra_rseg-percona-5.0.84-b18-20090811.patch1
l---------10160_all_innodb_extra_rseg-percona-5.0.87-b20-20091116.patch1
l---------10170_all_innodb_thread_concurrency_timer_based-percona-5.0.83-b17-20090706.patch1
l---------10170_all_innodb_thread_concurrency_timer_based-percona-5.0.84-b18-20090811.patch1
l---------10170_all_innodb_thread_concurrency_timer_based-percona-5.0.87-b20-20091116.patch1
l---------10200_all_mysql-test-percona-5.0.83-b17-20090706.patch1
l---------10200_all_mysql-test-percona-5.0.84-b18-20090811.patch1
l---------10200_all_mysql-test-percona-5.0.87-b20-20091116.patch1
l---------10500_all_innodb_use_sys_malloc-percona-5.0.84-b18-20090811.patch1
l---------10500_all_innodb_use_sys_malloc-percona-5.0.87-b20-20091116.patch1
l---------10510_all_innodb_recovery_patches-percona-5.0.84-b18-20090811.patch1
l---------10510_all_innodb_recovery_patches-percona-5.0.87-b20-20091116.patch1
l---------10511_all_innodb_misc_patch-percona-5.0.87-b20-20091116.patch1
l---------10520_all_innodb_split_buf_pool_mutex-percona-5.0.84-b18-20090811.patch1
l---------10520_all_innodb_split_buf_pool_mutex-percona-5.0.87-b20-20091116.patch1
l---------11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.75-b12.patch1
l---------11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.77-b13.patch1
l---------11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.83-b17-20090706.patch1
l---------11010_all_innodb_rw_lock-percona-5.0.75-b12.patch1
l---------11010_all_innodb_rw_lock-percona-5.0.77-b13.patch1
l---------11010_all_innodb_rw_lock-percona-5.0.83-b17-20090706.patch1
l---------11010_all_innodb_rw_lock-percona-5.0.84-b18-20090811.patch1
l---------11010_all_innodb_rw_lock-percona-5.0.87-b20-20091116.patch1
-rw-r--r--15000_all_mariadb_libevent-system_5.1.42.patch92
-rw-r--r--21000_all_sql-5.1.62.patch3199
-rw-r--r--21000_all_sql-5.2.12.patch3234
-rw-r--r--21000_all_sql-5.3.7.patch3258
-rw-r--r--21000_all_sql-5.5.25.patch3338
-rw-r--r--percona/5.0.75-b12/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.75-b12/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.75-b12/innodb_io_patches.patch672
-rw-r--r--percona/5.0.75-b12/innodb_io_pattern.patch688
-rw-r--r--percona/5.0.75-b12/innodb_locks_held.patch219
-rw-r--r--percona/5.0.75-b12/innodb_rw_lock.patch1459
-rw-r--r--percona/5.0.75-b12/innodb_show_bp.patch447
-rw-r--r--percona/5.0.75-b12/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.75-b12/microsec_process.patch281
-rw-r--r--percona/5.0.75-b12/microslow_innodb.patch2472
-rw-r--r--percona/5.0.75-b12/mirror_binlog.patch2694
-rw-r--r--percona/5.0.75-b12/mysql-percona.rhel5.spec1396
-rw-r--r--percona/5.0.75-b12/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.75-b12/series15
-rw-r--r--percona/5.0.75-b12/show_patches.patch288
-rw-r--r--percona/5.0.75-b12/split_buf_pool_mutex_fixed_optimistic_safe.patch1305
-rw-r--r--percona/5.0.75-b12/userstatv2.patch4463
-rw-r--r--percona/5.0.77-b13/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.77-b13/innodb_dict_size_limit.patch477
-rw-r--r--percona/5.0.77-b13/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.77-b13/innodb_io_patches.patch672
-rw-r--r--percona/5.0.77-b13/innodb_io_pattern.patch688
-rw-r--r--percona/5.0.77-b13/innodb_locks_held.patch219
-rw-r--r--percona/5.0.77-b13/innodb_rw_lock.patch1472
-rw-r--r--percona/5.0.77-b13/innodb_show_bp.patch447
-rw-r--r--percona/5.0.77-b13/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.77-b13/microsec_process.patch281
-rw-r--r--percona/5.0.77-b13/microslow_innodb.patch2472
-rw-r--r--percona/5.0.77-b13/mirror_binlog.patch2694
-rw-r--r--percona/5.0.77-b13/mysql-percona.rhel5.spec1413
-rw-r--r--percona/5.0.77-b13/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.77-b13/series16
-rw-r--r--percona/5.0.77-b13/show_patches.patch288
-rw-r--r--percona/5.0.77-b13/split_buf_pool_mutex_fixed_optimistic_safe.patch1314
-rw-r--r--percona/5.0.77-b13/userstatv2.patch4441
-rw-r--r--percona/5.0.77-b16/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.77-b16/innodb_dict_size_limit.patch477
-rw-r--r--percona/5.0.77-b16/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.77-b16/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.77-b16/innodb_io_patches.patch704
-rw-r--r--percona/5.0.77-b16/innodb_io_pattern.patch688
-rw-r--r--percona/5.0.77-b16/innodb_locks_held.patch219
-rw-r--r--percona/5.0.77-b16/innodb_rw_lock.patch1357
-rw-r--r--percona/5.0.77-b16/innodb_show_bp.patch447
-rw-r--r--percona/5.0.77-b16/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.77-b16/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.77-b16/microsec_process.patch282
-rw-r--r--percona/5.0.77-b16/microslow_innodb.patch2484
-rw-r--r--percona/5.0.77-b16/mirror_binlog.patch2694
-rw-r--r--percona/5.0.77-b16/mysql-percona.rhel5.spec1417
-rw-r--r--percona/5.0.77-b16/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.77-b16/series18
-rw-r--r--percona/5.0.77-b16/show_patches.patch288
-rw-r--r--percona/5.0.77-b16/split_buf_pool_mutex_fixed_optimistic_safe.patch1314
-rw-r--r--percona/5.0.77-b16/userstatv2.patch4441
-rw-r--r--percona/5.0.83-b17-20090706/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.83-b17-20090706/innodb_dict_size_limit.patch477
-rw-r--r--percona/5.0.83-b17-20090706/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.83-b17-20090706/innodb_extra_status.patch747
-rw-r--r--percona/5.0.83-b17-20090706/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.83-b17-20090706/innodb_io_patches.patch705
-rw-r--r--percona/5.0.83-b17-20090706/innodb_io_pattern.patch688
-rw-r--r--percona/5.0.83-b17-20090706/innodb_io_tune.patch1823
-rw-r--r--percona/5.0.83-b17-20090706/innodb_locks_held.patch219
-rw-r--r--percona/5.0.83-b17-20090706/innodb_rw_lock.patch1357
-rw-r--r--percona/5.0.83-b17-20090706/innodb_show_bp.patch447
-rw-r--r--percona/5.0.83-b17-20090706/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.83-b17-20090706/innodb_show_hashed_memory_standalone.patch264
-rw-r--r--percona/5.0.83-b17-20090706/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.83-b17-20090706/microsec_process.patch282
-rw-r--r--percona/5.0.83-b17-20090706/microslow_innodb.patch2493
-rw-r--r--percona/5.0.83-b17-20090706/mirror_binlog.patch2694
-rw-r--r--percona/5.0.83-b17-20090706/mysql-test.patch108
-rw-r--r--percona/5.0.83-b17-20090706/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.83-b17-20090706/profiling_slow.patch271
-rw-r--r--percona/5.0.83-b17-20090706/series20
-rw-r--r--percona/5.0.83-b17-20090706/show_patches.patch288
-rw-r--r--percona/5.0.83-b17-20090706/split_buf_pool_mutex_fixed_optimistic_safe.patch1316
-rw-r--r--percona/5.0.83-b17-20090706/userstatv2.patch4387
-rw-r--r--percona/5.0.83-b17-20090723/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.83-b17-20090723/innodb_dict_size_limit.patch483
-rw-r--r--percona/5.0.83-b17-20090723/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.83-b17-20090723/innodb_extra_status.patch747
-rw-r--r--percona/5.0.83-b17-20090723/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.83-b17-20090723/innodb_io_patches.patch1379
-rw-r--r--percona/5.0.83-b17-20090723/innodb_io_pattern.patch688
-rw-r--r--percona/5.0.83-b17-20090723/innodb_io_tune.patch1823
-rw-r--r--percona/5.0.83-b17-20090723/innodb_locks_held.patch219
-rw-r--r--percona/5.0.83-b17-20090723/innodb_rw_lock.patch1357
-rw-r--r--percona/5.0.83-b17-20090723/innodb_show_bp.patch447
-rw-r--r--percona/5.0.83-b17-20090723/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.83-b17-20090723/innodb_show_hashed_memory_standalone.patch264
-rw-r--r--percona/5.0.83-b17-20090723/innodb_split_buf_pool_mutex.patch1870
-rw-r--r--percona/5.0.83-b17-20090723/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.83-b17-20090723/innodb_use_sys_malloc.patch225
-rw-r--r--percona/5.0.83-b17-20090723/microsec_process.patch282
-rw-r--r--percona/5.0.83-b17-20090723/microslow_innodb.patch2493
-rw-r--r--percona/5.0.83-b17-20090723/mirror_binlog.patch2694
-rw-r--r--percona/5.0.83-b17-20090723/mysql-test.patch108
-rw-r--r--percona/5.0.83-b17-20090723/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.83-b17-20090723/profiling_slow.patch271
-rw-r--r--percona/5.0.83-b17-20090723/series20
-rw-r--r--percona/5.0.83-b17-20090723/show_patches.patch288
-rw-r--r--percona/5.0.83-b17-20090723/split_buf_pool_mutex_fixed_optimistic_safe.patch1316
-rw-r--r--percona/5.0.83-b17-20090723/userstatv2.patch4386
-rw-r--r--percona/5.0.84-b18-20090811/README-GENTOO7
-rw-r--r--percona/5.0.84-b18-20090811/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.84-b18-20090811/innodb_dict_size_limit.patch483
-rw-r--r--percona/5.0.84-b18-20090811/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.84-b18-20090811/innodb_extra_status.patch747
-rw-r--r--percona/5.0.84-b18-20090811/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.84-b18-20090811/innodb_io_patches.patch1379
-rw-r--r--percona/5.0.84-b18-20090811/innodb_io_pattern.patch693
-rw-r--r--percona/5.0.84-b18-20090811/innodb_io_tune.patch1823
-rw-r--r--percona/5.0.84-b18-20090811/innodb_locks_held.patch219
-rw-r--r--percona/5.0.84-b18-20090811/innodb_recovery_patches.patch217
-rw-r--r--percona/5.0.84-b18-20090811/innodb_rw_lock.patch1357
-rw-r--r--percona/5.0.84-b18-20090811/innodb_show_bp.patch453
-rw-r--r--percona/5.0.84-b18-20090811/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.84-b18-20090811/innodb_show_hashed_memory_standalone.patch264
-rw-r--r--percona/5.0.84-b18-20090811/innodb_split_buf_pool_mutex.patch1870
-rw-r--r--percona/5.0.84-b18-20090811/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.84-b18-20090811/innodb_use_sys_malloc.patch265
-rw-r--r--percona/5.0.84-b18-20090811/microsec_process.patch282
-rw-r--r--percona/5.0.84-b18-20090811/microslow_innodb.patch2492
-rw-r--r--percona/5.0.84-b18-20090811/mirror_binlog.patch2694
-rw-r--r--percona/5.0.84-b18-20090811/mysql-percona.spec1421
-rw-r--r--percona/5.0.84-b18-20090811/mysql-test.patch108
-rw-r--r--percona/5.0.84-b18-20090811/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.84-b18-20090811/profiling_slow.patch271
-rw-r--r--percona/5.0.84-b18-20090811/series21
-rw-r--r--percona/5.0.84-b18-20090811/show_patches.patch288
-rw-r--r--percona/5.0.84-b18-20090811/userstatv2.patch4394
-rw-r--r--percona/5.0.87-b20-20091116/README-GENTOO8
-rw-r--r--percona/5.0.87-b20-20091116/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.87-b20-20091116/innodb_dict_size_limit.patch633
-rw-r--r--percona/5.0.87-b20-20091116/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.87-b20-20091116/innodb_extra_status.patch747
-rw-r--r--percona/5.0.87-b20-20091116/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.87-b20-20091116/innodb_io_patches.patch1379
-rw-r--r--percona/5.0.87-b20-20091116/innodb_io_pattern.patch693
-rw-r--r--percona/5.0.87-b20-20091116/innodb_io_tune.patch1823
-rw-r--r--percona/5.0.87-b20-20091116/innodb_locks_held.patch219
-rw-r--r--percona/5.0.87-b20-20091116/innodb_misc_patch.patch64
-rw-r--r--percona/5.0.87-b20-20091116/innodb_recovery_patches.patch217
-rw-r--r--percona/5.0.87-b20-20091116/innodb_rw_lock.patch2480
-rw-r--r--percona/5.0.87-b20-20091116/innodb_rw_lock_old.patch1357
-rw-r--r--percona/5.0.87-b20-20091116/innodb_show_bp.patch453
-rw-r--r--percona/5.0.87-b20-20091116/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.87-b20-20091116/innodb_show_hashed_memory_standalone.patch264
-rw-r--r--percona/5.0.87-b20-20091116/innodb_split_buf_pool_mutex.patch1895
-rw-r--r--percona/5.0.87-b20-20091116/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.87-b20-20091116/innodb_use_sys_malloc.patch265
-rw-r--r--percona/5.0.87-b20-20091116/microsec_process.patch282
-rw-r--r--percona/5.0.87-b20-20091116/microslow_innodb.patch2492
-rw-r--r--percona/5.0.87-b20-20091116/mirror_binlog.patch2694
-rw-r--r--percona/5.0.87-b20-20091116/mysql-test.patch108
-rw-r--r--percona/5.0.87-b20-20091116/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.87-b20-20091116/profiling_slow.patch271
-rw-r--r--percona/5.0.87-b20-20091116/series22
-rw-r--r--percona/5.0.87-b20-20091116/show_patches.patch288
-rw-r--r--percona/5.0.87-b20-20091116/userstatv2.patch4394
-rw-r--r--percona/5.0.87-b20-20100217/README-GENTOO7
-rw-r--r--percona/5.0.87-b20-20100217/innodb_check_fragmentation.patch275
-rw-r--r--percona/5.0.87-b20-20100217/innodb_dict_size_limit.patch633
-rw-r--r--percona/5.0.87-b20-20100217/innodb_extra_rseg.patch243
-rw-r--r--percona/5.0.87-b20-20100217/innodb_extra_status.patch747
-rw-r--r--percona/5.0.87-b20-20100217/innodb_fsync_source.patch594
-rw-r--r--percona/5.0.87-b20-20100217/innodb_io_patches.patch1379
-rw-r--r--percona/5.0.87-b20-20100217/innodb_io_pattern.patch693
-rw-r--r--percona/5.0.87-b20-20100217/innodb_locks_held.patch219
-rw-r--r--percona/5.0.87-b20-20100217/innodb_misc_patch.patch64
-rw-r--r--percona/5.0.87-b20-20100217/innodb_recovery_patches.patch217
-rw-r--r--percona/5.0.87-b20-20100217/innodb_rw_lock.patch2480
-rw-r--r--percona/5.0.87-b20-20100217/innodb_rw_lock_old.patch1357
-rw-r--r--percona/5.0.87-b20-20100217/innodb_show_bp.patch453
-rw-r--r--percona/5.0.87-b20-20100217/innodb_show_hashed_memory.patch275
-rw-r--r--percona/5.0.87-b20-20100217/innodb_show_hashed_memory_standalone.patch264
-rw-r--r--percona/5.0.87-b20-20100217/innodb_split_buf_pool_mutex.patch1895
-rw-r--r--percona/5.0.87-b20-20100217/innodb_thread_concurrency_timer_based.patch389
-rw-r--r--percona/5.0.87-b20-20100217/innodb_use_sys_malloc.patch265
-rw-r--r--percona/5.0.87-b20-20100217/microsec_process.patch282
-rw-r--r--percona/5.0.87-b20-20100217/microslow_innodb.patch2492
-rw-r--r--percona/5.0.87-b20-20100217/mirror_binlog.patch2694
-rw-r--r--percona/5.0.87-b20-20100217/mysql-test.patch108
-rw-r--r--percona/5.0.87-b20-20100217/mysqld_safe_syslog.patch127
-rw-r--r--percona/5.0.87-b20-20100217/profiling_slow.patch271
-rw-r--r--percona/5.0.87-b20-20100217/series22
-rw-r--r--percona/5.0.87-b20-20100217/show_patches.patch288
-rw-r--r--percona/5.0.87-b20-20100217/userstatv2.patch4394
375 files changed, 5 insertions, 284883 deletions
diff --git a/00000_index.txt b/00000_index.txt
index 436dc69..c575c84 100644
--- a/00000_index.txt
+++ b/00000_index.txt
@@ -1,65 +1,21 @@
-@patch 00100_all_mysql-4.0-my-print-defaults.patch
-@ver 4.00.00.00 to 4.00.26.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ /etc => /etc/mysql
-
@patch 00100_all_default-dir-4.0.27.patch
@ver 4.00.27.00 to 4.00.27.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ /etc => /etc/mysql
-
-@patch 00100_all_default-dir-4.0.28.patch
-@ver 4.00.28.00 to 4.00.99.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ /etc => /etc/mysql
@patch 00100_all_default-dir-4.1.15.patch
@ver 4.01.15.00 to 4.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Move config directory to the gentoo default
-@patch 00100_all_default-dir-5.0.19.patch
-@ver 5.00.19.00 to 5.00.19.99
-@ver 5.01.07.00 to 5.01.09.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ upstream http://lists.mysql.com/commits/3885?f=plain
-@@ fix MySQL Bug#15069
-@@ does not fix gentoo Bug#126054
-
@patch 00200_all_gentoo-nptl-4.0.18.patch
@ver 4.00.18.00 to 4.00.27.99
-@ver 4.01.00.00 to 4.01.11.99
-@ver 5.00.00.00 to 5.00.03.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Add support for NPTL
@patch 00300_all_thrssl-4.0.patch
@ver 4.00.00.00 to 4.00.27.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Link libmysqlclient_r against ssl
-# attempt to get libmysqlclient_r linked against ssl if USE="ssl" enabled
-# i would really prefer to fix this at the Makefile.am level, but can't
-# get the software to autoreconf as distributed - too many missing files
-
-@patch 00300_all_thrssl-4.0.28.patch
-@ver 4.00.28.00 to 4.00.99.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Link libmysqlclient_r against ssl
# attempt to get libmysqlclient_r linked against ssl if USE="ssl" enabled
# i would really prefer to fix this at the Makefile.am level, but can't
@@ -67,48 +23,24 @@
@patch 00300_all_thrssl-4.1.21.patch
@ver 4.01.21.00 to 4.01.22.99
-@ver 5.00.00.00 to 5.00.04.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Link libmysqlclient_r against ssl
-
-@patch 00300_all_thrssl-4.1.23.patch
-@ver 4.01.23.00 to 4.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Link libmysqlclient_r against ssl
@patch 00350_x86_asm-pic-fixes-4.0.27.patch
@ver 4.00.25.00 to 4.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ remove page relocations
@@ _many_ thanks to pageexec@freemail.hu
@patch 00350_x86_asm-pic-fixes-4.1.12.patch
@ver 4.01.12.00 to 4.01.99.99
@ver 5.00.12.00 to 5.00.99.99
-@ver 5.01.00.00 to 5.01.10.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ remove page relocations
@@ Most part of the original patch has already been accepted by MysQL,
@@ here is the remaining.
@@ _many_ thanks to pageexec@freemail.hu
-@patch 00350_x86_asm-pic-fixes-5.1.41.patch
-@ver 5.01.39.00 to 5.01.55.99
-@pn mysql
-@pn mariadb
-@@ remove page relocations
-@@ Most of the original patch has already been accepted by MysQL,
-@@ here is the remaining.
-@@ _many_ thanks to pageexec@freemail.hu
-
@patch 00350_x86_asm-pic-fixes-5.1.56.patch
@ver 5.01.56.00 to 5.01.99.99
@pn mysql
@@ -121,113 +53,21 @@
@patch 00400_all_tcpd-vars-fix-4.0.14.patch
@ver 4.00.14.00 to 4.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@patch 00600_all_nisam_maykeylen-4.0.27.patch
@ver 4.00.00.00 to 4.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Enlarge max key length
-@patch 00800_all_slot_script-4.0.patch
-@ver 4.00.26.00 to 4.00.99.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-4.1.16.patch
-@ver 4.01.16.00 to 4.01.22.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-4.1.23.patch
-@ver 4.01.23.00 to 4.01.99.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.0.17.patch
-@ver 5.01.00.00 to 5.01.08.99
-@ver 5.00.17.00 to 5.00.20.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.0.21.patch
-@ver 5.00.21.00 to 5.00.33.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.0.34.patch
-@ver 5.00.34.00 to 5.00.99.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.1.10.patch
-@ver 5.01.09.00 to 5.01.11.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.1.12.patch
-@ver 5.01.12.00 to 5.01.13.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.1.14.patch
-@ver 5.01.14.00 to 5.01.14.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00800_all_slot_script-5.1.15.patch
-@ver 5.01.15.00 to 5.02.99.99
-@pn mysql-slotted
-@@ add slot MySQL support to scripts utilities
-
-@patch 00810_all_slot_manager-5.0.19.patch
-@ver 5.00.19.00 to 5.00.99.99
-@pn mysql-slotted
-@@ add slot support for mysqlmanager
-
-@patch 00810_all_slot_manager-5.1.7.patch
-@ver 5.01.07.00 to 5.01.08.99
-@pn mysql-slotted
-@@ add slot support for mysqlmanager
-
-@patch 00810_all_slot_manager-5.1.10.patch
-@ver 5.01.09.00 to 5.02.09.99
-@pn mysql-slotted
-@@ add slot support for mysqlmanager
-
-@patch 01000_all_bug23427-abi-breakage-5.0.26.patch
-@ver 5.00.26.00 to 5.00.26.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix MySQL bug #23427
-
-@patch 01010_all_bootstrap_no_plugin.patch
-@ver 5.01.13.00 to 5.01.41.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ prevent loading of modules from plugin table when in bootstrap mode
-@@ Thanks solar, bug #158777
-@@ TODO: Need to check the status with 5.1.41
-
@patch 01050_all_mysql_config_cleanup.patch
@ver 4.01.22.00 to 4.01.99.99
-@ver 5.00.26.00 to 5.00.56.99
-@ver 5.01.21.99 to 5.01.38.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ fix bug #156301 mysql_config wrongly retains too much info from CFLAGS
@patch 01050_all_mysql_config_cleanup-5.0.60.patch
@ver 5.00.60.00 to 5.00.86.99
@ver 5.01.00.00 to 5.01.21.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ fix bug #156301 mysql_config wrongly retains too much info from CFLAGS
@patch 01050_all_mysql_config_cleanup-5.1.41.patch
@@ -278,68 +118,14 @@
@patch 02000_all_query-logging-bypass-4.1.19.patch
@ver 4.01.14.00 to 4.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Fix bug #128713
@@ dev-db/mysql: Query Logging Bypass Vulnerability (CVE-2006-0903)
-@patch 02000_all_query-logging-bypass-5.0.21.patch
-@ver 5.00.00.00 to 5.00.23.99
-@ver 5.01.00.00 to 5.01.10.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix bug #128713
-@@ dev-db/mysql: Query Logging Bypass Vulnerability (CVE-2006-0903)
-
-@patch 02020_all_embedded-library-compile-5.0.38.patch
-@ver 5.00.38.00 to 5.00.39.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Compile fix for USE=embedded
-
-@patch 02040_all_embedded-library-shared-5.0.76.patch
-@ver 5.0.76.00 to 5.00.79.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-5.0.77.patch
-@ver 5.0.77.00 to 5.00.99.99
-@pn mysql-community
-@@ Take libmysqld to be a proper shared library.
-
-# This is really a symlink to the old mysql-community version
-@patch 02040_all_embedded-library-shared-5.0.83.patch
-@ver 5.0.83.00 to 5.00.91.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-5.0.92.patch
-@ver 5.0.92.00 to 5.00.95.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
@patch 02040_all_embedded-library-shared-5.0.96.patch
@ver 5.0.96.00 to 5.00.99.99
@pn mysql
@@ Take libmysqld to be a proper shared library.
-@patch 02040_all_embedded-library-shared-5.1.43.patch
-@ver 5.01.43.00 to 5.01.49.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-5.1.50.patch
-@ver 5.01.50.00 to 5.01.59.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-5.1.60.patch
-@ver 5.01.60.00 to 5.01.68.99
-@pn mysql
-@@ Take libmysqld to be a proper shared library.
-
@patch 02040_all_embedded-library-shared-5.1.69.patch
@ver 5.01.69.00 to 5.01.99.99
@pn mysql
@@ -348,6 +134,7 @@
@patch 02040_all_embedded-library-shared-5.5.10.patch
@ver 5.05.10.00 to 5.07.99.99
@pn mysql
+@pn percona-server
@@ Take libmysqld to be a proper shared library.
@patch 02040_all_embedded-library-shared-5.5.10.patch
@@ -355,96 +142,35 @@
@pn mysql-cluster
@@ Take libmysqld to be a proper shared library.
-@patch 02040_all_embedded-library-shared-5.5.10.patch
-@ver 5.05.10.00 to 5.07.99.99
-@pn percona-server
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-maria-5.1.50.patch
-@ver 5.01.50.00 to 5.01.52.99
-@pn mariadb
-@@ Take libmysqld to be a proper shared library.
-
-@patch 02040_all_embedded-library-shared-maria-5.2.03.patch
-@ver 5.02.03.00 to 5.02.03.99
-@pn mariadb
-@@ Take libmysqld to be a proper shared library.
-
@patch 04000_all_mysqld-safe-sh-4.0.27.patch
@ver 4.00.00.00 to 4.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Change paths detection in mysqld_safe
@patch 04010_all_install-db-sh-4.0.27.patch
@ver 4.00.00.00 to 4.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Change an output comment in mysql_install_db
@patch 07000_all_mysqldump-missing-cfgfile-fix-4.1.21.patch
@ver 4.01.21.00 to 4.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Add configuration section for mysqldump
@patch 07010_all_rpl000015-portsobst-fix-4.1.21.patch
@ver 4.01.21.00 to 4.01.22.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ normalize port 3306 in tests
-@patch 07010_all_rpl000015-portsobst-fix-4.1.23.patch
-@ver 4.01.23.00 to 4.01.99.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ normalize port 3306 in tests
-
-@patch 07010_all_rpl000015-portsobst-fix-5.0.26.patch
-@ver 5.00.26.00 to 5.00.31.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ normalize port 3306 in tests
-
-@patch 07020_all_trigger-rename-fail-as-root-5.0.26.patch
-@ver 5.00.26.00 to 5.00.33.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ portage normally ran as root, MySQL tests are designed to be used
-@@ with lower priviledges
-
-@patch 07020_all_trigger-rename-fail-as-root-5.0.34.patch
-@ver 5.00.34.00 to 5.00.34.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ portage normally ran as root, MySQL tests are designed to be used
-@@ with lower priviledges
-
@patch 07030_all_test-rpl_rotate_logs-5.0.21.patch
@ver 5.00.26.00 to 5.00.99.99
-@ver 5.01.00.00 to 5.01.15.99
-@ver 5.02.00.00 to 5.02.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@patch 07040_all_disable_mybug_9735_test.patch
-@ver 5.00.26.00 to 5.00.81.99
-@ver 5.01.00.00 to 5.01.21.99
+@patch 07110_all_mysql_gcc-4.2_5.1.73.patch
+@ver 5.01.73.00 to 5.01.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ disable a test that fail on longtext field length, the expected value is
-@@ three times the returned one, look like a multibyte character related
-@@ failure.
+@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
+@@ FIXME: Testing patch - applies cleanly
@patch 07040_all_disable_mybug_9735_test-5.1.41.patch
@ver 5.01.39.00 to 5.01.99.99
@@ -454,281 +180,52 @@
@@ three times the returned one, look like a multibyte character related
@@ failure.
-@patch 07050_all_we-are-in-2007-now.patch
-@ver 5.00.26.00 to 5.00.32.99
-@ver 5.01.14.00 to 5.01.14.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ the view.test is year dependant
-
-@patch 07060_all_fix-nullpointer-dos.patch
-@ver 5.00.26.00 to 5.00.39.99
-@ver 5.01.00.00 to 5.01.15.99
-@ver 5.02.00.00 to 5.02.99.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix gentoo bug 171934
-
-@patch 07070_all_fix-nullpointer-dos-testcase.patch
-@ver 5.00.26.00 to 5.00.39.99
-@ver 5.01.00.00 to 5.01.15.99
-@ver 5.02.00.00 to 5.02.99.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Testcase for fix to gentoo bug 171934 (upstream bug #27513)
-
-@patch 07080_all_mysql_client_test-fix-pointer-aliasing-mysqlbug27383.patch
-@ver 5.00.42.00 to 5.00.44.99
-@ver 5.01.00.00 to 5.01.15.99
-@ver 5.02.00.00 to 5.02.09.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix for pointer aliasing that breaks mysql_client_test (upstream bug #27393)
-
-@patch 07090_all_innodb_spatial_crash_mybug_32125_5.0.patch
-@ver 5.00.42.00 to 5.00.53.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix for InnoDB 'CONTAINS' DoS (gentoo bug #198988, upstream bug #32125)
-
-@patch 07090_all_innodb_spatial_crash_mybug_32125_5.1.patch
-@ver 5.01.22.00 to 5.01.38.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix for InnoDB 'CONTAINS' DoS (gentoo bug #198988, upstream bug #32125)
-
-@patch 07100_all_respect_tmpdir_filesort_mybug_30287_5.0.patch
-@ver 5.00.44.00 to 5.00.47.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix for TMPDIR not being used during filesot (upstream bug #30287)
-
-@patch 07100_all_respect_tmpdir_filesort_mybug_30287_5.1.patch
-@ver 5.01.20.00 to 5.01.21.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Fix for TMPDIR not being used during filesot (upstream bug #30287)
-
-@patch 07110_all_mysql_gcc-4.2.patch
-@ver 5.00.42.00 to 5.00.50.99
-@ver 5.01.21.99 to 5.01.22.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-
-@patch 07110_all_mysql_gcc-4.2_5.0.54.patch
-@ver 5.00.54.00 to 5.00.55.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-# 5.0.56 and newer, as well as 5.0.51a do not need the MYSQL_MIN gcc-4.2 fix
-# anymore.
-
-@patch 07110_all_mysql_gcc-4.2_5.1.39.patch
-@ver 5.01.39.00 to 5.01.39.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.41.patch
-@ver 5.01.41.00 to 5.01.41.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.42.patch
-@ver 5.01.42.00 to 5.01.42.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.43.patch
-@ver 5.01.43.00 to 5.01.45.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.46.patch
-@ver 5.01.46.00 to 5.01.48.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.49.patch
-@ver 5.01.49.00 to 5.01.49.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.50.patch
-@ver 5.01.50.00 to 5.01.50.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.51.patch
-@ver 5.01.51.00 to 5.01.55.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.56.patch
-@ver 5.01.56.00 to 5.01.56.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.57.patch
-@ver 5.01.57.00 to 5.01.57.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.58.patch
-@ver 5.01.58.00 to 5.01.59.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.60.patch
-@ver 5.01.60.00 to 5.01.61.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.62.patch
-@ver 5.01.62.00 to 5.01.64.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.65.patch
-@ver 5.01.65.00 to 5.01.68.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.69.patch
-@ver 5.01.69.00 to 5.01.72.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-@patch 07110_all_mysql_gcc-4.2_5.1.73.patch
-@ver 5.01.73.00 to 5.01.99.99
-@pn mysql
-@@ Replace max() and min() macro with MYSQL_MIN() and MYSQL_MAX()
-@@ FIXME: Testing patch - applies cleanly
-
-
-@patch 07120_all_openssl_handshake_mybug_33050.patch
-@ver 5.00.50.00 to 5.00.54.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Set the connection type for OpenSSL to not break the handshake (upstream bug 33050)
-
-@patch 07130_all_mysqldump-hang-33057_5.0.52.patch
-@ver 5.00.52.00 to 5.00.54.99
-@pn mysql
-@pn mysql-community
-@pn mysql-slotted
-@@ Avoid hang during mysqldump
-
@patch 07140_all_no-atomic-configure.patch
@ver 5.00.50.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ No atomic garbage in configure.in
@patch 07150_all_mysql_config_libdir.patch
@ver 5.00.50.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Do not muck with libdir in mysql_config
@patch 07160_all_flush_priveleges_in_tests.patch
@ver 5.00.50.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ Flush privileges during some tests to avoid false positives
@patch 07170_all_safe_s390x_stack_size.patch
@ver 5.00.50.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
-@pn mysql-slotted
@@ s390x needs a sane stack size
-@patch 07190_all_disallow_database_ops_without_super_mybug_27440.patch
-@ver 5.00.51.00 to 5.00.55.99
-@ver 5.01.21.00 to 5.01.22.99
-@pn mysql
-@pn mysql-community
-@@ Fix for read_only allowing create/drop database without SUPER (upstream bug 27440)
-
@patch 07200_all_libtool_2_2_4.patch
@ver 4.01.22.00 to 4.01.99.99
@ver 5.00.50.00 to 5.00.99.99
@ver 5.01.21.00 to 5.01.22.99
@pn mysql
-@pn mysql-community
@@ automake is more strict with libtool-2.2.4
@@ Gentoo bug 220549
-@patch 07210_all_encode_html_entities-5.0.70.patch
-@ver 5.00.45.00 to 5.00.89.99
-@pn mysql
-@pn mysql-community
-@@ Fix CVE-2008-4456 XSS in command line client (Gentoo #240407, MySQL #27884)
-
-@patch 07210_all_encode_html_entities_testcase-5.0.72.patch
-@ver 5.00.72.00 to 5.00.72.99
-@pn mysql
-@pn mysql-community
-@@ Testcase for CVE-2008-4456
-
-@patch 07210_all_encode_html_entities_testcase-5.0.76.patch
-@ver 5.00.76.00 to 5.00.81.99
-@pn mysql
-@pn mysql-community
-@@ Testcase for CVE-2008-4456
-
@patch 07210_all_encode_html_entities_testcase-5.0.83.patch
@ver 5.00.82.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
@@ Testcase for CVE-2008-4456
@patch 07220_all_need_upgraded_grant_tables_for_grant.patch
@ver 5.00.18.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
@@ Do not crash on old grant tables when GRANT is called (Gentoo #229329, MySQL #16470)
@patch 07230_all_avoid_bus_error_5.0.76.patch
@ver 5.00.72.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
@@ Prevent SIGBUS on Sparc with NDB
@patch 07240_all_as-needed-config-5.0.76.patch
@ver 5.00.76.00 to 5.00.99.99
@pn mysql
-@pn mysql-community
@@ Fix LDFLAGS inclusion in the mysql_config libs output for --as-needed usage.
@patch 07250_all_testcase_latin1_fix-5.1.42.patch
@@ -745,21 +242,6 @@
@@ Latin1 is assumed by the testsuite even with --with-charset=utf8
@@ is passed to configure. Fix information_schema test.
-@patch 07270_all_charset_boot_fix-5.1.43.patch
-@ver 5.01.43.00 to 5.01.44.00
-@pn mysql
-@@ Revert charset initialization changes that broke Akonadi.
-
-@patch 07270_all_charset_boot_fix-5.1.44.patch
-@ver 5.01.44.01 to 5.01.44.99
-@pn mysql
-@@ Revert charset initialization changes that broke Akonadi.
-
-@patch 07271_all_charset_init_fix-5.1.44.patch
-@ver 5.01.44.01 to 5.01.44.99
-@pn mysql
-@@ Workaround the pthread_once_t static initialization.
-
@patch 07280_all_stdbool-5.0.90.patch
@ver 5.00.84.00 to 5.00.99.99
@pn mysql
@@ -770,11 +252,6 @@
@pn mysql
@@ Fix GCC4.4 stdbool requirement.
-@patch 07280_all_stdbool-maria-5.1.42.patch
-@ver 5.01.00.00 to 5.01.61.99
-@pn mariadb
-@@ Fix GCC4.4 stdbool requirement.
-
@patch 07280_all_stdbool-maria-5.1.62.patch
@ver 5.01.62.00 to 5.01.99.99
@pn mariadb
@@ -786,52 +263,12 @@
@pn mysql-cluster
@@ Bug #308999: Fix false positives with between OK/"Table is already up to date" output
-@patch 07300_all_mysql_embedded_compilefix-5.0.91.patch
-@ver 5.00.91.00 to 5.00.91.99
-@pn mysql
-@@ Compile fix for bug introduced by upstream in 5.0.91
-
-@patch 07310_all_mysql_gcc45-disable-abicheck.patch
-@ver 5.01.00.00 to 5.01.49.99
-@pn mysql
-@@ GCC4.5 fails on the ABI-check block
-
-@patch 07320_all_mysql_mycompiler_header.patch
-@ver 5.01.50.00 to 5.01.50.99
-@pn mysql
-@@ my_compiler.h is not installed, but is required.
-
-@patch 07330_all_mysql_itemfunc_stacksize_bug57386.patch
-@ver 5.01.50.00 to 5.01.55.99
-@pn mysql
-@pn maria
-@pn mysql-cluster
-@@ Bug#57386: Enlarge the stacksize used for trackback.
-
-@patch 07340_all_mysql_hardened_x86_strings.patch
-@ver 5.01.51.00 to 5.01.68.99
-@pn mysql
-@pn mysql-cluster
-@@ Gentoo Bug #344031: Fix new TEXTRELs (remove old strings-x86.s file, for case-insensitive file-systems).
-
-@patch 07340_all_mysql_hardened_x86_strings-5.1.69.patch
-@ver 5.01.69.00 to 5.01.69.99
-@pn mysql
-@pn mysql-cluster
-@@ Gentoo Bug #344031: Fix new TEXTRELs (remove old strings-x86.s file, for case-insensitive file-systems).
-
@patch 07340_all_mysql_hardened_x86_strings-5.1.70.patch
@ver 5.01.70.00 to 5.01.99.99
@pn mysql
@pn mysql-cluster
@@ Gentoo Bug #344031: Fix new TEXTRELs (remove old strings-x86.s file, for case-insensitive file-systems).
-@patch 07341_all_mysql_hardened_x86_strings.patch
-@ver 5.01.51.00 to 5.01.55.99
-@pn mysql
-@pn mysql-cluster
-@@ Gentoo Bug #344031: Fix new TEXTRELs
-
@patch 07341_all_mysql-5.1.56_hardened_x86_strings.patch
@ver 5.01.56.00 to 5.01.99.99
@pn mysql
@@ -843,619 +280,121 @@
@pn mariadb
@@ Gentoo Bug #344031: Fix new TEXTRELs (remove old strings-x86.s file, for case-insensitive file-systems).
-@patch 07341_all_mariadb_hardened_x86_strings.patch
-@ver 5.01.51.00 to 5.01.54.99
-@pn mariadb
-@@ Gentoo Bug #344031: Fix new TEXTRELs
-
@patch 07341_all_mariadb_5.1.55_hardened_x86_strings.patch
@ver 5.01.55.00 to 5.01.99.99
@pn mariadb
@@ Gentoo Bug #344031: Fix new TEXTRELs
-@patch 07342_all_mysql_auth_bypass-5.1.62.patch
-@ver 5.01.62.00 to 5.01.62.99
-@pn mysql
-@@ Upstream bug #64884: auth bypass
-
@patch 07342_all_mysql_auth_bypass-5.5.22.patch
@ver 5.05.22.00 to 5.05.22.99
@pn mysql
@@ Upstream bug #64884: auth bypass
-@patch 10010_all_show_patches-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Patch listing in build data
-
-@patch 10010_all_show_patches-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Patch listing in build data
-
-@patch 10010_all_show_patches-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: SHOW PATCHES
-
-@patch 10010_all_show_patches-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: SHOW PATCHES
-
-@patch 10010_all_show_patches-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: SHOW PATCHES
-
@patch 10010_all_show_patches-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: SHOW PATCHES
-@patch 10020_all_microslow_innodb-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Extended statistics in slow.log
-
-@patch 10020_all_microslow_innodb-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Extended statistics in slow.log
-
-@patch 10020_all_microslow_innodb-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Extended statistics in slow.log
-
-@patch 10020_all_microslow_innodb-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Extended statistics in slow.log
-
-@patch 10020_all_microslow_innodb-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Extended statistics in slow.log
-
-@patch 10020_all_microslow_innodb-percona-5.0.91-b22-20100522.patch
-@ver 5.00.91.00 to 5.00.91.99
-@pn mysql
-@@ Percona 5.0.91-b22-20100522: Extended statistics in slow.log
-
@patch 10020_all_microslow_innodb-percona-5.0.92.patch
@ver 5.00.92.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.92: Extended statistics in slow.log
-@patch 10021_all_profiling_slow-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: profiling from SHOW PROFILE to slow.log
-
-@patch 10021_all_profiling_slow-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: profiling from SHOW PROFILE to slow.log
-
-@patch 10021_all_profiling_slow-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: profiling from SHOW PROFILE to slow.log
-
@patch 10021_all_profiling_slow-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: profiling from SHOW PROFILE to slow.log
-@patch 10030_all_userstatv2-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.91-b22-20100522.patch
-@ver 5.00.91.00 to 5.00.91.99
-@pn mysql
-@@ Percona 5.0.91-b22-20100522: SHOW USER/TABLE/INDEX statistics
-
-@patch 10030_all_userstatv2-percona-5.0.92.patch
-@ver 5.00.92.00 to 5.00.95.99
-@pn mysql
-@@ Percona 5.0.92: SHOW USER/TABLE/INDEX statistics
-
@patch 10030_all_userstatv2-percona-5.0.96.patch
@ver 5.00.96.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.96: SHOW USER/TABLE/INDEX statistics (Gentoo forward-port)
-@patch 10040_all_microsec_process-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-
-@patch 10040_all_microsec_process-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-
-@patch 10040_all_microsec_process-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-
-@patch 10040_all_microsec_process-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-
-@patch 10040_all_microsec_process-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-
@patch 10040_all_microsec_process-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-@patch 10050_all_innodb_io_patches-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Cluster of past InnoDB IO patches
-
-@patch 10050_all_innodb_io_patches-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Cluster of past InnoDB IO patches
-
-@patch 10050_all_innodb_io_patches-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Cluster of past InnoDB IO patches
-
-@patch 10050_all_innodb_io_patches-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Cluster of past InnoDB IO patches
-
-@patch 10050_all_innodb_io_patches-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Cluster of past InnoDB IO patches
-
@patch 10050_all_innodb_io_patches-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Cluster of past InnoDB IO patches
-# Disabled, broken.
-#@patch 10060_all_mirror_binlog-percona-5.0.75-b12.patch
-#@ver 5.00.75.00 to 5.00.76.99
-#@pn mysql-community
-#@@ Percona 5.0.75-b12: Mirroring binary logs on slave
-
-# Disabled, broken.
-#@patch 10060_all_mirror_binlog-percona-5.0.77-b13.patch
-#@ver 5.00.77.00 to 5.00.77.99
-#@pn mysql-community
-#@@ Percona 5.0.77-b13: Mirroring binary logs on slave
-
-# Disabled, broken.
-#@patch 10060_all_mirror_binlog-percona-5.0.83-b17-20090706.patch
-#@ver 5.00.83.00 to 5.00.83.99
-#@pn mysql
-#@@ Percona 5.0.83-b17-20090706: Mirroring binary logs on slave
-
-@patch 10070_all_mysqld_safe_syslog-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: allows redirect output of error.log to syslog-ng
-
-@patch 10070_all_mysqld_safe_syslog-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: allows redirect output of error.log to syslog-ng
-
-@patch 10070_all_mysqld_safe_syslog-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Patch allows redirect output of error.log to syslog-ng
-
-@patch 10070_all_mysqld_safe_syslog-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Patch allows redirect output of error.log to syslog-ng
-
-@patch 10070_all_mysqld_safe_syslog-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Patch allows redirect output of error.log to syslog-ng
-
@patch 10070_all_mysqld_safe_syslog-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Patch allows redirect output of error.log to syslog-ng
-@patch 10080_all_innodb_locks_held-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Add locks held, remove locked records in SHOW INNODB STATUS
-
-@patch 10080_all_innodb_locks_held-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Add locks held, remove locked records in SHOW INNODB STATUS
-
-@patch 10080_all_innodb_locks_held-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Add locks held, remove locked records in SHOW INNODB STATUS
-
-@patch 10080_all_innodb_locks_held-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Add locks held, remove locked records in SHOW INNODB STATUS
-
-@patch 10080_all_innodb_locks_held-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Add locks held, remove locked records in SHOW INNODB STATUS
-
@patch 10080_all_innodb_locks_held-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Add locks held, remove locked records in SHOW INNODB STATUS
-@patch 10090_all_innodb_show_bp-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: show innodb buffer pool content
-
-@patch 10090_all_innodb_show_bp-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: show innodb buffer pool content
-
-@patch 10090_all_innodb_show_bp-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: show innodb buffer pool content
-
-@patch 10090_all_innodb_show_bp-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: show innodb buffer pool content
-
-@patch 10090_all_innodb_show_bp-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: show innodb buffer pool content
-
@patch 10090_all_innodb_show_bp-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: show innodb buffer pool content
-@patch 10100_all_innodb_show_hashed_memory-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-
-@patch 10100_all_innodb_show_hashed_memory-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-
-@patch 10110_all_innodb_check_fragmentation-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Session status to check fragmentation of the last InnoDB scan
-
-@patch 10110_all_innodb_check_fragmentation-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Session status to check fragmentation of the last InnoDB scan
-
-@patch 10110_all_innodb_check_fragmentation-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Session status to check fragmentation of the last InnoDB scan
-
-@patch 10110_all_innodb_check_fragmentation-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Session status to check fragmentation of the last InnoDB scan
-
-@patch 10110_all_innodb_check_fragmentation-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Session status to check fragmentation of the last InnoDB scan
-
@patch 10110_all_innodb_check_fragmentation-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Session status to check fragmentation of the last InnoDB scan
-@patch 10120_all_innodb_io_pattern-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Information schema table of InnoDB IO counts for each datafile pages
-
-@patch 10120_all_innodb_io_pattern-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Information schema table of InnoDB IO counts for each datafile pages
-
-@patch 10120_all_innodb_io_pattern-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Information schema table of InnoDB IO counts for each datafile pages
-
-@patch 10120_all_innodb_io_pattern-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Information schema table of InnoDB IO counts for each datafile pages
-
-@patch 10120_all_innodb_io_pattern-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Information schema table of InnoDB IO counts for each datafile pages
-
@patch 10120_all_innodb_io_pattern-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Information schema table of InnoDB IO counts for each datafile pages
-@patch 10130_all_innodb_fsync_source-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Information of fsync callers in InnoDB
-
-@patch 10130_all_innodb_fsync_source-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Information of fsync callers in InnoDB
-
-@patch 10130_all_innodb_fsync_source-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Information of fsync callers in InnoDB
-
-@patch 10130_all_innodb_fsync_source-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Information of fsync callers in InnoDB
-
-@patch 10130_all_innodb_fsync_source-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Information of fsync callers in InnoDB
-
@patch 10130_all_innodb_fsync_source-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Information of fsync callers in InnoDB
-@patch 10139_all_innodb_show_hashed_memory-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-
-@patch 10139_all_innodb_show_hashed_memory-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-
-@patch 10139_all_innodb_show_hashed_memory-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-
@patch 10139_all_innodb_show_hashed_memory-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-@patch 10140_all_innodb_dict_size_limit-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Variable innodb_dict_size_limit in bytes
-
-@patch 10140_all_innodb_dict_size_limit-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Limit dictionary cache size
-
-@patch 10140_all_innodb_dict_size_limit-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Limit dictionary cache size
-
-@patch 10140_all_innodb_dict_size_limit-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Limit dictionary cache size
-
@patch 10140_all_innodb_dict_size_limit-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Limit dictionary cache size
-@patch 10160_all_innodb_extra_rseg-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: allow to create extra rollback segments
-
-@patch 10160_all_innodb_extra_rseg-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: allow to create extra rollback segments
-
-@patch 10160_all_innodb_extra_rseg-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: allow to create extra rollback segments
-
@patch 10160_all_innodb_extra_rseg-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: allow to create extra rollback segments
-@patch 10170_all_innodb_thread_concurrency_timer_based-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-
-@patch 10170_all_innodb_thread_concurrency_timer_based-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-
-@patch 10170_all_innodb_thread_concurrency_timer_based-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-
@patch 10170_all_innodb_thread_concurrency_timer_based-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-@patch 10200_all_mysql-test-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Fix some testcases
-
-@patch 10200_all_mysql-test-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811:
-
-@patch 10200_all_mysql-test-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116:
-
@patch 10200_all_mysql-test-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522:
-@patch 10500_all_innodb_use_sys_malloc-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: InnoDB uses malloc directly (backport from InnoDB-Plugin)
-
-@patch 10500_all_innodb_use_sys_malloc-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: InnoDB uses malloc directly (backport from InnoDB-Plugin)
-
@patch 10500_all_innodb_use_sys_malloc-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: InnoDB uses malloc directly (backport from InnoDB-Plugin)
-@patch 10510_all_innodb_recovery_patches-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Bugfixes and adjustments about recovery process
-
-@patch 10510_all_innodb_recovery_patches-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Bugfixes and adjustments about recovery process
-
@patch 10510_all_innodb_recovery_patches-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Bugfixes and adjustments about recovery process
-@patch 10511_all_innodb_misc_patch-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Identifies if thread is running a SELECT
-
@patch 10511_all_innodb_misc_patch-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: Identifies if thread is running a SELECT
-@patch 10520_all_innodb_split_buf_pool_mutex-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: InnoDB patch to fix buffer pool scalability
-
-@patch 10520_all_innodb_split_buf_pool_mutex-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: InnoDB patch to fix buffer pool scalability
-
@patch 10520_all_innodb_split_buf_pool_mutex-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ Percona 5.0.91-b22-20100522: InnoDB patch to fix buffer pool scalability
-@patch 11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: InnoDB patch to fix buffer pool scalability
-
-@patch 11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: InnoDB patch to fix buffer pool scalability
-
-@patch 11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: InnoDB patch to fix buffer pool scalability
-
-@patch 11010_all_innodb_rw_lock-percona-5.0.75-b12.patch
-@ver 5.00.75.00 to 5.00.76.99
-@pn mysql-community
-@@ Percona 5.0.75-b12: Fix of InnoDB rw_locks
-
-@patch 11010_all_innodb_rw_lock-percona-5.0.77-b13.patch
-@ver 5.00.77.00 to 5.00.77.99
-@pn mysql-community
-@@ Percona 5.0.77-b13: Fix of InnoDB rw_locks
-
-@patch 11010_all_innodb_rw_lock-percona-5.0.83-b17-20090706.patch
-@ver 5.00.83.00 to 5.00.83.99
-@pn mysql
-@@ Percona 5.0.83-b17-20090706: Fix of InnoDB rw_locks
-
-@patch 11010_all_innodb_rw_lock-percona-5.0.84-b18-20090811.patch
-@ver 5.00.84.00 to 5.00.84.99
-@pn mysql
-@@ Percona 5.0.84-b18-20090811: Fix of InnoDB rw_locks
-
-@patch 11010_all_innodb_rw_lock-percona-5.0.87-b20-20091116.patch
-@ver 5.00.87.00 to 5.00.90.99
-@pn mysql
-@@ Percona 5.0.87-b20-20091116: Fix of InnoDB rw_locks
-
@patch 11010_all_innodb_rw_lock-percona-5.0.91-b22-20100522.patch
@ver 5.00.91.00 to 5.00.99.99
@pn mysql
@@ -1464,14 +403,8 @@
@patch 15000_all_mysql_gcc-4.4_5.0.77.patch
@ver 5.00.77.00 to 5.00.90.99
@pn mysql
-@pn mysql-community
@@ GCC4.4 Fixup for Percona Patch
-@patch 15000_all_mariadb_libevent-system_5.1.42.patch
-@ver 5.01.39.00 to 5.01.42.99
-@pn mariadb
-@@ Clean up libevent autoconf usage
-
@patch 15010_all_innodb_show_bp-fixes-5.0.91.patch
@ver 5.00.87.00 to 5.00.99.99
@pn mysql
@@ -1560,26 +493,6 @@
@@ Fix the minimal build by reordering CMakeLists.txt
@@ Fixes MDEV-6562
-@patch 21000_all_sql-5.1.62.patch
-@ver 5.01.62.00 to 5.01.64.99
-@pn mariadb
-@@ Fix sql
-
-@patch 21000_all_sql-5.2.12.patch
-@ver 5.02.12.00 to 5.02.12.99
-@pn mariadb
-@@ Fix sql
-
-@patch 21000_all_sql-5.3.7.patch
-@ver 5.03.07.00 to 5.03.07.99
-@pn mariadb
-@@ Fix sql
-
-@patch 21000_all_sql-5.5.25.patch
-@ver 5.05.25.00 to 5.05.26.99
-@pn mariadb
-@@ Fix sql
-
@patch 20002_all_mysql-va-list.patch
@ver 5.05.00.00 to 5.05.99.99
@pn mysql
diff --git a/00100_all_default-dir-4.0.28.patch b/00100_all_default-dir-4.0.28.patch
deleted file mode 100644
index 7733a9c..0000000
--- a/00100_all_default-dir-4.0.28.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql-4.0.18-bk-20070101/mysys/default.c 2007-01-01 21:19:15.000000000 +0100
-+++ mysql-4.0.18-bk-20070101.orig/mysys/default.c 2007-01-01 20:46:31.000000000 +0100
-@@ -48,7 +48,7 @@
- #elif defined(__NETWARE__)
- "sys:/etc/",
- #else
--"/etc/",
-+"/etc/mysql/",
- #endif
- #ifdef DATADIR
- DATADIR,
diff --git a/00100_all_default-dir-5.0.19.patch b/00100_all_default-dir-5.0.19.patch
deleted file mode 100644
index 16fbcb7..0000000
--- a/00100_all_default-dir-5.0.19.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-From: msvensson at mysql dot com
-Date: April 10 2006 3:11pm
-Subject: bk commit into 5.0 tree (msvensson:1.2086) BUG#15069
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of msvensson. When msvensson does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet
- 1.2086 06/04/10 15:11:37 msvensson@shellback.(none) +3 -0
- Bug#15069 [patch] my_print_defaults does'nt care --sysconfdir
- - Grab the path from "configure --sysconfdir=<path>" and set it as
- the first place to look for my.cnf files
- Do this both in Makefiles for libmysql and mysys
- - Patch provided by Francesco Riosa. Thank you!
-
- mysys/default.c
- 1.81 06/04/10 15:11:32 msvensson@shellback.(none) +9 -1
- Use DEFAULT_SYSCONFDIR as first place to look for my.cnf file if "--sysconfdir=<path>" been specified as argument to configure
-
- mysys/Makefile.am
- 1.68 06/04/10 15:11:32 msvensson@shellback.(none) +1 -0
- Grab the path from "--sysconfdir=<path>" into the defined variable DEFAULT_SYSYCONFDIR
-
- libmysql/Makefile.shared
- 1.67 06/04/10 15:11:32 msvensson@shellback.(none) +1 -0
- Grab the path from "--sysconfdir=<path>" into the defined variable DEFAULT_SYSYCONFDIR
-
-# This is a BitKeeper patch. What follows are the unified diffs for the
-# set of deltas contained in the patch. The rest of the patch, the part
-# that BitKeeper cares about, is below these diffs.
-# User: msvensson
-# Host: shellback.(none)
-# Root: /home/msvensson/mysql/bug15069/my50-bug15069
-
---- 1.67/mysys/Makefile.am 2005-10-14 01:13:55 +02:00
-+++ 1.68/mysys/Makefile.am 2006-04-10 15:11:32 +02:00
-@@ -70,6 +70,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- -DDEFAULT_HOME_ENV=MYSQL_HOME \
- -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
-+ -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
- libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
-
---- 1.80/mysys/default.c 2005-09-30 12:25:36 +02:00
-+++ 1.81/mysys/default.c 2006-04-10 15:11:32 +02:00
-@@ -48,7 +48,7 @@
-
- /* Which directories are searched for options (and in which order) */
-
--#define MAX_DEFAULT_DIRS 6
-+#define MAX_DEFAULT_DIRS 7
- const char *default_directories[MAX_DEFAULT_DIRS + 1];
-
- #ifdef __WIN__
-@@ -959,11 +959,13 @@
- 4. getenv(DEFAULT_HOME_ENV)
- 5. Directory above where the executable is located
- 6. ""
-+ 7. --sysconfdir=<path>
-
- On Novell NetWare, this is:
- 1. sys:/etc/
- 2. getenv(DEFAULT_HOME_ENV)
- 3. ""
-+ 4. --sysconfdir=<path>
-
- On OS/2, this is:
- 1. getenv(ETC)
-@@ -971,12 +973,14 @@
- 3. getenv(DEFAULT_HOME_ENV)
- 4. ""
- 5. "~/"
-+ 6. --sysconfdir=<path>
-
- Everywhere else, this is:
- 1. /etc/
- 2. getenv(DEFAULT_HOME_ENV)
- 3. ""
- 4. "~/"
-+ 5. --sysconfdir=<path>
-
- */
-
-@@ -1040,6 +1044,10 @@
- }
- *ptr++= (char *)&config_dir;
- }
-+#endif
-+#ifdef DEFAULT_SYSCONFDIR
-+ if (DEFAULT_SYSCONFDIR != "")
-+ *ptr++= DEFAULT_SYSCONFDIR;
- #endif
- *ptr= 0; /* end marker */
- }
-
---- 1.66/libmysql/Makefile.shared 2006-01-18 13:09:42 +01:00
-+++ 1.67/libmysql/Makefile.shared 2006-04-10 15:11:32 +02:00
-@@ -85,6 +85,7 @@
- -DDATADIR="\"$(MYSQLDATAdir)\"" \
- -DDEFAULT_HOME_ENV=MYSQL_HOME \
- -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
-+ -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
-
- # The automatic dependencies miss this
diff --git a/00100_all_mysql-4.0-my-print-defaults.patch b/00100_all_mysql-4.0-my-print-defaults.patch
deleted file mode 100644
index b086563..0000000
--- a/00100_all_mysql-4.0-my-print-defaults.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql-4.0.1-alpha.orig/mysys/default.c Sun Dec 23 01:22:08 2001
-+++ mysql-4.0.1-alpha/mysys/default.c Sat Jun 22 18:56:03 2002
-@@ -47,7 +47,7 @@
- #ifdef __WIN__
- "C:/",
- #else
--"/etc/",
-+"/etc/mysql/",
- #endif
- #ifdef DATADIR
- DATADIR,
diff --git a/00300_all_thrssl-4.0.28.patch b/00300_all_thrssl-4.0.28.patch
deleted file mode 100644
index 5d8ac12..0000000
--- a/00300_all_thrssl-4.0.28.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql-4.0.18-bk-20070101/libmysql_r/Makefile.am 2007-01-01 20:46:25.000000000 +0100
-+++ mysql-4.0.18-bk-20070101.new/libmysql_r/Makefile.am 2007-01-02 10:16:18.000000000 +0100
-@@ -22,7 +22,7 @@
-
- target = libmysqlclient_r.la
- target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
--LIBS = @LIBS@ @openssl_libs@
-+LIBS = @CLIENT_LIBS@ @openssl_libs@
-
- INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include \
- -I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
diff --git a/00300_all_thrssl-4.1.23.patch b/00300_all_thrssl-4.1.23.patch
deleted file mode 100644
index 2123a27..0000000
--- a/00300_all_thrssl-4.1.23.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql/libmysql_r/Makefile.am 2007-01-01 20:44:03.000000000 +0100
-+++ mysql.new/libmysql_r/Makefile.am 2007-01-02 10:38:08.000000000 +0100
-@@ -22,7 +22,7 @@
-
- target = libmysqlclient_r.la
- target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
--LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
-+LIBS = @CLIENT_LIBS@ @ZLIB_LIBS@ @openssl_libs@
-
- INCLUDES = @MT_INCLUDES@ \
- -I$(top_builddir)/include -I$(top_srcdir)/include \
diff --git a/00300_all_thrssl-4.1.patch b/00300_all_thrssl-4.1.patch
deleted file mode 100644
index 2e6c893..0000000
--- a/00300_all_thrssl-4.1.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- mysql-4.1.11_alpha20050216.orig/libmysql_r/Makefile.am 2005-02-19 15:58:34.000000000 +0100
-+++ mysql-4.1.10/libmysql_r/Makefile.am 2005-02-19 15:59:02.000000000 +0100
-@@ -22,7 +22,7 @@
-
- target = libmysqlclient_r.la
- target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
--LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
-+LIBS = @CLIENT_LIBS@ @ZLIB_LIBS@ @openssl_libs@
-
- INCLUDES = @MT_INCLUDES@ \
- -I$(top_srcdir)/include $(openssl_includes) @ZLIB_INCLUDES@
---- mysql-4.1.11_alpha20050216.orig/libmysql_r/Makefile.in 2005-02-19 15:58:34.000000000 +0100
-+++ mysql-4.1.10/libmysql_r/Makefile.in 2005-02-19 15:59:24.000000000 +0100
-@@ -243,7 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
--LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
-+LIBS = @CLIENT_LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
- LM_CFLAGS = @LM_CFLAGS@
diff --git a/00350_x86_asm-pic-fixes-5.1.41.patch b/00350_x86_asm-pic-fixes-5.1.41.patch
deleted file mode 100644
index a3c97bd..0000000
--- a/00350_x86_asm-pic-fixes-5.1.41.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff -Naur mysql.old/strings/longlong2str-x86.s mysql.new/strings/longlong2str-x86.s
---- mysql.old/strings/longlong2str-x86.s 2005-08-27 22:33:11.000000000 +0200
-+++ mysql.new/strings/longlong2str-x86.s 2005-09-05 18:46:04.000000000 +0200
-@@ -214,3 +214,6 @@
-
- .L10end:
- .size longlong10_to_str,.L10end-longlong10_to_str
-+
-+ .section .note.GNU-stack,"",@progbits
-+
-diff -Naur mysql.old/strings/my_strtoll10-x86.s mysql.new/strings/my_strtoll10-x86.s
---- mysql.old/strings/my_strtoll10-x86.s 2005-08-27 22:33:19.000000000 +0200
-+++ mysql.new/strings/my_strtoll10-x86.s 2005-09-05 18:46:10.000000000 +0200
-@@ -416,3 +416,6 @@
- .comm end_ptr,120,32
- .comm error,120,32
- .ident "Monty"
-+
-+ .section .note.GNU-stack,"",@progbits
-+
-diff -Naur mysql.old/strings/strings-x86.s mysql.new/strings/strings-x86.s
---- mysql.old/strings/strings-x86.s 2005-08-27 22:33:36.000000000 +0200
-+++ mysql.new/strings/strings-x86.s 2005-09-05 18:46:22.000000000 +0200
-@@ -414,3 +414,6 @@
- ret
- .strxmov_end:
- .size strxmov,.strxmov_end-strxmov
-+
-+ .section .note.GNU-stack,"",@progbits
-+
diff --git a/00800_all_slot_script-4.0.patch b/00800_all_slot_script-4.0.patch
deleted file mode 100644
index 36b4f3d..0000000
--- a/00800_all_slot_script-4.0.patch
+++ /dev/null
@@ -1,646 +0,0 @@
-diff -Naur -Naur mysql-4.0.26/scripts/Makefile.am mysql-4.0.26.new/scripts/Makefile.am
---- mysql-4.0.26/scripts/Makefile.am 2005-09-02 22:38:04.000000000 +0000
-+++ mysql-4.0.26.new/scripts/Makefile.am 2005-12-06 15:30:25.000000000 +0000
-@@ -81,11 +81,41 @@
- mysql_find_rows \
- mysqlhotcopy \
- mysqldumpslow \
-+ mysql_explain_log \
-+ mysql_tableinfo \
- mysqld_multi \
- make_win_src_distribution
-
- SUPERCLEANFILES = mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
-+dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-+
- # We want the right version and configure comand line in mysqlbug
- mysqlbug: ${top_builddir}/config.status mysqlbug.sh
-
-@@ -93,8 +123,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur -Naur mysql-4.0.26/scripts/msql2mysql.sh mysql-4.0.26.new/scripts/msql2mysql.sh
---- mysql-4.0.26/scripts/msql2mysql.sh 2005-09-02 22:38:10.000000000 +0000
-+++ mysql-4.0.26.new/scripts/msql2mysql.sh 2005-12-06 15:26:25.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur -Naur mysql-4.0.26/scripts/mysql_config.sh mysql-4.0.26.new/scripts/mysql_config.sh
---- mysql-4.0.26/scripts/mysql_config.sh 2005-09-02 22:37:59.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysql_config.sh 2005-12-06 15:26:25.000000000 +0000
-@@ -69,7 +69,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-diff -Naur -Naur mysql-4.0.26/scripts/mysql_config.sh.orig mysql-4.0.26.new/scripts/mysql_config.sh.orig
---- mysql-4.0.26/scripts/mysql_config.sh.orig 1970-01-01 00:00:00.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysql_config.sh.orig 2005-09-02 22:37:59.000000000 +0000
-@@ -0,0 +1,152 @@
-+#!/bin/sh
-+# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-+#
-+# 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; either version 2 of the License, or
-+# (at your option) any later version.
-+#
-+# 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
-+
-+# This script reports various configuration settings that may be needed
-+# when using the MySQL client library.
-+
-+which ()
-+{
-+ IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
-+ for file
-+ do
-+ for dir in $PATH
-+ do
-+ if test -f $dir/$file
-+ then
-+ echo "$dir/$file"
-+ continue 2
-+ fi
-+ done
-+ echo "which: no $file in ($PATH)"
-+ exit 1
-+ done
-+ IFS="$save_ifs"
-+}
-+
-+#
-+# If we can find the given directory relatively to where mysql_config is
-+# we should use this instead of the incompiled one.
-+# This is to ensure that this script also works with the binary MySQL
-+# version
-+
-+fix_path ()
-+{
-+ var=$1
-+ shift
-+ for filename
-+ do
-+ path=$basedir/$filename
-+ if [ -d "$path" ] ;
-+ then
-+ eval "$var"=$path
-+ return
-+ fi
-+ done
-+}
-+
-+get_full_path ()
-+{
-+ case $1 in
-+ /*) echo "$1";;
-+ ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;;
-+ *) which $1 ;;
-+ esac
-+}
-+
-+me=`get_full_path $0`
-+
-+basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+
-+ldata='@localstatedir@'
-+execdir='@libexecdir@'
-+bindir='@bindir@'
-+pkglibdir='@pkglibdir@'
-+fix_path pkglibdir lib/mysql lib
-+pkgincludedir='@pkgincludedir@'
-+fix_path pkgincludedir include/mysql include
-+version='@VERSION@'
-+socket='@MYSQL_UNIX_ADDR@'
-+port='@MYSQL_TCP_PORT@'
-+ldflags='@LDFLAGS@'
-+client_libs='@CLIENT_LIBS@'
-+
-+# Create options
-+
-+libs="$ldflags -L$pkglibdir -lmysqlclient $client_libs"
-+libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@"
-+libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
-+include="-I$pkgincludedir"
-+embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@"
-+embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+
-+# Remove some options that a client doesn't have to care about
-+for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
-+ DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
-+ DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*'
-+do
-+ cflags=`echo "$cflags"|sed -e "s/-$remove *//g"`
-+done
-+cflags=`echo "$cflags"|sed -e 's/ *\$//'`
-+
-+usage () {
-+ cat <<EOF
-+Usage: $0 [OPTIONS]
-+Options:
-+ --cflags [$cflags]
-+ --include [$include]
-+ --libs [$libs]
-+ --libs_r [$libs_r]
-+ --socket [$socket]
-+ --port [$port]
-+ --version [$version]
-+ --libmysqld-libs [$embedded_libs]
-+EOF
-+ exit 1
-+}
-+
-+if test $# -le 0; then usage; fi
-+
-+while test $# -gt 0; do
-+ case $1 in
-+ --cflags) echo "$cflags" ;;
-+ --include) echo "$include" ;;
-+ --libs) echo "$libs" ;;
-+ --libs_r) echo "$libs_r" ;;
-+ --socket) echo "$socket" ;;
-+ --port) echo "$port" ;;
-+ --version) echo "$version" ;;
-+ --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
-+ *) usage ;;
-+ esac
-+
-+ shift
-+done
-+
-+#echo "ldata: '"$ldata"'"
-+#echo "execdir: '"$execdir"'"
-+#echo "bindir: '"$bindir"'"
-+#echo "pkglibdir: '"$pkglibdir"'"
-+#echo "pkgincludedir: '"$pkgincludedir"'"
-+#echo "version: '"$version"'"
-+#echo "socket: '"$socket"'"
-+#echo "port: '"$port"'"
-+#echo "ldflags: '"$ldflags"'"
-+#echo "client_libs: '"$client_libs"'"
-+
-+exit 0
-diff -Naur -Naur mysql-4.0.26/scripts/mysql_install_db.sh mysql-4.0.26.new/scripts/mysql_install_db.sh
---- mysql-4.0.26/scripts/mysql_install_db.sh 2005-09-02 22:38:00.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysql_install_db.sh 2005-12-06 15:37:24.000000000 +0000
-@@ -61,20 +61,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -95,10 +95,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
--if test -x "$basedir/libexec/mysqld"
-+if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
--elif test -x "$basedir/sbin/mysqld"
-+elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -107,13 +107,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -137,22 +137,22 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could not be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
- exit 1
- fi
-- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
-+ echo "WARNING: The host '$hostname' could not be looked up with @mybin_resolveip@."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -371,8 +371,8 @@
- fi
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -380,14 +380,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -407,13 +407,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$execdir/mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -422,6 +422,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur -Naur mysql-4.0.26/scripts/mysql_secure_installation.sh mysql-4.0.26.new/scripts/mysql_secure_installation.sh
---- mysql-4.0.26/scripts/mysql_secure_installation.sh 2005-09-02 22:37:55.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysql_secure_installation.sh 2005-12-06 15:26:49.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur -Naur mysql-4.0.26/scripts/mysqlaccess.sh mysql-4.0.26.new/scripts/mysqlaccess.sh
---- mysql-4.0.26/scripts/mysqlaccess.sh 2005-09-02 22:37:59.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysqlaccess.sh 2005-12-06 15:26:49.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur -Naur mysql-4.0.26/scripts/mysqld_multi.sh mysql-4.0.26.new/scripts/mysqld_multi.sh
---- mysql-4.0.26/scripts/mysqld_multi.sh 2005-09-02 22:38:07.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysqld_multi.sh 2005-12-06 15:41:13.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -37,11 +37,11 @@
- {
- my ($flag_exit);
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING! my_print_defaults command not found!\n";
-+ print "WARNING! @mybin_my_print_defaults@ command not found!\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -67,9 +67,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -102,9 +102,9 @@
- print "Error with an option, see $my_progname --help for more info!\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'!\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'!\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -149,7 +149,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -263,7 +263,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -574,8 +574,8 @@
- # give you extra performance in a threaded system!
- #
- [mysqld_multi]
--mysqld = @bindir@/mysqld_safe
--mysqladmin = @bindir@/mysqladmin
-+mysqld = @bindir@/@mybin_safe_mysqld@
-+mysqladmin = @bindir@/@mybin_mysqladmin@
- user = root
- password = your_password
-
-diff -Naur -Naur mysql-4.0.26/scripts/mysqld_safe.sh mysql-4.0.26.new/scripts/mysqld_safe.sh
---- mysql-4.0.26/scripts/mysqld_safe.sh 2005-09-02 22:37:59.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysqld_safe.sh 2005-12-06 15:43:55.000000000 +0000
-@@ -67,7 +67,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -87,7 +87,7 @@
- MY_PWD=`pwd`
- # Check if we are starting this relative (for the binary release)
- if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
-- -x ./bin/mysqld
-+ -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
-@@ -98,7 +98,7 @@
- fi
- # Check if this is a 'moved install directory'
- elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -113,11 +113,11 @@
- niceness=0
-
- # Use the mysqld-max binary by default if the user doesn't specify a binary
--if test -x $ledir/mysqld-max
-+if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
-
- # these rely on $DATADIR by default, so we'll set them later on
-@@ -126,17 +126,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -155,7 +155,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -284,12 +284,12 @@
- # checked and repaired during startup. You should add sensible key_buffer
- # and sort_buffer values to my.cnf to improve check performance or require
- # less disk space.
--# Alternatively, you can start mysqld with the "myisam-recover" option. See
-+# Alternatively, you can start @mybin_mysqld@ with the "myisam-recover" option. See
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-@@ -299,7 +299,7 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "`date +'%y%m%d %H:%M:%S @mybin_mysqld@ started'`" >> $err_log
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
-@@ -344,9 +344,9 @@
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "`date +'%y%m%d %H:%M:%S'` @mybin_mysqld@ restarted" | tee -a $err_log
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
-+echo "`date +'%y%m%d %H:%M:%S'` @mybin_mysqld@ ended" | tee -a $err_log
- echo "" | tee -a $err_log
-
-diff -Naur -Naur mysql-4.0.26/scripts/mysqldumpslow.sh mysql-4.0.26.new/scripts/mysqldumpslow.sh
---- mysql-4.0.26/scripts/mysqldumpslow.sh 2005-09-02 22:37:59.000000000 +0000
-+++ mysql-4.0.26.new/scripts/mysqldumpslow.sh 2005-12-06 15:26:49.000000000 +0000
-@@ -32,16 +32,16 @@
-
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -49,7 +49,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-4.1.16.patch b/00800_all_slot_script-4.1.16.patch
deleted file mode 100644
index 29abc58..0000000
--- a/00800_all_slot_script-4.1.16.patch
+++ /dev/null
@@ -1,532 +0,0 @@
-diff -Naur -Naur mysql-4.1.16.orig/scripts/Makefile.am mysql-4.1.16.new/scripts/Makefile.am
---- mysql-4.1.16.orig/scripts/Makefile.am 2005-11-30 20:36:23.000000000 +0000
-+++ mysql-4.1.16.new/scripts/Makefile.am 2006-01-14 18:32:53.000000000 +0000
-@@ -66,6 +66,32 @@
- mysqlaccess.conf \
- mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -100,8 +126,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur -Naur mysql-4.1.16.orig/scripts/msql2mysql.sh mysql-4.1.16.new/scripts/msql2mysql.sh
---- mysql-4.1.16.orig/scripts/msql2mysql.sh 2005-11-30 20:36:34.000000000 +0000
-+++ mysql-4.1.16.new/scripts/msql2mysql.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysql_config.sh mysql-4.1.16.new/scripts/mysql_config.sh
---- mysql-4.1.16.orig/scripts/mysql_config.sh 2005-11-30 20:36:06.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysql_config.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysql_create_system_tables.sh mysql-4.1.16.new/scripts/mysql_create_system_tables.sh
---- mysql-4.1.16.orig/scripts/mysql_create_system_tables.sh 2005-11-30 20:36:27.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysql_create_system_tables.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysql_fix_privilege_tables.sh mysql-4.1.16.new/scripts/mysql_fix_privilege_tables.sh
---- mysql-4.1.16.orig/scripts/mysql_fix_privilege_tables.sh 2005-11-30 20:36:32.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysql_fix_privilege_tables.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -76,17 +76,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$basedir"
-@@ -119,7 +119,7 @@
- password=$old_style_password
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -137,7 +137,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts @pkgdatadir@ . ./scripts
- do
- if test -f $i/$file
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysql_install_db.sh mysql-4.1.16.new/scripts/mysql_install_db.sh
---- mysql-4.1.16.orig/scripts/mysql_install_db.sh 2005-11-30 20:36:14.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysql_install_db.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -57,20 +57,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -94,10 +94,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -106,7 +106,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -123,13 +123,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -153,14 +153,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -168,7 +168,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -213,7 +213,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -243,8 +243,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -252,14 +252,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -279,13 +279,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -294,6 +294,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysql_secure_installation.sh mysql-4.1.16.new/scripts/mysql_secure_installation.sh
---- mysql-4.1.16.orig/scripts/mysql_secure_installation.sh 2005-11-30 20:36:34.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysql_secure_installation.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysqlaccess.sh mysql-4.1.16.new/scripts/mysqlaccess.sh
---- mysql-4.1.16.orig/scripts/mysqlaccess.sh 2005-11-30 20:36:05.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysqlaccess.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysqld_multi.sh mysql-4.1.16.new/scripts/mysqld_multi.sh
---- mysql-4.1.16.orig/scripts/mysqld_multi.sh 2005-11-30 20:36:28.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysqld_multi.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my ($flag_exit);
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING! my_print_defaults command not found!\n";
-+ print "WARNING! @mybin_my_print_defaults@ command not found!\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -69,9 +69,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -101,9 +101,9 @@
- print "Error with an option, see $my_progname --help for more info!\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'!\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'!\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -165,7 +165,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -266,7 +266,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -295,7 +295,7 @@
- $tmp.= " '$options[$j]'";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -366,7 +366,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysqld_safe.sh mysql-4.1.16.new/scripts/mysqld_safe.sh
---- mysql-4.1.16.orig/scripts/mysqld_safe.sh 2005-11-30 20:36:34.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysqld_safe.sh 2006-01-14 18:36:18.000000000 +0000
-@@ -68,7 +68,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -91,13 +91,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -137,17 +137,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -172,11 +172,11 @@
- # Use the mysqld-max binary by default if the user doesn't specify a binary
- if test -z "$MYSQLD"
- then
-- if test -x $ledir/mysqld-max
-+ if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
- fi
-
-@@ -185,7 +185,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -318,8 +318,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur -Naur mysql-4.1.16.orig/scripts/mysqldumpslow.sh mysql-4.1.16.new/scripts/mysqldumpslow.sh
---- mysql-4.1.16.orig/scripts/mysqldumpslow.sh 2005-11-30 20:36:35.000000000 +0000
-+++ mysql-4.1.16.new/scripts/mysqldumpslow.sh 2006-01-14 18:32:53.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-4.1.23.patch b/00800_all_slot_script-4.1.23.patch
deleted file mode 100644
index fbdb051..0000000
--- a/00800_all_slot_script-4.1.23.patch
+++ /dev/null
@@ -1,545 +0,0 @@
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/Makefile.am mysql-4.1.23-bk-20070101/scripts/Makefile.am
---- mysql-4.1.23-bk-20070101.orig/scripts/Makefile.am 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/Makefile.am 2007-01-03 00:14:16.000000000 +0100
-@@ -66,6 +66,32 @@
- mysqlaccess.conf \
- mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -100,8 +126,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/msql2mysql.sh mysql-4.1.23-bk-20070101/scripts/msql2mysql.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/msql2mysql.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/msql2mysql.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysql_config.sh mysql-4.1.23-bk-20070101/scripts/mysql_config.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysql_config.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysql_config.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysql_create_system_tables.sh mysql-4.1.23-bk-20070101/scripts/mysql_create_system_tables.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysql_create_system_tables.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysql_create_system_tables.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysql_fix_privilege_tables.sh mysql-4.1.23-bk-20070101/scripts/mysql_fix_privilege_tables.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysql_fix_privilege_tables.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysql_fix_privilege_tables.sh 2007-01-03 00:19:37.000000000 +0100
-@@ -76,17 +76,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$basedir"
-@@ -103,10 +103,10 @@
- then
- bindir="$basedir/bin"
- fi
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "@libexecdir@/mysqld"
-+ elif test -x "@libexecdir@/@mybin_mysqld@"
- then
- execdir="@libexecdir@"
- else
-@@ -119,7 +119,7 @@
- password=$old_style_password
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$port"; then
- cmd="$cmd --port=$port"
- fi
-@@ -134,7 +134,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts @pkgdatadir@ . ./scripts
- do
- if test -f $i/$file
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysql_install_db.sh mysql-4.1.23-bk-20070101/scripts/mysql_install_db.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysql_install_db.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysql_install_db.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -57,20 +57,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -94,10 +94,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -106,7 +106,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -123,13 +123,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -153,14 +153,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -168,7 +168,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -213,7 +213,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -243,8 +243,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -252,14 +252,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -279,13 +279,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -294,6 +294,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysql_secure_installation.sh mysql-4.1.23-bk-20070101/scripts/mysql_secure_installation.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysql_secure_installation.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysql_secure_installation.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysqlaccess.sh mysql-4.1.23-bk-20070101/scripts/mysqlaccess.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysqlaccess.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysqlaccess.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysqld_multi.sh mysql-4.1.23-bk-20070101/scripts/mysqld_multi.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysqld_multi.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysqld_multi.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my ($flag_exit);
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING! my_print_defaults command not found!\n";
-+ print "WARNING! @mybin_my_print_defaults@ command not found!\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -69,9 +69,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -101,9 +101,9 @@
- print "Error with an option, see $my_progname --help for more info!\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'!\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'!\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -165,7 +165,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -266,7 +266,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -295,7 +295,7 @@
- $tmp.= " '$options[$j]'";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -366,7 +366,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysqld_safe.sh mysql-4.1.23-bk-20070101/scripts/mysqld_safe.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysqld_safe.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysqld_safe.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -93,7 +93,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -119,13 +119,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -165,17 +165,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -200,11 +200,11 @@
- # Use the mysqld-max binary by default if the user doesn't specify a binary
- if test -z "$MYSQLD"
- then
-- if test -x $ledir/mysqld-max
-+ if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
- fi
-
-@@ -213,7 +213,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -346,8 +346,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur mysql-4.1.23-bk-20070101.orig/scripts/mysqldumpslow.sh mysql-4.1.23-bk-20070101/scripts/mysqldumpslow.sh
---- mysql-4.1.23-bk-20070101.orig/scripts/mysqldumpslow.sh 2007-01-01 20:44:41.000000000 +0100
-+++ mysql-4.1.23-bk-20070101/scripts/mysqldumpslow.sh 2007-01-03 00:14:16.000000000 +0100
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-5.0.17.patch b/00800_all_slot_script-5.0.17.patch
deleted file mode 100644
index ceb858a..0000000
--- a/00800_all_slot_script-5.0.17.patch
+++ /dev/null
@@ -1,542 +0,0 @@
-diff -Naur -Naur mysql-5.0.18.orig/scripts/Makefile.am mysql-5.0.18.new/scripts/Makefile.am
---- mysql-5.0.18.orig/scripts/Makefile.am 2005-12-21 19:39:51.000000000 +0000
-+++ mysql-5.0.18.new/scripts/Makefile.am 2006-01-15 12:22:57.000000000 +0000
-@@ -66,6 +66,32 @@
- mysqlaccess.conf \
- mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -100,8 +126,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur -Naur mysql-5.0.18.orig/scripts/msql2mysql.sh mysql-5.0.18.new/scripts/msql2mysql.sh
---- mysql-5.0.18.orig/scripts/msql2mysql.sh 2005-12-21 19:40:02.000000000 +0000
-+++ mysql-5.0.18.new/scripts/msql2mysql.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysql_config.sh mysql-5.0.18.new/scripts/mysql_config.sh
---- mysql-5.0.18.orig/scripts/mysql_config.sh 2005-12-21 19:39:36.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysql_config.sh 2006-01-15 12:43:37.000000000 +0000
-@@ -77,15 +77,15 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
- bindir='@bindir@'
- pkglibdir='@pkglibdir@'
--fix_path pkglibdir lib/mysql lib
-+fix_path pkglibdir "lib${pkglibdir##*lib}" lib/mysql lib
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
- port='@MYSQL_TCP_PORT@'
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysql_create_system_tables.sh mysql-5.0.18.new/scripts/mysql_create_system_tables.sh
---- mysql-5.0.18.orig/scripts/mysql_create_system_tables.sh 2005-12-21 19:39:52.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysql_create_system_tables.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysql_fix_privilege_tables.sh mysql-5.0.18.new/scripts/mysql_fix_privilege_tables.sh
---- mysql-5.0.18.orig/scripts/mysql_fix_privilege_tables.sh 2005-12-21 19:39:59.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysql_fix_privilege_tables.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -136,7 +136,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysql_install_db.sh mysql-5.0.18.new/scripts/mysql_install_db.sh
---- mysql-5.0.18.orig/scripts/mysql_install_db.sh 2005-12-21 19:39:42.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysql_install_db.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -57,20 +57,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -94,10 +94,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -106,7 +106,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -123,13 +123,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -153,14 +153,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -168,7 +168,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -213,7 +213,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -243,8 +243,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -252,14 +252,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -279,13 +279,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -294,6 +294,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysql_secure_installation.sh mysql-5.0.18.new/scripts/mysql_secure_installation.sh
---- mysql-5.0.18.orig/scripts/mysql_secure_installation.sh 2005-12-21 19:40:02.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysql_secure_installation.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysqlaccess.sh mysql-5.0.18.new/scripts/mysqlaccess.sh
---- mysql-5.0.18.orig/scripts/mysqlaccess.sh 2005-12-21 19:39:32.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysqlaccess.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysqld_multi.sh mysql-5.0.18.new/scripts/mysqld_multi.sh
---- mysql-5.0.18.orig/scripts/mysqld_multi.sh 2005-12-21 19:39:55.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysqld_multi.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysqld_safe.sh mysql-5.0.18.new/scripts/mysqld_safe.sh
---- mysql-5.0.18.orig/scripts/mysqld_safe.sh 2005-12-21 19:40:02.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysqld_safe.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -87,7 +87,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -113,13 +113,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -181,17 +181,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -216,11 +216,11 @@
- # Use the mysqld-max binary by default if the user doesn't specify a binary
- if test -z "$MYSQLD"
- then
-- if test -x $ledir/mysqld-max
-+ if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
- fi
-
-@@ -229,7 +229,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -362,8 +362,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur -Naur mysql-5.0.18.orig/scripts/mysqldumpslow.sh mysql-5.0.18.new/scripts/mysqldumpslow.sh
---- mysql-5.0.18.orig/scripts/mysqldumpslow.sh 2005-12-21 19:40:05.000000000 +0000
-+++ mysql-5.0.18.new/scripts/mysqldumpslow.sh 2006-01-15 12:22:57.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-5.0.21.patch b/00800_all_slot_script-5.0.21.patch
deleted file mode 100644
index 8122f6f..0000000
--- a/00800_all_slot_script-5.0.21.patch
+++ /dev/null
@@ -1,545 +0,0 @@
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/Makefile.am mysql-5.0.21-nightly-20060410.b/scripts/Makefile.am
---- mysql-5.0.21-nightly-20060410.a/scripts/Makefile.am 2006-04-10 04:02:46.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/Makefile.am 2006-04-12 16:16:09.000000000 +0000
-@@ -68,6 +68,32 @@
- mysqlaccess.conf \
- mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -103,8 +129,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/msql2mysql.sh mysql-5.0.21-nightly-20060410.b/scripts/msql2mysql.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/msql2mysql.sh 2006-04-10 04:02:50.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/msql2mysql.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysqlaccess.sh mysql-5.0.21-nightly-20060410.b/scripts/mysqlaccess.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysqlaccess.sh 2006-04-10 04:02:43.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysqlaccess.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysql_config.sh mysql-5.0.21-nightly-20060410.b/scripts/mysql_config.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysql_config.sh 2006-04-10 04:02:44.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysql_config.sh 2006-04-12 16:19:06.000000000 +0000
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -86,10 +86,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysql_create_system_tables.sh mysql-5.0.21-nightly-20060410.b/scripts/mysql_create_system_tables.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysql_create_system_tables.sh 2006-04-10 04:02:46.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysql_create_system_tables.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysqld_multi.sh mysql-5.0.21-nightly-20060410.b/scripts/mysqld_multi.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysqld_multi.sh 2006-04-10 04:02:48.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysqld_multi.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysqld_safe.sh mysql-5.0.21-nightly-20060410.b/scripts/mysqld_safe.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysqld_safe.sh 2006-04-10 04:02:50.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysqld_safe.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -87,7 +87,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -113,13 +113,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -181,17 +181,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -216,11 +216,11 @@
- # Use the mysqld-max binary by default if the user doesn't specify a binary
- if test -z "$MYSQLD"
- then
-- if test -x $ledir/mysqld-max
-+ if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
- fi
-
-@@ -229,7 +229,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -362,8 +362,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysqldumpslow.sh mysql-5.0.21-nightly-20060410.b/scripts/mysqldumpslow.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysqldumpslow.sh 2006-04-10 04:02:50.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysqldumpslow.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysql_fix_privilege_tables.sh mysql-5.0.21-nightly-20060410.b/scripts/mysql_fix_privilege_tables.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysql_fix_privilege_tables.sh 2006-04-10 04:02:49.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysql_fix_privilege_tables.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -136,7 +136,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysql_install_db.sh mysql-5.0.21-nightly-20060410.b/scripts/mysql_install_db.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysql_install_db.sh 2006-04-10 04:02:44.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysql_install_db.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -58,20 +58,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -95,10 +95,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -107,7 +107,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -124,13 +124,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -154,14 +154,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -169,7 +169,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -214,7 +214,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -244,8 +244,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -253,14 +253,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -280,13 +280,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -295,6 +295,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur mysql-5.0.21-nightly-20060410.a/scripts/mysql_secure_installation.sh mysql-5.0.21-nightly-20060410.b/scripts/mysql_secure_installation.sh
---- mysql-5.0.21-nightly-20060410.a/scripts/mysql_secure_installation.sh 2006-04-10 04:02:50.000000000 +0000
-+++ mysql-5.0.21-nightly-20060410.b/scripts/mysql_secure_installation.sh 2006-04-12 16:16:09.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
diff --git a/00800_all_slot_script-5.0.34.patch b/00800_all_slot_script-5.0.34.patch
deleted file mode 100644
index 65b41fd..0000000
--- a/00800_all_slot_script-5.0.34.patch
+++ /dev/null
@@ -1,2434 +0,0 @@
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/Makefile.am mysql-5.0.34-bk-20070101/scripts/Makefile.am
---- mysql-5.0.34-bk-20070101.orig/scripts/Makefile.am 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/Makefile.am 2007-01-03 00:48:04.000000000 +0100
-@@ -68,6 +68,32 @@
- mysqlbug \
- make_win_bin_dist
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -103,8 +129,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/Makefile.am.orig mysql-5.0.34-bk-20070101/scripts/Makefile.am.orig
---- mysql-5.0.34-bk-20070101.orig/scripts/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/Makefile.am.orig 2007-01-01 19:10:29.000000000 +0100
-@@ -0,0 +1,158 @@
-+# Copyright (C) 2000-2006 MySQL AB
-+#
-+# 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
-+
-+## Process this file with automake to create Makefile.in
-+
-+bin_SCRIPTS = @server_scripts@ \
-+ msql2mysql \
-+ mysql_config \
-+ mysql_fix_privilege_tables \
-+ mysql_fix_extensions \
-+ mysql_setpermission \
-+ mysql_secure_installation \
-+ mysql_zap \
-+ mysqlaccess \
-+ mysqlbug \
-+ mysql_convert_table_format \
-+ mysql_find_rows \
-+ mysqlhotcopy \
-+ mysqldumpslow \
-+ mysql_explain_log \
-+ mysql_tableinfo \
-+ mysql_upgrade_shell \
-+ mysqld_multi \
-+ mysql_create_system_tables
-+
-+noinst_SCRIPTS = make_binary_distribution \
-+ make_sharedlib_distribution \
-+ make_win_src_distribution
-+
-+EXTRA_SCRIPTS = make_binary_distribution.sh \
-+ make_sharedlib_distribution.sh \
-+ make_win_src_distribution.sh \
-+ msql2mysql.sh \
-+ mysql_config.sh \
-+ mysql_fix_privilege_tables.sh \
-+ mysql_fix_extensions.sh \
-+ mysql_install_db.sh \
-+ mysql_setpermission.sh \
-+ mysql_secure_installation.sh \
-+ mysql_zap.sh \
-+ mysqlaccess.sh \
-+ mysqlbug.sh \
-+ mysql_convert_table_format.sh \
-+ mysql_find_rows.sh \
-+ mysqlhotcopy.sh \
-+ mysqldumpslow.sh \
-+ mysql_explain_log.sh \
-+ mysqld_multi.sh \
-+ mysql_tableinfo.sh \
-+ mysql_upgrade_shell.sh \
-+ mysqld_safe.sh \
-+ mysql_create_system_tables.sh
-+
-+EXTRA_DIST = $(EXTRA_SCRIPTS) \
-+ mysqlaccess.conf \
-+ mysqlbug \
-+ make_win_bin_dist
-+
-+dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-+
-+# mysqlbug should be distributed built so that people can report build
-+# failures with it.
-+CLEANFILES = @server_scripts@ \
-+ make_binary_distribution \
-+ make_sharedlib_distribution \
-+ msql2mysql \
-+ mysql_config \
-+ mysql_fix_privilege_tables \
-+ mysql_fix_extensions \
-+ mysql_setpermission \
-+ mysql_secure_installation \
-+ mysql_zap \
-+ mysqlaccess \
-+ mysql_convert_table_format \
-+ mysql_find_rows \
-+ mysqlhotcopy \
-+ mysqldumpslow \
-+ mysql_explain_log \
-+ mysql_tableinfo \
-+ mysql_upgrade_shell \
-+ mysqld_multi \
-+ make_win_src_distribution \
-+ mysql_create_system_tables
-+
-+DISTCLEANFILES = mysqlbug
-+
-+# We want the right version and configure comand line in mysqlbug
-+mysqlbug: ${top_builddir}/config.status mysqlbug.sh
-+
-+SUFFIXES = .sh
-+
-+.sh:
-+ @RM@ -f $@ $@-t
-+ @SED@ \
-+ -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sbindir''@!$(sbindir)!g' \
-+ -e 's!@''scriptdir''@!$(bindir)!g' \
-+ -e 's!@''prefix''@!$(prefix)!g' \
-+ -e 's!@''datadir''@!$(datadir)!g' \
-+ -e 's!@''localstatedir''@!$(localstatedir)!g' \
-+ -e 's!@''libexecdir''@!$(libexecdir)!g' \
-+ -e 's!@''pkglibdir''@!$(pkglibdir)!g' \
-+ -e 's!@''pkgincludedir''@!$(pkgincludedir)!g' \
-+ -e 's!@''pkgdatadir''@!$(pkgdatadir)!g' \
-+ -e 's!@''sysconfdir''@!$(sysconfdir)!g' \
-+ -e 's!@''CC''@!@CC@!'\
-+ -e 's!@''CXX''@!@CXX@!'\
-+ -e 's!@''GXX''@!@GXX@!'\
-+ -e 's!@''CC_VERSION''@!@CC_VERSION@!'\
-+ -e 's!@''CXX_VERSION''@!@CXX_VERSION@!'\
-+ -e 's!@''PERL''@!@PERL@!' \
-+ -e 's!@''ASFLAGS''@!@SAVE_ASFLAGS@!'\
-+ -e 's!@''CFLAGS''@!@SAVE_CFLAGS@!'\
-+ -e 's!@''CXXFLAGS''@!@SAVE_CXXFLAGS@!'\
-+ -e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\
-+ -e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \
-+ -e 's!@''ZLIB_LIBS''@!@ZLIB_LIBS@!' \
-+ -e 's!@''LIBS''@!@LIBS@!' \
-+ -e 's!@''WRAPLIBS''@!@WRAPLIBS@!' \
-+ -e 's!@''innodb_system_libs''@!@innodb_system_libs@!' \
-+ -e 's!@''openssl_libs''@!@openssl_libs@!' \
-+ -e 's!@''VERSION''@!@VERSION@!' \
-+ -e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
-+ -e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
-+ -e 's!@''COMPILATION_COMMENT''@!@COMPILATION_COMMENT@!' \
-+ -e 's!@''MACHINE_TYPE''@!@MACHINE_TYPE@!' \
-+ -e 's!@''HOSTNAME''@!@HOSTNAME@!' \
-+ -e 's!@''SYSTEM_TYPE''@!@SYSTEM_TYPE@!' \
-+ -e 's!@''CHECK_PID''@!@CHECK_PID@!' \
-+ -e 's!@''FIND_PROC''@!@FIND_PROC@!' \
-+ -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \
-+ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-+ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-+ -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
-+ -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
-+ -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
-+ -e 's!@''STATIC_NSS_FLAGS''@!@STATIC_NSS_FLAGS@!' \
-+ -e 's!@''NON_THREADED_LIBS''@!@NON_THREADED_LIBS@!' \
-+ -e 's!@''ZLIB_DEPS''@!@ZLIB_DEPS@!' \
-+ -e "s!@MAKE@!$(MAKE)!" \
-+ $< > $@-t
-+ @CHMOD@ +x $@-t
-+ @MV@ $@-t $@
-+
-+# Don't update the files from bitkeeper
-+%::SCCS/s.%
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/msql2mysql.sh mysql-5.0.34-bk-20070101/scripts/msql2mysql.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/msql2mysql.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/msql2mysql.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_config.sh mysql-5.0.34-bk-20070101/scripts/mysql_config.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_config.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_config.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -76,7 +76,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -85,10 +85,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_config.sh.orig mysql-5.0.34-bk-20070101/scripts/mysql_config.sh.orig
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_config.sh.orig 1970-01-01 01:00:00.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_config.sh.orig 2007-01-01 19:10:29.000000000 +0100
-@@ -0,0 +1,182 @@
-+#!/bin/sh
-+# Copyright (C) 2000-2006 MySQL AB
-+#
-+# 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
-+
-+# This script reports various configuration settings that may be needed
-+# when using the MySQL client library.
-+
-+which ()
-+{
-+ IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
-+ for file
-+ do
-+ for dir in $PATH
-+ do
-+ if test -f $dir/$file
-+ then
-+ echo "$dir/$file"
-+ continue 2
-+ fi
-+ done
-+ echo "which: no $file in ($PATH)"
-+ exit 1
-+ done
-+ IFS="$save_ifs"
-+}
-+
-+#
-+# If we can find the given directory relatively to where mysql_config is
-+# we should use this instead of the incompiled one.
-+# This is to ensure that this script also works with the binary MySQL
-+# version
-+
-+fix_path ()
-+{
-+ var=$1
-+ shift
-+ for filename
-+ do
-+ path=$basedir/$filename
-+ if [ -d "$path" ] ;
-+ then
-+ eval "$var"=$path
-+ return
-+ fi
-+ done
-+}
-+
-+get_full_path ()
-+{
-+ file=$1
-+
-+ # if the file is a symlink, try to resolve it
-+ if [ -h $file ];
-+ then
-+ file=`ls -l $file | awk '{ print $NF }'`
-+ fi
-+
-+ case $file in
-+ /*) echo "$file";;
-+ */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
-+ *) which $file ;;
-+ esac
-+}
-+
-+me=`get_full_path $0`
-+
-+basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+
-+ldata='@localstatedir@'
-+execdir='@libexecdir@'
-+bindir='@bindir@'
-+
-+# If installed, search for the compiled in directory first (might be "lib64")
-+pkglibdir='@pkglibdir@'
-+pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
-+fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+
-+pkgincludedir='@pkgincludedir@'
-+fix_path pkgincludedir include/mysql include
-+
-+version='@VERSION@'
-+socket='@MYSQL_UNIX_ADDR@'
-+port='@MYSQL_TCP_PORT@'
-+ldflags='@LDFLAGS@'
-+
-+# Create options
-+# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
-+libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
-+libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
-+libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ "
-+embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ "
-+
-+cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
-+include="-I$pkgincludedir"
-+
-+# Remove some options that a client doesn't have to care about
-+# FIXME until we have a --cxxflags, we need to remove -Xa
-+# and -xstrconst to make --cflags usable for Sun Forte C++
-+for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
-+ DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
-+ DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
-+ Xa xstrconst "xc99=none" \
-+ unroll2 ip mp restrict
-+do
-+ # The first option we might strip will always have a space before it because
-+ # we set -I$pkgincludedir as the first option
-+ cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
-+done
-+cflags=`echo "$cflags"|sed -e 's/ *\$//'`
-+
-+# Same for --libs(_r)
-+for remove in lmtmalloc static-libcxa i-static
-+do
-+ # We know the strings starts with a space
-+ libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
-+ libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
-+ embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
-+done
-+
-+# Strip trailing and ending space if any, and '+' (FIXME why?)
-+libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-+
-+usage () {
-+ cat <<EOF
-+Usage: $0 [OPTIONS]
-+Options:
-+ --cflags [$cflags]
-+ --include [$include]
-+ --libs [$libs]
-+ --libs_r [$libs_r]
-+ --socket [$socket]
-+ --port [$port]
-+ --version [$version]
-+ --libmysqld-libs [$embedded_libs]
-+EOF
-+ exit 1
-+}
-+
-+if test $# -le 0; then usage; fi
-+
-+while test $# -gt 0; do
-+ case $1 in
-+ --cflags) echo "$cflags" ;;
-+ --include) echo "$include" ;;
-+ --libs) echo "$libs" ;;
-+ --libs_r) echo "$libs_r" ;;
-+ --socket) echo "$socket" ;;
-+ --port) echo "$port" ;;
-+ --version) echo "$version" ;;
-+ --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
-+ *) usage ;;
-+ esac
-+
-+ shift
-+done
-+
-+#echo "ldata: '"$ldata"'"
-+#echo "execdir: '"$execdir"'"
-+#echo "bindir: '"$bindir"'"
-+#echo "pkglibdir: '"$pkglibdir"'"
-+#echo "pkgincludedir: '"$pkgincludedir"'"
-+#echo "version: '"$version"'"
-+#echo "socket: '"$socket"'"
-+#echo "port: '"$port"'"
-+#echo "ldflags: '"$ldflags"'"
-+#echo "client_libs: '"$client_libs"'"
-+
-+exit 0
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_create_system_tables.sh mysql-5.0.34-bk-20070101/scripts/mysql_create_system_tables.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_create_system_tables.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_create_system_tables.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -31,7 +31,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_create_system_tables.sh.orig mysql-5.0.34-bk-20070101/scripts/mysql_create_system_tables.sh.orig
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_create_system_tables.sh.orig 1970-01-01 01:00:00.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_create_system_tables.sh.orig 2007-01-01 19:10:29.000000000 +0100
-@@ -0,0 +1,779 @@
-+#!/bin/sh
-+# Copyright (C) 1997-2003 MySQL AB
-+#
-+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-+
-+# This script writes on stdout SQL commands to generate all not
-+# existing MySQL system tables. It also replaces the help tables with
-+# new context from the manual (from fill_help_tables.sql).
-+
-+# $1 - "test" or "real" or "verbose" variant of database
-+# $2 - path to mysql-database directory
-+# $3 - hostname
-+# $4 - windows option
-+
-+if test "$1" = ""
-+then
-+ echo "
-+This script writes on stdout SQL commands to generate all not
-+existing MySQL system tables. It also replaces the help tables with
-+new context from the manual (from fill_help_tables.sql).
-+
-+Usage:
-+ mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+"
-+ exit
-+fi
-+
-+mdata=$2
-+hostname=$3
-+windows=$4
-+
-+# Initialize variables
-+c_d="" i_d=""
-+c_h="" i_h=""
-+c_u="" i_u=""
-+c_f="" i_f=""
-+c_t="" c_c=""
-+c_ht=""
-+c_hc=""
-+c_hr=""
-+c_hk=""
-+i_ht=""
-+c_tzn="" c_tz="" c_tzt="" c_tztt="" c_tzls=""
-+i_tzn="" i_tz="" i_tzt="" i_tztt="" i_tzls=""
-+c_p="" c_pp=""
-+
-+# Check for old tables
-+if test ! -f $mdata/db.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing db table" 1>&2;
-+ fi
-+
-+ # mysqld --bootstrap wants one command/line
-+ c_d="$c_d CREATE TABLE db ("
-+ c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
-+ c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
-+ c_d="$c_d Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
-+ c_d="$c_d KEY User (User)"
-+ c_d="$c_d ) engine=MyISAM"
-+ c_d="$c_d CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_d="$c_d comment='Database privileges';"
-+
-+ i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
-+ INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');"
-+fi
-+
-+if test ! -f $mdata/host.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing host table" 1>&2;
-+ fi
-+
-+ c_h="$c_h CREATE TABLE host ("
-+ c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
-+ c_h="$c_h Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_h="$c_h PRIMARY KEY Host (Host,Db)"
-+ c_h="$c_h ) engine=MyISAM"
-+ c_h="$c_h CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_h="$c_h comment='Host privileges; Merged with database privileges';"
-+fi
-+
-+if test ! -f $mdata/user.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing user table" 1>&2;
-+ fi
-+
-+ c_u="$c_u CREATE TABLE user ("
-+ c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
-+ c_u="$c_u Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL,"
-+ c_u="$c_u Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
-+ c_u="$c_u ssl_cipher BLOB NOT NULL,"
-+ c_u="$c_u x509_issuer BLOB NOT NULL,"
-+ c_u="$c_u x509_subject BLOB NOT NULL,"
-+ c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL,"
-+ c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL,"
-+ c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL,"
-+ c_u="$c_u max_user_connections int(11) unsigned DEFAULT 0 NOT NULL,"
-+ c_u="$c_u PRIMARY KEY Host (Host,User)"
-+ c_u="$c_u ) engine=MyISAM"
-+ c_u="$c_u CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_u="$c_u comment='Users and global privileges';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
-+ INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
-+ REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
-+ INSERT INTO user (host,user) values ('localhost','');
-+ INSERT INTO user (host,user) values ('$hostname','');"
-+ else
-+ i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);"
-+ if test "$windows" = "0"
-+ then
-+ i_u="$i_u
-+ INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
-+ INSERT INTO user (host,user) values ('$hostname','');
-+ INSERT INTO user (host,user) values ('localhost','');"
-+ else
-+ i_u="$i_u
-+ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);"
-+ fi
-+ fi
-+fi
-+
-+if test ! -f $mdata/func.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing func table" 1>&2;
-+ fi
-+
-+ c_f="$c_f CREATE TABLE func ("
-+ c_f="$c_f name char(64) binary DEFAULT '' NOT NULL,"
-+ c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
-+ c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
-+ c_f="$c_f type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL,"
-+ c_f="$c_f PRIMARY KEY (name)"
-+ c_f="$c_f ) engine=MyISAM"
-+ c_f="$c_f CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_f="$c_f comment='User defined functions';"
-+fi
-+
-+if test ! -f $mdata/tables_priv.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing tables_priv table" 1>&2;
-+ fi
-+
-+ c_t="$c_t CREATE TABLE tables_priv ("
-+ c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
-+ c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
-+ c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
-+ c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
-+ c_t="$c_t Timestamp timestamp(14),"
-+ c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
-+ c_t="$c_t Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
-+ c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
-+ c_t="$c_t KEY Grantor (Grantor)"
-+ c_t="$c_t ) engine=MyISAM"
-+ c_t="$c_t CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_t="$c_t comment='Table privileges';"
-+fi
-+
-+if test ! -f $mdata/columns_priv.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing columns_priv table" 1>&2;
-+ fi
-+
-+ c_c="$c_c CREATE TABLE columns_priv ("
-+ c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL,"
-+ c_c="$c_c User char(16) binary DEFAULT '' NOT NULL,"
-+ c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
-+ c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
-+ c_c="$c_c Timestamp timestamp(14),"
-+ c_c="$c_c Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
-+ c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
-+ c_c="$c_c ) engine=MyISAM"
-+ c_c="$c_c CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_c="$c_c comment='Column privileges';"
-+fi
-+
-+if test ! -f $mdata/procs_priv.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing procs_priv table" 1>&2;
-+ fi
-+
-+ c_pp="$c_pp CREATE TABLE procs_priv ("
-+ c_pp="$c_pp Host char(60) binary DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp Db char(64) binary DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp User char(16) binary DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp Routine_name char(64) binary DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp Routine_type enum('FUNCTION','PROCEDURE') NOT NULL,"
-+ c_pp="$c_pp Grantor char(77) DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
-+ c_pp="$c_pp Timestamp timestamp(14),"
-+ c_pp="$c_pp PRIMARY KEY (Host,Db,User,Routine_name,Routine_type),"
-+ c_pp="$c_pp KEY Grantor (Grantor)"
-+ c_pp="$c_pp ) engine=MyISAM"
-+ c_pp="$c_pp CHARACTER SET utf8 COLLATE utf8_bin"
-+ c_pp="$c_pp comment='Procedure privileges';"
-+fi
-+
-+if test ! -f $mdata/help_topic.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing help_topic table" 1>&2;
-+ fi
-+
-+ c_ht="$c_ht CREATE TABLE help_topic ("
-+ c_ht="$c_ht help_topic_id int unsigned not null,"
-+ c_ht="$c_ht name char(64) not null,"
-+ c_ht="$c_ht help_category_id smallint unsigned not null,"
-+ c_ht="$c_ht description text not null,"
-+ c_ht="$c_ht example text not null,"
-+ c_ht="$c_ht url char(128) not null,"
-+ c_ht="$c_ht primary key (help_topic_id),"
-+ c_ht="$c_ht unique index (name)"
-+ c_ht="$c_ht ) engine=MyISAM"
-+ c_ht="$c_ht CHARACTER SET utf8"
-+ c_ht="$c_ht comment='help topics';"
-+fi
-+
-+old_categories="yes"
-+
-+if test ! -f $mdata/help_category.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing help_category table" 1>&2;
-+ fi
-+
-+ c_hc="$c_hc CREATE TABLE help_category ("
-+ c_hc="$c_hc help_category_id smallint unsigned not null,"
-+ c_hc="$c_hc name char(64) not null,"
-+ c_hc="$c_hc parent_category_id smallint unsigned null,"
-+ c_hc="$c_hc url char(128) not null,"
-+ c_hc="$c_hc primary key (help_category_id),"
-+ c_hc="$c_hc unique index (name)"
-+ c_hc="$c_hc ) engine=MyISAM"
-+ c_hc="$c_hc CHARACTER SET utf8"
-+ c_hc="$c_hc comment='help categories';"
-+fi
-+
-+if test ! -f $mdata/help_keyword.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing help_keyword table" 1>&2;
-+ fi
-+
-+ c_hk="$c_hk CREATE TABLE help_keyword ("
-+ c_hk="$c_hk help_keyword_id int unsigned not null,"
-+ c_hk="$c_hk name char(64) not null,"
-+ c_hk="$c_hk primary key (help_keyword_id),"
-+ c_hk="$c_hk unique index (name)"
-+ c_hk="$c_hk ) engine=MyISAM"
-+ c_hk="$c_hk CHARACTER SET utf8"
-+ c_hk="$c_hk comment='help keywords';"
-+fi
-+
-+if test ! -f $mdata/help_relation.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing help_relation table" 1>&2;
-+ fi
-+
-+ c_hr="$c_hr CREATE TABLE help_relation ("
-+ c_hr="$c_hr help_topic_id int unsigned not null references help_topic,"
-+ c_hr="$c_hr help_keyword_id int unsigned not null references help_keyword,"
-+ c_hr="$c_hr primary key (help_keyword_id, help_topic_id)"
-+ c_hr="$c_hr ) engine=MyISAM"
-+ c_hr="$c_hr CHARACTER SET utf8"
-+ c_hr="$c_hr comment='keyword-topic relation';"
-+fi
-+
-+if test ! -f $mdata/time_zone_name.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing time_zone_name table" 1>&2;
-+ fi
-+
-+ c_tzn="$c_tzn CREATE TABLE time_zone_name ("
-+ c_tzn="$c_tzn Name char(64) NOT NULL,"
-+ c_tzn="$c_tzn Time_zone_id int unsigned NOT NULL,"
-+ c_tzn="$c_tzn PRIMARY KEY Name (Name)"
-+ c_tzn="$c_tzn ) engine=MyISAM CHARACTER SET utf8"
-+ c_tzn="$c_tzn comment='Time zone names';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_tzn="$i_tzn INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES"
-+ i_tzn="$i_tzn ('MET', 1), ('UTC', 2), ('Universal', 2), "
-+ i_tzn="$i_tzn ('Europe/Moscow',3), ('leap/Europe/Moscow',4), "
-+ i_tzn="$i_tzn ('Japan', 5);"
-+ fi
-+fi
-+
-+if test ! -f $mdata/time_zone.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing time_zone table" 1>&2;
-+ fi
-+
-+ c_tz="$c_tz CREATE TABLE time_zone ("
-+ c_tz="$c_tz Time_zone_id int unsigned NOT NULL auto_increment,"
-+ c_tz="$c_tz Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
-+ c_tz="$c_tz PRIMARY KEY TzId (Time_zone_id)"
-+ c_tz="$c_tz ) engine=MyISAM CHARACTER SET utf8"
-+ c_tz="$c_tz comment='Time zones';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_tz="$i_tz INSERT INTO time_zone (Time_zone_id, Use_leap_seconds)"
-+ i_tz="$i_tz VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N');"
-+ fi
-+fi
-+
-+if test ! -f $mdata/time_zone_transition.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing time_zone_transition table" 1>&2;
-+ fi
-+
-+ c_tzt="$c_tzt CREATE TABLE time_zone_transition ("
-+ c_tzt="$c_tzt Time_zone_id int unsigned NOT NULL,"
-+ c_tzt="$c_tzt Transition_time bigint signed NOT NULL,"
-+ c_tzt="$c_tzt Transition_type_id int unsigned NOT NULL,"
-+ c_tzt="$c_tzt PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time)"
-+ c_tzt="$c_tzt ) engine=MyISAM CHARACTER SET utf8"
-+ c_tzt="$c_tzt comment='Time zone transitions';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_tzt="$i_tzt INSERT INTO time_zone_transition"
-+ i_tzt="$i_tzt (Time_zone_id, Transition_time, Transition_type_id)"
-+ i_tzt="$i_tzt VALUES"
-+ i_tzt="$i_tzt (1, -1693706400, 0) ,(1, -1680483600, 1)"
-+ i_tzt="$i_tzt ,(1, -1663455600, 2) ,(1, -1650150000, 3)"
-+ i_tzt="$i_tzt ,(1, -1632006000, 2) ,(1, -1618700400, 3)"
-+ i_tzt="$i_tzt ,(1, -938905200, 2) ,(1, -857257200, 3)"
-+ i_tzt="$i_tzt ,(1, -844556400, 2) ,(1, -828226800, 3)"
-+ i_tzt="$i_tzt ,(1, -812502000, 2) ,(1, -796777200, 3)"
-+ i_tzt="$i_tzt ,(1, 228877200, 2) ,(1, 243997200, 3)"
-+ i_tzt="$i_tzt ,(1, 260326800, 2) ,(1, 276051600, 3)"
-+ i_tzt="$i_tzt ,(1, 291776400, 2) ,(1, 307501200, 3)"
-+ i_tzt="$i_tzt ,(1, 323830800, 2) ,(1, 338950800, 3)"
-+ i_tzt="$i_tzt ,(1, 354675600, 2) ,(1, 370400400, 3)"
-+ i_tzt="$i_tzt ,(1, 386125200, 2) ,(1, 401850000, 3)"
-+ i_tzt="$i_tzt ,(1, 417574800, 2) ,(1, 433299600, 3)"
-+ i_tzt="$i_tzt ,(1, 449024400, 2) ,(1, 465354000, 3)"
-+ i_tzt="$i_tzt ,(1, 481078800, 2) ,(1, 496803600, 3)"
-+ i_tzt="$i_tzt ,(1, 512528400, 2) ,(1, 528253200, 3)"
-+ i_tzt="$i_tzt ,(1, 543978000, 2) ,(1, 559702800, 3)"
-+ i_tzt="$i_tzt ,(1, 575427600, 2) ,(1, 591152400, 3)"
-+ i_tzt="$i_tzt ,(1, 606877200, 2) ,(1, 622602000, 3)"
-+ i_tzt="$i_tzt ,(1, 638326800, 2) ,(1, 654656400, 3)"
-+ i_tzt="$i_tzt ,(1, 670381200, 2) ,(1, 686106000, 3)"
-+ i_tzt="$i_tzt ,(1, 701830800, 2) ,(1, 717555600, 3)"
-+ i_tzt="$i_tzt ,(1, 733280400, 2) ,(1, 749005200, 3)"
-+ i_tzt="$i_tzt ,(1, 764730000, 2) ,(1, 780454800, 3)"
-+ i_tzt="$i_tzt ,(1, 796179600, 2) ,(1, 811904400, 3)"
-+ i_tzt="$i_tzt ,(1, 828234000, 2) ,(1, 846378000, 3)"
-+ i_tzt="$i_tzt ,(1, 859683600, 2) ,(1, 877827600, 3)"
-+ i_tzt="$i_tzt ,(1, 891133200, 2) ,(1, 909277200, 3)"
-+ i_tzt="$i_tzt ,(1, 922582800, 2) ,(1, 941331600, 3)"
-+ i_tzt="$i_tzt ,(1, 954032400, 2) ,(1, 972781200, 3)"
-+ i_tzt="$i_tzt ,(1, 985482000, 2) ,(1, 1004230800, 3)"
-+ i_tzt="$i_tzt ,(1, 1017536400, 2) ,(1, 1035680400, 3)"
-+ i_tzt="$i_tzt ,(1, 1048986000, 2) ,(1, 1067130000, 3)"
-+ i_tzt="$i_tzt ,(1, 1080435600, 2) ,(1, 1099184400, 3)"
-+ i_tzt="$i_tzt ,(1, 1111885200, 2) ,(1, 1130634000, 3)"
-+ i_tzt="$i_tzt ,(1, 1143334800, 2) ,(1, 1162083600, 3)"
-+ i_tzt="$i_tzt ,(1, 1174784400, 2) ,(1, 1193533200, 3)"
-+ i_tzt="$i_tzt ,(1, 1206838800, 2) ,(1, 1224982800, 3)"
-+ i_tzt="$i_tzt ,(1, 1238288400, 2) ,(1, 1256432400, 3)"
-+ i_tzt="$i_tzt ,(1, 1269738000, 2) ,(1, 1288486800, 3)"
-+ i_tzt="$i_tzt ,(1, 1301187600, 2) ,(1, 1319936400, 3)"
-+ i_tzt="$i_tzt ,(1, 1332637200, 2) ,(1, 1351386000, 3)"
-+ i_tzt="$i_tzt ,(1, 1364691600, 2) ,(1, 1382835600, 3)"
-+ i_tzt="$i_tzt ,(1, 1396141200, 2) ,(1, 1414285200, 3)"
-+ i_tzt="$i_tzt ,(1, 1427590800, 2) ,(1, 1445734800, 3)"
-+ i_tzt="$i_tzt ,(1, 1459040400, 2) ,(1, 1477789200, 3)"
-+ i_tzt="$i_tzt ,(1, 1490490000, 2) ,(1, 1509238800, 3)"
-+ i_tzt="$i_tzt ,(1, 1521939600, 2) ,(1, 1540688400, 3)"
-+ i_tzt="$i_tzt ,(1, 1553994000, 2) ,(1, 1572138000, 3)"
-+ i_tzt="$i_tzt ,(1, 1585443600, 2) ,(1, 1603587600, 3)"
-+ i_tzt="$i_tzt ,(1, 1616893200, 2) ,(1, 1635642000, 3)"
-+ i_tzt="$i_tzt ,(1, 1648342800, 2) ,(1, 1667091600, 3)"
-+ i_tzt="$i_tzt ,(1, 1679792400, 2) ,(1, 1698541200, 3)"
-+ i_tzt="$i_tzt ,(1, 1711846800, 2) ,(1, 1729990800, 3)"
-+ i_tzt="$i_tzt ,(1, 1743296400, 2) ,(1, 1761440400, 3)"
-+ i_tzt="$i_tzt ,(1, 1774746000, 2) ,(1, 1792890000, 3)"
-+ i_tzt="$i_tzt ,(1, 1806195600, 2) ,(1, 1824944400, 3)"
-+ i_tzt="$i_tzt ,(1, 1837645200, 2) ,(1, 1856394000, 3)"
-+ i_tzt="$i_tzt ,(1, 1869094800, 2) ,(1, 1887843600, 3)"
-+ i_tzt="$i_tzt ,(1, 1901149200, 2) ,(1, 1919293200, 3)"
-+ i_tzt="$i_tzt ,(1, 1932598800, 2) ,(1, 1950742800, 3)"
-+ i_tzt="$i_tzt ,(1, 1964048400, 2) ,(1, 1982797200, 3)"
-+ i_tzt="$i_tzt ,(1, 1995498000, 2) ,(1, 2014246800, 3)"
-+ i_tzt="$i_tzt ,(1, 2026947600, 2) ,(1, 2045696400, 3)"
-+ i_tzt="$i_tzt ,(1, 2058397200, 2) ,(1, 2077146000, 3)"
-+ i_tzt="$i_tzt ,(1, 2090451600, 2) ,(1, 2108595600, 3)"
-+ i_tzt="$i_tzt ,(1, 2121901200, 2) ,(1, 2140045200, 3)"
-+ i_tzt="$i_tzt ,(3, -1688265000, 2) ,(3, -1656819048, 1)"
-+ i_tzt="$i_tzt ,(3, -1641353448, 2) ,(3, -1627965048, 3)"
-+ i_tzt="$i_tzt ,(3, -1618716648, 1) ,(3, -1596429048, 3)"
-+ i_tzt="$i_tzt ,(3, -1593829848, 5) ,(3, -1589860800, 4)"
-+ i_tzt="$i_tzt ,(3, -1542427200, 5) ,(3, -1539493200, 6)"
-+ i_tzt="$i_tzt ,(3, -1525323600, 5) ,(3, -1522728000, 4)"
-+ i_tzt="$i_tzt ,(3, -1491188400, 7) ,(3, -1247536800, 4)"
-+ i_tzt="$i_tzt ,(3, 354920400, 5) ,(3, 370728000, 4)"
-+ i_tzt="$i_tzt ,(3, 386456400, 5) ,(3, 402264000, 4)"
-+ i_tzt="$i_tzt ,(3, 417992400, 5) ,(3, 433800000, 4)"
-+ i_tzt="$i_tzt ,(3, 449614800, 5) ,(3, 465346800, 8)"
-+ i_tzt="$i_tzt ,(3, 481071600, 9) ,(3, 496796400, 8)"
-+ i_tzt="$i_tzt ,(3, 512521200, 9) ,(3, 528246000, 8)"
-+ i_tzt="$i_tzt ,(3, 543970800, 9) ,(3, 559695600, 8)"
-+ i_tzt="$i_tzt ,(3, 575420400, 9) ,(3, 591145200, 8)"
-+ i_tzt="$i_tzt ,(3, 606870000, 9) ,(3, 622594800, 8)"
-+ i_tzt="$i_tzt ,(3, 638319600, 9) ,(3, 654649200, 8)"
-+ i_tzt="$i_tzt ,(3, 670374000, 10) ,(3, 686102400, 11)"
-+ i_tzt="$i_tzt ,(3, 695779200, 8) ,(3, 701812800, 5)"
-+ i_tzt="$i_tzt ,(3, 717534000, 4) ,(3, 733273200, 9)"
-+ i_tzt="$i_tzt ,(3, 748998000, 8) ,(3, 764722800, 9)"
-+ i_tzt="$i_tzt ,(3, 780447600, 8) ,(3, 796172400, 9)"
-+ i_tzt="$i_tzt ,(3, 811897200, 8) ,(3, 828226800, 9)"
-+ i_tzt="$i_tzt ,(3, 846370800, 8) ,(3, 859676400, 9)"
-+ i_tzt="$i_tzt ,(3, 877820400, 8) ,(3, 891126000, 9)"
-+ i_tzt="$i_tzt ,(3, 909270000, 8) ,(3, 922575600, 9)"
-+ i_tzt="$i_tzt ,(3, 941324400, 8) ,(3, 954025200, 9)"
-+ i_tzt="$i_tzt ,(3, 972774000, 8) ,(3, 985474800, 9)"
-+ i_tzt="$i_tzt ,(3, 1004223600, 8) ,(3, 1017529200, 9)"
-+ i_tzt="$i_tzt ,(3, 1035673200, 8) ,(3, 1048978800, 9)"
-+ i_tzt="$i_tzt ,(3, 1067122800, 8) ,(3, 1080428400, 9)"
-+ i_tzt="$i_tzt ,(3, 1099177200, 8) ,(3, 1111878000, 9)"
-+ i_tzt="$i_tzt ,(3, 1130626800, 8) ,(3, 1143327600, 9)"
-+ i_tzt="$i_tzt ,(3, 1162076400, 8) ,(3, 1174777200, 9)"
-+ i_tzt="$i_tzt ,(3, 1193526000, 8) ,(3, 1206831600, 9)"
-+ i_tzt="$i_tzt ,(3, 1224975600, 8) ,(3, 1238281200, 9)"
-+ i_tzt="$i_tzt ,(3, 1256425200, 8) ,(3, 1269730800, 9)"
-+ i_tzt="$i_tzt ,(3, 1288479600, 8) ,(3, 1301180400, 9)"
-+ i_tzt="$i_tzt ,(3, 1319929200, 8) ,(3, 1332630000, 9)"
-+ i_tzt="$i_tzt ,(3, 1351378800, 8) ,(3, 1364684400, 9)"
-+ i_tzt="$i_tzt ,(3, 1382828400, 8) ,(3, 1396134000, 9)"
-+ i_tzt="$i_tzt ,(3, 1414278000, 8) ,(3, 1427583600, 9)"
-+ i_tzt="$i_tzt ,(3, 1445727600, 8) ,(3, 1459033200, 9)"
-+ i_tzt="$i_tzt ,(3, 1477782000, 8) ,(3, 1490482800, 9)"
-+ i_tzt="$i_tzt ,(3, 1509231600, 8) ,(3, 1521932400, 9)"
-+ i_tzt="$i_tzt ,(3, 1540681200, 8) ,(3, 1553986800, 9)"
-+ i_tzt="$i_tzt ,(3, 1572130800, 8) ,(3, 1585436400, 9)"
-+ i_tzt="$i_tzt ,(3, 1603580400, 8) ,(3, 1616886000, 9)"
-+ i_tzt="$i_tzt ,(3, 1635634800, 8) ,(3, 1648335600, 9)"
-+ i_tzt="$i_tzt ,(3, 1667084400, 8) ,(3, 1679785200, 9)"
-+ i_tzt="$i_tzt ,(3, 1698534000, 8) ,(3, 1711839600, 9)"
-+ i_tzt="$i_tzt ,(3, 1729983600, 8) ,(3, 1743289200, 9)"
-+ i_tzt="$i_tzt ,(3, 1761433200, 8) ,(3, 1774738800, 9)"
-+ i_tzt="$i_tzt ,(3, 1792882800, 8) ,(3, 1806188400, 9)"
-+ i_tzt="$i_tzt ,(3, 1824937200, 8) ,(3, 1837638000, 9)"
-+ i_tzt="$i_tzt ,(3, 1856386800, 8) ,(3, 1869087600, 9)"
-+ i_tzt="$i_tzt ,(3, 1887836400, 8) ,(3, 1901142000, 9)"
-+ i_tzt="$i_tzt ,(3, 1919286000, 8) ,(3, 1932591600, 9)"
-+ i_tzt="$i_tzt ,(3, 1950735600, 8) ,(3, 1964041200, 9)"
-+ i_tzt="$i_tzt ,(3, 1982790000, 8) ,(3, 1995490800, 9)"
-+ i_tzt="$i_tzt ,(3, 2014239600, 8) ,(3, 2026940400, 9)"
-+ i_tzt="$i_tzt ,(3, 2045689200, 8) ,(3, 2058390000, 9)"
-+ i_tzt="$i_tzt ,(3, 2077138800, 8) ,(3, 2090444400, 9)"
-+ i_tzt="$i_tzt ,(3, 2108588400, 8) ,(3, 2121894000, 9)"
-+ i_tzt="$i_tzt ,(3, 2140038000, 8)"
-+ i_tzt="$i_tzt ,(4, -1688265000, 2) ,(4, -1656819048, 1)"
-+ i_tzt="$i_tzt ,(4, -1641353448, 2) ,(4, -1627965048, 3)"
-+ i_tzt="$i_tzt ,(4, -1618716648, 1) ,(4, -1596429048, 3)"
-+ i_tzt="$i_tzt ,(4, -1593829848, 5) ,(4, -1589860800, 4)"
-+ i_tzt="$i_tzt ,(4, -1542427200, 5) ,(4, -1539493200, 6)"
-+ i_tzt="$i_tzt ,(4, -1525323600, 5) ,(4, -1522728000, 4)"
-+ i_tzt="$i_tzt ,(4, -1491188400, 7) ,(4, -1247536800, 4)"
-+ i_tzt="$i_tzt ,(4, 354920409, 5) ,(4, 370728010, 4)"
-+ i_tzt="$i_tzt ,(4, 386456410, 5) ,(4, 402264011, 4)"
-+ i_tzt="$i_tzt ,(4, 417992411, 5) ,(4, 433800012, 4)"
-+ i_tzt="$i_tzt ,(4, 449614812, 5) ,(4, 465346812, 8)"
-+ i_tzt="$i_tzt ,(4, 481071612, 9) ,(4, 496796413, 8)"
-+ i_tzt="$i_tzt ,(4, 512521213, 9) ,(4, 528246013, 8)"
-+ i_tzt="$i_tzt ,(4, 543970813, 9) ,(4, 559695613, 8)"
-+ i_tzt="$i_tzt ,(4, 575420414, 9) ,(4, 591145214, 8)"
-+ i_tzt="$i_tzt ,(4, 606870014, 9) ,(4, 622594814, 8)"
-+ i_tzt="$i_tzt ,(4, 638319615, 9) ,(4, 654649215, 8)"
-+ i_tzt="$i_tzt ,(4, 670374016, 10) ,(4, 686102416, 11)"
-+ i_tzt="$i_tzt ,(4, 695779216, 8) ,(4, 701812816, 5)"
-+ i_tzt="$i_tzt ,(4, 717534017, 4) ,(4, 733273217, 9)"
-+ i_tzt="$i_tzt ,(4, 748998018, 8) ,(4, 764722818, 9)"
-+ i_tzt="$i_tzt ,(4, 780447619, 8) ,(4, 796172419, 9)"
-+ i_tzt="$i_tzt ,(4, 811897219, 8) ,(4, 828226820, 9)"
-+ i_tzt="$i_tzt ,(4, 846370820, 8) ,(4, 859676420, 9)"
-+ i_tzt="$i_tzt ,(4, 877820421, 8) ,(4, 891126021, 9)"
-+ i_tzt="$i_tzt ,(4, 909270021, 8) ,(4, 922575622, 9)"
-+ i_tzt="$i_tzt ,(4, 941324422, 8) ,(4, 954025222, 9)"
-+ i_tzt="$i_tzt ,(4, 972774022, 8) ,(4, 985474822, 9)"
-+ i_tzt="$i_tzt ,(4, 1004223622, 8) ,(4, 1017529222, 9)"
-+ i_tzt="$i_tzt ,(4, 1035673222, 8) ,(4, 1048978822, 9)"
-+ i_tzt="$i_tzt ,(4, 1067122822, 8) ,(4, 1080428422, 9)"
-+ i_tzt="$i_tzt ,(4, 1099177222, 8) ,(4, 1111878022, 9)"
-+ i_tzt="$i_tzt ,(4, 1130626822, 8) ,(4, 1143327622, 9)"
-+ i_tzt="$i_tzt ,(4, 1162076422, 8) ,(4, 1174777222, 9)"
-+ i_tzt="$i_tzt ,(4, 1193526022, 8) ,(4, 1206831622, 9)"
-+ i_tzt="$i_tzt ,(4, 1224975622, 8) ,(4, 1238281222, 9)"
-+ i_tzt="$i_tzt ,(4, 1256425222, 8) ,(4, 1269730822, 9)"
-+ i_tzt="$i_tzt ,(4, 1288479622, 8) ,(4, 1301180422, 9)"
-+ i_tzt="$i_tzt ,(4, 1319929222, 8) ,(4, 1332630022, 9)"
-+ i_tzt="$i_tzt ,(4, 1351378822, 8) ,(4, 1364684422, 9)"
-+ i_tzt="$i_tzt ,(4, 1382828422, 8) ,(4, 1396134022, 9)"
-+ i_tzt="$i_tzt ,(4, 1414278022, 8) ,(4, 1427583622, 9)"
-+ i_tzt="$i_tzt ,(4, 1445727622, 8) ,(4, 1459033222, 9)"
-+ i_tzt="$i_tzt ,(4, 1477782022, 8) ,(4, 1490482822, 9)"
-+ i_tzt="$i_tzt ,(4, 1509231622, 8) ,(4, 1521932422, 9)"
-+ i_tzt="$i_tzt ,(4, 1540681222, 8) ,(4, 1553986822, 9)"
-+ i_tzt="$i_tzt ,(4, 1572130822, 8) ,(4, 1585436422, 9)"
-+ i_tzt="$i_tzt ,(4, 1603580422, 8) ,(4, 1616886022, 9)"
-+ i_tzt="$i_tzt ,(4, 1635634822, 8) ,(4, 1648335622, 9)"
-+ i_tzt="$i_tzt ,(4, 1667084422, 8) ,(4, 1679785222, 9)"
-+ i_tzt="$i_tzt ,(4, 1698534022, 8) ,(4, 1711839622, 9)"
-+ i_tzt="$i_tzt ,(4, 1729983622, 8) ,(4, 1743289222, 9)"
-+ i_tzt="$i_tzt ,(4, 1761433222, 8) ,(4, 1774738822, 9)"
-+ i_tzt="$i_tzt ,(4, 1792882822, 8) ,(4, 1806188422, 9)"
-+ i_tzt="$i_tzt ,(4, 1824937222, 8) ,(4, 1837638022, 9)"
-+ i_tzt="$i_tzt ,(4, 1856386822, 8) ,(4, 1869087622, 9)"
-+ i_tzt="$i_tzt ,(4, 1887836422, 8) ,(4, 1901142022, 9)"
-+ i_tzt="$i_tzt ,(4, 1919286022, 8) ,(4, 1932591622, 9)"
-+ i_tzt="$i_tzt ,(4, 1950735622, 8) ,(4, 1964041222, 9)"
-+ i_tzt="$i_tzt ,(4, 1982790022, 8) ,(4, 1995490822, 9)"
-+ i_tzt="$i_tzt ,(4, 2014239622, 8) ,(4, 2026940422, 9)"
-+ i_tzt="$i_tzt ,(4, 2045689222, 8) ,(4, 2058390022, 9)"
-+ i_tzt="$i_tzt ,(4, 2077138822, 8) ,(4, 2090444422, 9)"
-+ i_tzt="$i_tzt ,(4, 2108588422, 8) ,(4, 2121894022, 9)"
-+ i_tzt="$i_tzt ,(4, 2140038022, 8)"
-+ i_tzt="$i_tzt ,(5, -1009875600, 1);"
-+ fi
-+fi
-+
-+if test ! -f $mdata/time_zone_transition_type.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing time_zone_transition_type table" 1>&2;
-+ fi
-+
-+ c_tztt="$c_tztt CREATE TABLE time_zone_transition_type ("
-+ c_tztt="$c_tztt Time_zone_id int unsigned NOT NULL,"
-+ c_tztt="$c_tztt Transition_type_id int unsigned NOT NULL,"
-+ c_tztt="$c_tztt Offset int signed DEFAULT 0 NOT NULL,"
-+ c_tztt="$c_tztt Is_DST tinyint unsigned DEFAULT 0 NOT NULL,"
-+ c_tztt="$c_tztt Abbreviation char(8) DEFAULT '' NOT NULL,"
-+ c_tztt="$c_tztt PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id)"
-+ c_tztt="$c_tztt ) engine=MyISAM CHARACTER SET utf8"
-+ c_tztt="$c_tztt comment='Time zone transition types';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_tztt="$i_tztt INSERT INTO time_zone_transition_type (Time_zone_id,"
-+ i_tztt="$i_tztt Transition_type_id, Offset, Is_DST, Abbreviation) VALUES"
-+ i_tztt="$i_tztt (1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET')"
-+ i_tztt="$i_tztt ,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET')"
-+ i_tztt="$i_tztt ,(2, 0, 0, 0, 'UTC')"
-+ i_tztt="$i_tztt ,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST')"
-+ i_tztt="$i_tztt ,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST')"
-+ i_tztt="$i_tztt ,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD')"
-+ i_tztt="$i_tztt ,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET')"
-+ i_tztt="$i_tztt ,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD')"
-+ i_tztt="$i_tztt ,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET')"
-+ i_tztt="$i_tztt ,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST')"
-+ i_tztt="$i_tztt ,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST')"
-+ i_tztt="$i_tztt ,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD')"
-+ i_tztt="$i_tztt ,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET')"
-+ i_tztt="$i_tztt ,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD')"
-+ i_tztt="$i_tztt ,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET')"
-+ i_tztt="$i_tztt ,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST');"
-+ fi
-+fi
-+
-+if test ! -f $mdata/time_zone_leap_second.frm
-+then
-+ if test "$1" = "verbose" ; then
-+ echo "Preparing time_zone_leap_second table" 1>&2;
-+ fi
-+
-+ c_tzls="$c_tzls CREATE TABLE time_zone_leap_second ("
-+ c_tzls="$c_tzls Transition_time bigint signed NOT NULL,"
-+ c_tzls="$c_tzls Correction int signed NOT NULL,"
-+ c_tzls="$c_tzls PRIMARY KEY TranTime (Transition_time)"
-+ c_tzls="$c_tzls ) engine=MyISAM CHARACTER SET utf8"
-+ c_tzls="$c_tzls comment='Leap seconds information for time zones';"
-+
-+ if test "$1" = "test"
-+ then
-+ i_tzls="$i_tzls INSERT INTO time_zone_leap_second "
-+ i_tzls="$i_tzls (Transition_time, Correction) VALUES "
-+ i_tzls="$i_tzls (78796800, 1) ,(94694401, 2) ,(126230402, 3)"
-+ i_tzls="$i_tzls ,(157766403, 4) ,(189302404, 5) ,(220924805, 6)"
-+ i_tzls="$i_tzls ,(252460806, 7) ,(283996807, 8) ,(315532808, 9)"
-+ i_tzls="$i_tzls ,(362793609, 10) ,(394329610, 11) ,(425865611, 12)"
-+ i_tzls="$i_tzls ,(489024012, 13) ,(567993613, 14) ,(631152014, 15)"
-+ i_tzls="$i_tzls ,(662688015, 16) ,(709948816, 17) ,(741484817, 18)"
-+ i_tzls="$i_tzls ,(773020818, 19) ,(820454419, 20) ,(867715220, 21)"
-+ i_tzls="$i_tzls ,(915148821, 22);"
-+ fi
-+fi
-+
-+if test ! -f $mdata/proc.frm
-+then
-+ c_p="$c_p CREATE TABLE proc ("
-+ c_p="$c_p db char(64) collate utf8_bin DEFAULT '' NOT NULL,"
-+ c_p="$c_p name char(64) DEFAULT '' NOT NULL,"
-+ c_p="$c_p type enum('FUNCTION','PROCEDURE') NOT NULL,"
-+ c_p="$c_p specific_name char(64) DEFAULT '' NOT NULL,"
-+ c_p="$c_p language enum('SQL') DEFAULT 'SQL' NOT NULL,"
-+ c_p="$c_p sql_data_access enum('CONTAINS_SQL',"
-+ c_p="$c_p 'NO_SQL',"
-+ c_p="$c_p 'READS_SQL_DATA',"
-+ c_p="$c_p 'MODIFIES_SQL_DATA'"
-+ c_p="$c_p ) DEFAULT 'CONTAINS_SQL' NOT NULL,"
-+ c_p="$c_p is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL,"
-+ c_p="$c_p security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL,"
-+ c_p="$c_p param_list blob DEFAULT '' NOT NULL,"
-+ c_p="$c_p returns char(64) DEFAULT '' NOT NULL,"
-+ c_p="$c_p body longblob DEFAULT '' NOT NULL,"
-+ c_p="$c_p definer char(77) collate utf8_bin DEFAULT '' NOT NULL,"
-+ c_p="$c_p created timestamp,"
-+ c_p="$c_p modified timestamp,"
-+ c_p="$c_p sql_mode set("
-+ c_p="$c_p 'REAL_AS_FLOAT',"
-+ c_p="$c_p 'PIPES_AS_CONCAT',"
-+ c_p="$c_p 'ANSI_QUOTES',"
-+ c_p="$c_p 'IGNORE_SPACE',"
-+ c_p="$c_p 'NOT_USED',"
-+ c_p="$c_p 'ONLY_FULL_GROUP_BY',"
-+ c_p="$c_p 'NO_UNSIGNED_SUBTRACTION',"
-+ c_p="$c_p 'NO_DIR_IN_CREATE',"
-+ c_p="$c_p 'POSTGRESQL',"
-+ c_p="$c_p 'ORACLE',"
-+ c_p="$c_p 'MSSQL',"
-+ c_p="$c_p 'DB2',"
-+ c_p="$c_p 'MAXDB',"
-+ c_p="$c_p 'NO_KEY_OPTIONS',"
-+ c_p="$c_p 'NO_TABLE_OPTIONS',"
-+ c_p="$c_p 'NO_FIELD_OPTIONS',"
-+ c_p="$c_p 'MYSQL323',"
-+ c_p="$c_p 'MYSQL40',"
-+ c_p="$c_p 'ANSI',"
-+ c_p="$c_p 'NO_AUTO_VALUE_ON_ZERO',"
-+ c_p="$c_p 'NO_BACKSLASH_ESCAPES',"
-+ c_p="$c_p 'STRICT_TRANS_TABLES',"
-+ c_p="$c_p 'STRICT_ALL_TABLES',"
-+ c_p="$c_p 'NO_ZERO_IN_DATE',"
-+ c_p="$c_p 'NO_ZERO_DATE',"
-+ c_p="$c_p 'INVALID_DATES',"
-+ c_p="$c_p 'ERROR_FOR_DIVISION_BY_ZERO',"
-+ c_p="$c_p 'TRADITIONAL',"
-+ c_p="$c_p 'NO_AUTO_CREATE_USER',"
-+ c_p="$c_p 'HIGH_NOT_PRECEDENCE'"
-+ c_p="$c_p ) DEFAULT '' NOT NULL,"
-+ c_p="$c_p comment char(64) collate utf8_bin DEFAULT '' NOT NULL,"
-+ c_p="$c_p PRIMARY KEY (db,name,type)"
-+ c_p="$c_p ) engine=MyISAM"
-+ c_p="$c_p character set utf8"
-+ c_p="$c_p comment='Stored Procedures';"
-+fi
-+
-+cat << END_OF_DATA
-+use mysql;
-+set table_type=myisam;
-+$c_d
-+$i_d
-+
-+$c_h
-+$i_h
-+
-+$c_u
-+$i_u
-+
-+$c_f
-+$i_f
-+
-+$c_t
-+$c_c
-+
-+$c_ht
-+$c_hc
-+$c_hr
-+$c_hk
-+
-+$c_tzn
-+$i_tzn
-+$c_tz
-+$i_tz
-+$c_tzt
-+$i_tzt
-+$c_tztt
-+$i_tztt
-+$c_tzls
-+$i_tzls
-+
-+$c_p
-+$c_pp
-+
-+END_OF_DATA
-+
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_fix_privilege_tables.sh mysql-5.0.34-bk-20070101/scripts/mysql_fix_privilege_tables.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_fix_privilege_tables.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_fix_privilege_tables.sh 2007-01-03 00:50:06.000000000 +0100
-@@ -92,17 +92,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- then
- for i in @bindir@ $basedir/bin "$dirname/../client"
- do
-- if test -f $i/mysql
-+ if test -f $i/@mybin_mysql@
- then
- bindir=$i
- break
-@@ -133,7 +133,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$port"; then
- cmd="$cmd --port=$port"
- fi
-@@ -148,7 +148,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_install_db.sh mysql-5.0.34-bk-20070101/scripts/mysql_install_db.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_install_db.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_install_db.sh 2007-01-03 00:55:51.000000000 +0100
-@@ -70,20 +70,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -108,10 +108,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -124,7 +124,8 @@
- then
- fill_help_tables=$srcdir/scripts/fill_help_tables.sql
- else
-- for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+ for i in @sharedstatedir@ \
-+ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
-@@ -143,13 +144,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys
- then
- langdir=$srcdir/sql/share/english
-@@ -179,14 +180,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -194,7 +195,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -239,7 +240,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -269,8 +270,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -278,14 +279,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -305,13 +306,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -320,6 +321,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_secure_installation.sh mysql-5.0.34-bk-20070101/scripts/mysql_secure_installation.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_secure_installation.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_secure_installation.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -29,7 +29,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysql_secure_installation.sh.orig mysql-5.0.34-bk-20070101/scripts/mysql_secure_installation.sh.orig
---- mysql-5.0.34-bk-20070101.orig/scripts/mysql_secure_installation.sh.orig 1970-01-01 01:00:00.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysql_secure_installation.sh.orig 2007-01-01 19:10:29.000000000 +0100
-@@ -0,0 +1,311 @@
-+#!/bin/sh
-+
-+# Copyright (C) 2002 MySQL AB and Jeremy Cole
-+#
-+# 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
-+
-+config=".my.cnf.$$"
-+command=".mysql.$$"
-+
-+trap "interrupt" 2
-+
-+rootpass=""
-+
-+prepare() {
-+ touch $config $command
-+ chmod 600 $config $command
-+}
-+
-+do_query() {
-+ echo $1 >$command
-+ mysql --defaults-file=$config <$command
-+ return $?
-+}
-+
-+make_config() {
-+ echo "# mysql_secure_installation config file" >$config
-+ echo "[mysql]" >>$config
-+ echo "user=root" >>$config
-+ echo "password=$rootpass" >>$config
-+}
-+
-+get_root_password() {
-+ status=1
-+ while [ $status -eq 1 ]; do
-+ stty -echo
-+ echo -n "Enter current password for root (enter for none): "
-+ read password
-+ echo
-+ stty echo
-+ if [ "x$password" = "x" ]; then
-+ hadpass=0
-+ else
-+ hadpass=1
-+ fi
-+ rootpass=$password
-+ make_config
-+ do_query ""
-+ status=$?
-+ done
-+ echo "OK, successfully used password, moving on..."
-+ echo
-+}
-+
-+set_root_password() {
-+ stty -echo
-+ echo -n "New password: "
-+ read password1
-+ echo
-+ echo -n "Re-enter new password: "
-+ read password2
-+ echo
-+ stty echo
-+
-+ if [ "$password1" != "$password2" ]; then
-+ echo "Sorry, passwords do not match."
-+ echo
-+ return 1
-+ fi
-+
-+ if [ "$password1" = "" ]; then
-+ echo "Sorry, you can't use an empty password here."
-+ echo
-+ return 1
-+ fi
-+
-+ do_query "UPDATE mysql.user SET Password=PASSWORD('$password1') WHERE User='root';"
-+ if [ $? -eq 0 ]; then
-+ echo "Password updated successfully!"
-+ echo "Reloading privilege tables.."
-+ if ! reload_privilege_tables; then
-+ exit 1
-+ fi
-+ echo
-+ rootpass=$password1
-+ make_config
-+ else
-+ echo "Password update failed!"
-+ exit 1
-+ fi
-+
-+ return 0
-+}
-+
-+remove_anonymous_users() {
-+ do_query "DELETE FROM mysql.user WHERE User='';"
-+ if [ $? -eq 0 ]; then
-+ echo " ... Success!"
-+ else
-+ echo " ... Failed!"
-+ exit 1
-+ fi
-+
-+ return 0
-+}
-+
-+remove_remote_root() {
-+ do_query "DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';"
-+ if [ $? -eq 0 ]; then
-+ echo " ... Success!"
-+ else
-+ echo " ... Failed!"
-+ fi
-+}
-+
-+remove_test_database() {
-+ echo " - Dropping test database..."
-+ do_query "DROP DATABASE test;"
-+ if [ $? -eq 0 ]; then
-+ echo " ... Success!"
-+ else
-+ echo " ... Failed! Not critical, keep moving..."
-+ fi
-+
-+ echo " - Removing privileges on test database..."
-+ do_query "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
-+ if [ $? -eq 0 ]; then
-+ echo " ... Success!"
-+ else
-+ echo " ... Failed! Not critical, keep moving..."
-+ fi
-+
-+ return 0
-+}
-+
-+reload_privilege_tables() {
-+ do_query "FLUSH PRIVILEGES;"
-+ if [ $? -eq 0 ]; then
-+ echo " ... Success!"
-+ return 0
-+ else
-+ echo " ... Failed!"
-+ return 1
-+ fi
-+}
-+
-+interrupt() {
-+ echo
-+ echo "Aborting!"
-+ echo
-+ cleanup
-+ stty echo
-+ exit 1
-+}
-+
-+cleanup() {
-+ echo "Cleaning up..."
-+ rm -f $config $command
-+}
-+
-+
-+# The actual script starts here
-+
-+prepare
-+
-+echo
-+echo
-+echo
-+echo
-+echo "NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL"
-+echo " SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!"
-+echo
-+echo
-+
-+echo "In order to log into MySQL to secure it, we'll need the current"
-+echo "password for the root user. If you've just installed MySQL, and"
-+echo "you haven't set the root password yet, the password will be blank,"
-+echo "so you should just press enter here."
-+echo
-+
-+get_root_password
-+
-+
-+#
-+# Set the root password
-+#
-+
-+echo "Setting the root password ensures that nobody can log into the MySQL"
-+echo "root user without the proper authorisation."
-+echo
-+
-+if [ $hadpass -eq 0 ]; then
-+ echo -n "Set root password? [Y/n] "
-+else
-+ echo "You already have a root password set, so you can safely answer 'n'."
-+ echo
-+ echo -n "Change the root password? [Y/n] "
-+fi
-+
-+read reply
-+if [ "$reply" = "n" ]; then
-+ echo " ... skipping."
-+else
-+ status=1
-+ while [ $status -eq 1 ]; do
-+ set_root_password
-+ status=$?
-+ done
-+fi
-+echo
-+
-+
-+#
-+# Remove anonymous users
-+#
-+
-+echo "By default, a MySQL installation has an anonymous user, allowing anyone"
-+echo "to log into MySQL without having to have a user account created for"
-+echo "them. This is intended only for testing, and to make the installation"
-+echo "go a bit smoother. You should remove them before moving into a"
-+echo "production environment."
-+echo
-+
-+echo -n "Remove anonymous users? [Y/n] "
-+
-+read reply
-+if [ "$reply" = "n" ]; then
-+ echo " ... skipping."
-+else
-+ remove_anonymous_users
-+fi
-+echo
-+
-+
-+#
-+# Disallow remote root login
-+#
-+
-+echo "Normally, root should only be allowed to connect from 'localhost'. This"
-+echo "ensures that someone cannot guess at the root password from the network."
-+echo
-+
-+echo -n "Disallow root login remotely? [Y/n] "
-+read reply
-+if [ "$reply" = "n" ]; then
-+ echo " ... skipping."
-+else
-+ remove_remote_root
-+fi
-+echo
-+
-+
-+#
-+# Remove test database
-+#
-+
-+echo "By default, MySQL comes with a database named 'test' that anyone can"
-+echo "access. This is also intended only for testing, and should be removed"
-+echo "before moving into a production environment."
-+echo
-+
-+echo -n "Remove test database and access to it? [Y/n] "
-+read reply
-+if [ "$reply" = "n" ]; then
-+ echo " ... skipping."
-+else
-+ remove_test_database
-+fi
-+echo
-+
-+
-+#
-+# Reload privilege tables
-+#
-+
-+echo "Reloading the privilege tables will ensure that all changes made so far"
-+echo "will take effect immediately."
-+echo
-+
-+echo -n "Reload privilege tables now? [Y/n] "
-+read reply
-+if [ "$reply" = "n" ]; then
-+ echo " ... skipping."
-+else
-+ reload_privilege_tables
-+fi
-+echo
-+
-+cleanup
-+
-+echo
-+echo
-+echo
-+echo "All done! If you've completed all of the above steps, your MySQL"
-+echo "installation should now be secure."
-+echo
-+echo "Thanks for using MySQL!"
-+echo
-+echo
-+
-+
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysqlaccess.sh mysql-5.0.34-bk-20070101/scripts/mysqlaccess.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysqlaccess.sh 2007-01-01 19:10:29.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysqlaccess.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysqld_multi.sh mysql-5.0.34-bk-20070101/scripts/mysqld_multi.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysqld_multi.sh 2007-01-01 19:10:30.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysqld_multi.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysqld_safe.sh mysql-5.0.34-bk-20070101/scripts/mysqld_safe.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysqld_safe.sh 2007-01-01 19:10:30.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysqld_safe.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -87,7 +87,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -113,13 +113,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -181,17 +181,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -216,11 +216,11 @@
- # Use the mysqld-max binary by default if the user doesn't specify a binary
- if test -z "$MYSQLD"
- then
-- if test -x $ledir/mysqld-max
-+ if test -x $ledir/@mybin_mysqld-max@
- then
-- MYSQLD=mysqld-max
-+ MYSQLD=@mybin_mysqld-max@
- else
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
- fi
-
-@@ -229,7 +229,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -365,8 +365,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysqld_safe.sh.orig mysql-5.0.34-bk-20070101/scripts/mysqld_safe.sh.orig
---- mysql-5.0.34-bk-20070101.orig/scripts/mysqld_safe.sh.orig 1970-01-01 01:00:00.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysqld_safe.sh.orig 2007-01-01 19:10:30.000000000 +0100
-@@ -0,0 +1,429 @@
-+#!/bin/sh
-+# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
-+# This file is public domain and comes with NO WARRANTY of any kind
-+#
-+# scripts to start the MySQL daemon and restart it if it dies unexpectedly
-+#
-+# This should be executed in the MySQL base directory if you are using a
-+# binary installation that has other paths than you are using.
-+#
-+# mysql.server works by first doing a cd to the base directory and from there
-+# executing mysqld_safe
-+
-+KILL_MYSQLD=1;
-+MYSQLD=
-+
-+trap '' 1 2 3 15 # we shouldn't let anyone kill us
-+
-+umask 007
-+
-+defaults=
-+case "$1" in
-+ --no-defaults|--defaults-file=*|--defaults-extra-file=*)
-+ defaults="$1"; shift
-+ ;;
-+esac
-+
-+usage () {
-+ cat <<EOF
-+Usage: $0 [OPTIONS]
-+ --no-defaults Don't read the system defaults file
-+ --defaults-file=FILE Use the specified defaults file
-+ --defaults-extra-file=FILE Also use defaults from the specified file
-+ --ledir=DIRECTORY Look for mysqld in the specified directory
-+ --log-error=FILE Log errors to the specified log file
-+ --open-files-limit=LIMIT Limit the number of open files
-+ --core-file-size=LIMIT Limit core files to the specified size
-+ --timezone=TZ Set the system timezone
-+ --mysqld=FILE Use the specified file as mysqld
-+ --mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
-+ --nice=NICE Set the scheduling priority of mysqld
-+ --skip-kill-mysqld Don't try to kill stray mysqld processes
-+
-+All other options are passed to the mysqld program.
-+
-+EOF
-+ exit 1
-+}
-+
-+
-+parse_arguments() {
-+ # We only need to pass arguments through to the server if we don't
-+ # handle them here. So, we collect unrecognized options (passed on
-+ # the command line) into the args variable.
-+ pick_args=
-+ if test "$1" = PICK-ARGS-FROM-ARGV
-+ then
-+ pick_args=1
-+ shift
-+ fi
-+
-+ for arg do
-+ case "$arg" in
-+ --skip-kill-mysqld*)
-+ KILL_MYSQLD=0;
-+ ;;
-+ # these get passed explicitly to mysqld
-+ --basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e "s;--basedir=;;"` ;;
-+ --datadir=*) DATADIR=`echo "$arg" | sed -e "s;--datadir=;;"` ;;
-+ --pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;;
-+ --user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;;
-+
-+ # these two might have been set in a [mysqld_safe] section of my.cnf
-+ # they are added to mysqld command line to override settings from my.cnf
-+ --socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;;
-+ --port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;;
-+
-+ # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
-+ --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
-+ --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;;
-+ --open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;;
-+ --core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;;
-+ --timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;;
-+ --mysqld=*) MYSQLD=`echo "$arg" | sed -e "s;--mysqld=;;"` ;;
-+ --mysqld-version=*)
-+ tmp=`echo "$arg" | sed -e "s;--mysqld-version=;;"`
-+ if test -n "$tmp"
-+ then
-+ MYSQLD="mysqld-$tmp"
-+ else
-+ MYSQLD="mysqld"
-+ fi
-+ ;;
-+ --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-+ --help)
-+ usage
-+ ;;
-+ *)
-+ if test -n "$pick_args"
-+ then
-+ # This sed command makes sure that any special chars are quoted,
-+ # so the arg gets passed exactly to the server.
-+ args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
-+ fi
-+ ;;
-+ esac
-+ done
-+}
-+
-+
-+#
-+# First, try to find BASEDIR and ledir (where mysqld is)
-+#
-+
-+MY_PWD=`pwd`
-+# Check for the directories we would expect from a binary release install
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+then
-+ MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
-+ ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
-+# Check for the directories we would expect from a source install
-+elif test -f ./share/mysql/english/errmsg.sys -a \
-+ -x ./libexec/mysqld
-+then
-+ MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
-+ ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-+# Since we didn't find anything, used the compiled-in defaults
-+else
-+ MY_BASEDIR_VERSION=@prefix@
-+ ledir=@libexecdir@
-+fi
-+
-+#
-+# Second, try to find the data directory
-+#
-+
-+# Try where the binary installs put it
-+if test -d $MY_BASEDIR_VERSION/data/mysql
-+then
-+ DATADIR=$MY_BASEDIR_VERSION/data
-+ if test -z "$defaults" -a -r "$DATADIR/my.cnf"
-+ then
-+ defaults="--defaults-extra-file=$DATADIR/my.cnf"
-+ fi
-+# Next try where the source installs put it
-+elif test -d $MY_BASEDIR_VERSION/var/mysql
-+then
-+ DATADIR=$MY_BASEDIR_VERSION/var
-+# Or just give up and use our compiled-in default
-+else
-+ DATADIR=@localstatedir@
-+fi
-+
-+if test -z "$MYSQL_HOME"
-+then
-+ if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf"
-+ then
-+ echo "WARNING: Found two instances of my.cnf -"
-+ echo "$MY_BASEDIR_VERSION/my.cnf and"
-+ echo "$DATADIR/my.cnf"
-+ echo "IGNORING $DATADIR/my.cnf"
-+ echo
-+ MYSQL_HOME=$MY_BASEDIR_VERSION
-+ elif test -r "$DATADIR/my.cnf"
-+ then
-+ echo "WARNING: Found $DATADIR/my.cnf"
-+ echo "Datadir is deprecated place for my.cnf, please move it to $MY_BASEDIR_VERSION"
-+ echo
-+ MYSQL_HOME=$DATADIR
-+ else
-+ MYSQL_HOME=$MY_BASEDIR_VERSION
-+ fi
-+fi
-+export MYSQL_HOME
-+
-+user=@MYSQLD_USER@
-+niceness=0
-+
-+# these rely on $DATADIR by default, so we'll set them later on
-+pid_file=
-+err_log=
-+
-+# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
-+# and then merge with the command line arguments
-+if test -x ./bin/my_print_defaults
-+then
-+ print_defaults="./bin/my_print_defaults"
-+elif test -x @bindir@/my_print_defaults
-+then
-+ print_defaults="@bindir@/my_print_defaults"
-+elif test -x @bindir@/mysql_print_defaults
-+then
-+ print_defaults="@bindir@/mysql_print_defaults"
-+else
-+ print_defaults="my_print_defaults"
-+fi
-+
-+args=
-+SET_USER=2
-+parse_arguments `$print_defaults $defaults --loose-verbose mysqld server`
-+if test $SET_USER -eq 2
-+then
-+ SET_USER=0
-+fi
-+parse_arguments `$print_defaults $defaults --loose-verbose mysqld_safe safe_mysqld`
-+parse_arguments PICK-ARGS-FROM-ARGV "$@"
-+safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}}
-+
-+# Make sure that directory for $safe_mysql_unix_port exists
-+mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
-+if [ ! -d $mysql_unix_port_dir ]
-+then
-+ mkdir $mysql_unix_port_dir
-+ chown $user $mysql_unix_port_dir
-+fi
-+
-+# Use the mysqld-max binary by default if the user doesn't specify a binary
-+if test -z "$MYSQLD"
-+then
-+ if test -x $ledir/mysqld-max
-+ then
-+ MYSQLD=mysqld-max
-+ else
-+ MYSQLD=mysqld
-+ fi
-+fi
-+
-+if test ! -x $ledir/$MYSQLD
-+then
-+ echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
-+ echo "Please do a cd to the mysql installation directory and restart"
-+ echo "this script from there as follows:"
-+ echo "./bin/mysqld_safe".
-+ echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
-+ echo "information"
-+ exit 1
-+fi
-+
-+if test -z "$pid_file"
-+then
-+ pid_file=$DATADIR/`@HOSTNAME@`.pid
-+else
-+ case "$pid_file" in
-+ /* ) ;;
-+ * ) pid_file="$DATADIR/$pid_file" ;;
-+ esac
-+fi
-+test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-+
-+if test -n "$mysql_unix_port"
-+then
-+ args="--socket=$mysql_unix_port $args"
-+fi
-+if test -n "$mysql_tcp_port"
-+then
-+ args="--port=$mysql_tcp_port $args"
-+fi
-+
-+if test $niceness -eq 0
-+then
-+ NOHUP_NICENESS="nohup"
-+else
-+ NOHUP_NICENESS="nohup nice -$niceness"
-+fi
-+
-+# Using nice with no args to get the niceness level is GNU-specific.
-+# This check could be extended for other operating systems (e.g.,
-+# BSD could use "nohup sh -c 'ps -o nice -p $$' | tail -1").
-+# But, it also seems that GNU nohup is the only one which messes
-+# with the priority, so this is okay.
-+if nohup nice > /dev/null 2>&1
-+then
-+ normal_niceness=`nice`
-+ nohup_niceness=`nohup nice`
-+
-+ numeric_nice_values=1
-+ for val in $normal_niceness $nohup_niceness
-+ do
-+ case "$val" in
-+ -[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | \
-+ [0-9] | [0-9][0-9] | [0-9][0-9][0-9] )
-+ ;;
-+ * )
-+ numeric_nice_values=0 ;;
-+ esac
-+ done
-+
-+ if test $numeric_nice_values -eq 1
-+ then
-+ nice_value_diff=`expr $nohup_niceness - $normal_niceness`
-+ if test $? -eq 0 && test $nice_value_diff -gt 0 && \
-+ nice --$nice_value_diff echo testing > /dev/null 2>&1
-+ then
-+ # nohup increases the priority (bad), and we are permitted
-+ # to lower the priority with respect to the value the user
-+ # might have been given
-+ niceness=`expr $niceness - $nice_value_diff`
-+ NOHUP_NICENESS="nice -$niceness nohup"
-+ fi
-+ fi
-+else
-+ if nohup echo testing > /dev/null 2>&1
-+ then
-+ :
-+ else
-+ # nohup doesn't work on this system
-+ NOHUP_NICENESS=""
-+ fi
-+fi
-+
-+USER_OPTION=""
-+if test -w / -o "$USER" = "root"
-+then
-+ if test "$user" != "root" -o $SET_USER = 1
-+ then
-+ USER_OPTION="--user=$user"
-+ fi
-+ # If we are root, change the err log to the right user.
-+ touch $err_log; chown $user $err_log
-+ if test -n "$open_files"
-+ then
-+ ulimit -n $open_files
-+ args="--open-files-limit=$open_files $args"
-+ fi
-+fi
-+
-+# Try to set the core file size (even if we aren't root) because many systems
-+# don't specify a hard limit on core file size.
-+if test -n "$core_file_size"
-+then
-+ ulimit -c $core_file_size
-+fi
-+
-+#
-+# If there exists an old pid file, check if the daemon is already running
-+# Note: The switches to 'ps' may depend on your operating system
-+if test -f $pid_file
-+then
-+ PID=`cat $pid_file`
-+ if @CHECK_PID@
-+ then
-+ if @FIND_PROC@
-+ then # The pid contains a mysqld process
-+ echo "A mysqld process already exists"
-+ echo "A mysqld process already exists at " `date` >> $err_log
-+ exit 1
-+ fi
-+ fi
-+ rm -f $pid_file
-+ if test -f $pid_file
-+ then
-+ echo "Fatal error: Can't remove the pid file: $pid_file"
-+ echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-+ echo "Please remove it manually and start $0 again"
-+ echo "mysqld daemon not started"
-+ exit 1
-+ fi
-+fi
-+
-+#
-+# Uncomment the following lines if you want all tables to be automatically
-+# checked and repaired during startup. You should add sensible key_buffer
-+# and sort_buffer values to my.cnf to improve check performance or require
-+# less disk space.
-+# Alternatively, you can start mysqld with the "myisam-recover" option. See
-+# the manual for details.
-+#
-+# echo "Checking tables in $DATADIR"
-+# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+
-+echo "Starting $MYSQLD daemon with databases from $DATADIR"
-+
-+# Does this work on all systems?
-+#if type ulimit | grep "shell builtin" > /dev/null
-+#then
-+# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
-+#fi
-+
-+echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+while true
-+do
-+ rm -f $safe_mysql_unix_port $pid_file # Some extra safety
-+ if test -z "$args"
-+ then
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ else
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ fi
-+ if test ! -f $pid_file # This is removed if normal shutdown
-+ then
-+ echo "STOPPING server from pid file $pid_file"
-+ break
-+ fi
-+
-+ if @TARGET_LINUX@ && test $KILL_MYSQLD -eq 1
-+ then
-+ # Test if one process was hanging.
-+ # This is only a fix for Linux (running as base 3 mysqld processes)
-+ # but should work for the rest of the servers.
-+ # The only thing is ps x => redhat 5 gives warnings when using ps -x.
-+ # kill -9 is used or the process won't react on the kill.
-+ numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-+
-+ echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ I=1
-+ while test "$I" -le "$numofproces"
-+ do
-+ PROC=`ps xaww | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "pid-file=$pid_file" | sed -n '$p'`
-+
-+ for T in $PROC
-+ do
-+ break
-+ done
-+ # echo "TEST $I - $T **"
-+ if kill -9 $T
-+ then
-+ echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ else
-+ break
-+ fi
-+ I=`expr $I + 1`
-+ done
-+ fi
-+ echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+done
-+
-+echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
-+echo "" | tee -a $err_log
-+
-diff -Naur mysql-5.0.34-bk-20070101.orig/scripts/mysqldumpslow.sh mysql-5.0.34-bk-20070101/scripts/mysqldumpslow.sh
---- mysql-5.0.34-bk-20070101.orig/scripts/mysqldumpslow.sh 2007-01-01 19:10:30.000000000 +0100
-+++ mysql-5.0.34-bk-20070101/scripts/mysqldumpslow.sh 2007-01-03 00:48:04.000000000 +0100
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-5.1.10.patch b/00800_all_slot_script-5.1.10.patch
deleted file mode 100644
index 6faf367..0000000
--- a/00800_all_slot_script-5.1.10.patch
+++ /dev/null
@@ -1,539 +0,0 @@
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/Makefile.am mysql-5.1.10-beta-nightly-20060410.b/scripts/Makefile.am
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/Makefile.am 2006-04-10 04:27:52.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/Makefile.am 2006-04-12 15:54:41.000000000 +0000
-@@ -66,6 +66,32 @@
- mysqlaccess.conf \
- mysqlbug
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -101,8 +127,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/msql2mysql.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/msql2mysql.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/msql2mysql.sh 2006-04-10 04:27:53.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/msql2mysql.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqlaccess.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqlaccess.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqlaccess.sh 2006-04-10 04:27:54.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqlaccess.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_config.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_config.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_config.sh 2006-04-10 04:27:46.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_config.sh 2006-04-12 16:00:49.000000000 +0000
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -86,10 +86,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_create_system_tables.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_create_system_tables.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_create_system_tables.sh 2006-04-10 04:27:55.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_create_system_tables.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqld_multi.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqld_multi.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqld_multi.sh 2006-04-10 04:27:53.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqld_multi.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqld_safe.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqld_safe.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqld_safe.sh 2006-04-10 04:27:54.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqld_safe.sh 2006-04-12 16:02:34.000000000 +0000
-@@ -87,7 +87,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -113,13 +113,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -181,17 +181,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -216,7 +216,7 @@
- # If the user doesn't specify a binary, we assume name "mysqld"
- if test -z "$MYSQLD"
- then
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
-
- if test ! -x $ledir/$MYSQLD
-@@ -224,7 +224,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -357,8 +357,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqldumpslow.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqldumpslow.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysqldumpslow.sh 2006-04-10 04:27:54.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysqldumpslow.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_fix_privilege_tables.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_fix_privilege_tables.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_fix_privilege_tables.sh 2006-04-10 04:27:53.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_fix_privilege_tables.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -136,7 +136,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_install_db.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_install_db.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_install_db.sh 2006-04-10 04:27:54.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_install_db.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -58,20 +58,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -95,10 +95,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -107,7 +107,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -124,13 +124,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -154,14 +154,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -169,7 +169,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -214,7 +214,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -244,8 +244,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -253,14 +253,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:"
- echo "cd sql-bench ; perl run-all-tests"
-@@ -280,13 +280,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -295,6 +295,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_secure_installation.sh mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_secure_installation.sh
---- mysql-5.1.10-beta-nightly-20060410.a/scripts/mysql_secure_installation.sh 2006-04-10 04:27:53.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/scripts/mysql_secure_installation.sh 2006-04-12 15:54:41.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
diff --git a/00800_all_slot_script-5.1.12.patch b/00800_all_slot_script-5.1.12.patch
deleted file mode 100644
index a265dc4..0000000
--- a/00800_all_slot_script-5.1.12.patch
+++ /dev/null
@@ -1,539 +0,0 @@
-diff -Naur mysql_old/scripts/Makefile.am mysql_new/scripts/Makefile.am
---- mysql_old/scripts/Makefile.am 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/Makefile.am 2006-10-05 15:50:09.000000000 +0200
-@@ -61,6 +61,32 @@
- mysqlbug \
- make_win_bin_dist
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -93,8 +119,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur mysql_old/scripts/msql2mysql.sh mysql_new/scripts/msql2mysql.sh
---- mysql_old/scripts/msql2mysql.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/msql2mysql.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur mysql_old/scripts/mysql_config.sh mysql_new/scripts/mysql_config.sh
---- mysql_old/scripts/mysql_config.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysql_config.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -86,10 +86,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur mysql_old/scripts/mysql_create_system_tables.sh mysql_new/scripts/mysql_create_system_tables.sh
---- mysql_old/scripts/mysql_create_system_tables.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysql_create_system_tables.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur mysql_old/scripts/mysql_fix_privilege_tables.sh mysql_new/scripts/mysql_fix_privilege_tables.sh
---- mysql_old/scripts/mysql_fix_privilege_tables.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysql_fix_privilege_tables.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -136,7 +136,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur mysql_old/scripts/mysql_install_db.sh mysql_new/scripts/mysql_install_db.sh
---- mysql_old/scripts/mysql_install_db.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysql_install_db.sh 2006-10-05 15:51:01.000000000 +0200
-@@ -57,20 +57,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -94,10 +94,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -106,7 +106,7 @@
- fi
-
- # find fill_help_tables.sh
--for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
- then
-@@ -123,13 +123,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- mysqld_opt="--language=./sql/share/english"
- scriptdir="./scripts"
- fi
-@@ -153,14 +153,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -168,7 +168,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -213,7 +213,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -243,8 +243,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -252,14 +252,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- fi
- echo "Please report any problems with the @scriptdir@/mysqlbug script!"
-@@ -276,13 +276,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -291,6 +291,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur mysql_old/scripts/mysql_secure_installation.sh mysql_new/scripts/mysql_secure_installation.sh
---- mysql_old/scripts/mysql_secure_installation.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysql_secure_installation.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
-diff -Naur mysql_old/scripts/mysqlaccess.sh mysql_new/scripts/mysqlaccess.sh
---- mysql_old/scripts/mysqlaccess.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysqlaccess.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur mysql_old/scripts/mysqld_multi.sh mysql_new/scripts/mysqld_multi.sh
---- mysql_old/scripts/mysqld_multi.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysqld_multi.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur mysql_old/scripts/mysqld_safe.sh mysql_new/scripts/mysqld_safe.sh
---- mysql_old/scripts/mysqld_safe.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysqld_safe.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -91,7 +91,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -115,13 +115,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -183,17 +183,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- append_arg_to_args () {
-@@ -222,7 +222,7 @@
- # If the user doesn't specify a binary, we assume name "mysqld"
- if test -z "$MYSQLD"
- then
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
-
- if test ! -x $ledir/$MYSQLD
-@@ -230,7 +230,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -390,8 +390,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur mysql_old/scripts/mysqldumpslow.sh mysql_new/scripts/mysqldumpslow.sh
---- mysql_old/scripts/mysqldumpslow.sh 2006-10-05 15:18:45.000000000 +0200
-+++ mysql_new/scripts/mysqldumpslow.sh 2006-10-05 15:50:09.000000000 +0200
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
diff --git a/00800_all_slot_script-5.1.14.patch b/00800_all_slot_script-5.1.14.patch
deleted file mode 100644
index ef2c85d..0000000
--- a/00800_all_slot_script-5.1.14.patch
+++ /dev/null
@@ -1,540 +0,0 @@
-diff -Naur -Naur mysqlold/scripts/Makefile.am mysql/scripts/Makefile.am
---- mysqlold/scripts/Makefile.am 2006-12-06 17:05:36.000000000 +0000
-+++ mysql/scripts/Makefile.am 2006-12-12 13:21:16.000000000 +0000
-@@ -61,6 +61,32 @@
- mysqlbug \
- make_win_bin_dist
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -93,8 +119,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur -Naur mysqlold/scripts/msql2mysql.sh mysql/scripts/msql2mysql.sh
---- mysqlold/scripts/msql2mysql.sh 2006-12-06 17:05:23.000000000 +0000
-+++ mysql/scripts/msql2mysql.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur -Naur mysqlold/scripts/mysqlaccess.sh mysql/scripts/mysqlaccess.sh
---- mysqlold/scripts/mysqlaccess.sh 2006-12-06 17:05:55.000000000 +0000
-+++ mysql/scripts/mysqlaccess.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur -Naur mysqlold/scripts/mysql_config.sh mysql/scripts/mysql_config.sh
---- mysqlold/scripts/mysql_config.sh 2006-12-06 17:05:26.000000000 +0000
-+++ mysql/scripts/mysql_config.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -86,10 +86,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur -Naur mysqlold/scripts/mysql_create_system_tables.sh mysql/scripts/mysql_create_system_tables.sh
---- mysqlold/scripts/mysql_create_system_tables.sh 2006-12-06 17:05:24.000000000 +0000
-+++ mysql/scripts/mysql_create_system_tables.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur -Naur mysqlold/scripts/mysqld_multi.sh mysql/scripts/mysqld_multi.sh
---- mysqlold/scripts/mysqld_multi.sh 2006-12-06 17:05:26.000000000 +0000
-+++ mysql/scripts/mysqld_multi.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur -Naur mysqlold/scripts/mysqld_safe.sh mysql/scripts/mysqld_safe.sh
---- mysqlold/scripts/mysqld_safe.sh 2006-12-06 17:05:24.000000000 +0000
-+++ mysql/scripts/mysqld_safe.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -91,7 +91,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -115,13 +115,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -183,17 +183,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- append_arg_to_args () {
-@@ -222,7 +222,7 @@
- # If the user doesn't specify a binary, we assume name "mysqld"
- if test -z "$MYSQLD"
- then
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
-
- if test ! -x $ledir/$MYSQLD
-@@ -230,7 +230,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -390,8 +390,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur -Naur mysqlold/scripts/mysqldumpslow.sh mysql/scripts/mysqldumpslow.sh
---- mysqlold/scripts/mysqldumpslow.sh 2006-12-06 17:05:38.000000000 +0000
-+++ mysql/scripts/mysqldumpslow.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
-diff -Naur -Naur mysqlold/scripts/mysql_fix_privilege_tables.sh mysql/scripts/mysql_fix_privilege_tables.sh
---- mysqlold/scripts/mysql_fix_privilege_tables.sh 2006-12-06 17:05:18.000000000 +0000
-+++ mysql/scripts/mysql_fix_privilege_tables.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$password" ; then
- cmd="$cmd --password=$password"
- fi
-@@ -136,7 +136,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur -Naur mysqlold/scripts/mysql_install_db.sh mysql/scripts/mysql_install_db.sh
---- mysqlold/scripts/mysql_install_db.sh 2006-12-06 17:05:24.000000000 +0000
-+++ mysql/scripts/mysql_install_db.sh 2006-12-12 13:26:18.000000000 +0000
-@@ -58,20 +58,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -96,10 +96,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -112,7 +112,8 @@
- then
- fill_help_tables=$srcdir/scripts/fill_help_tables.sql
- else
-- for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+ for i in @sharedstatedir@ \
-+ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
-@@ -131,13 +132,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys
- then
- langdir=$srcdir/sql/share/english
-@@ -167,14 +168,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -182,7 +183,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -227,7 +228,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -257,8 +258,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -266,14 +267,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- fi
- echo "Please report any problems with the @scriptdir@/mysqlbug script!"
-@@ -290,13 +291,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -305,6 +306,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur -Naur mysqlold/scripts/mysql_secure_installation.sh mysql/scripts/mysql_secure_installation.sh
---- mysqlold/scripts/mysql_secure_installation.sh 2006-12-06 17:05:52.000000000 +0000
-+++ mysql/scripts/mysql_secure_installation.sh 2006-12-12 13:21:16.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
diff --git a/00800_all_slot_script-5.1.15.patch b/00800_all_slot_script-5.1.15.patch
deleted file mode 100644
index 40502d8..0000000
--- a/00800_all_slot_script-5.1.15.patch
+++ /dev/null
@@ -1,540 +0,0 @@
-diff -Naur -Naur mysqlold/scripts/Makefile.am mysql/scripts/Makefile.am
---- mysqlold/scripts/Makefile.am 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/Makefile.am 2006-12-11 22:25:49.000000000 +0000
-@@ -61,6 +61,32 @@
- mysqlbug \
- make_win_bin_dist
-
-+sql_libexec_REPLACE = mysqld
-+instance_manager_libexec_REPLACE= mysqlmanager
-+client_bin_REPLACE = mysql mysqladmin mysqlcheck mysqlshow \
-+ mysqldump mysqlimport mysqltest mysqlbinlog \
-+ mysqltestmanagerc mysqltestmanager-pwgen
-+extra_bin_REPLACE = replace comp_err perror resolveip my_print_defaults \
-+ resolve_stack_dump mysql_waitpid innochecksum
-+myisam_bin_REPLACE = myisamchk myisamlog myisampack myisam_ftdump
-+tools_bin_REPLACE = mysqltestmanager
-+cw_cpcd_ndbbin_REPLACE = ndb_cpcd
-+kernel_ndbbin_REPLACE = ndbd
-+mgmsrv_ndbbin_REPLACE = ndb_mgmd
-+sql_bin_REPLACE = mysql_tzinfo_to_sql
-+tests_bin_REPLACE = mysql_client_test
-+ndbtools_bin_REPLACE = ndb_test_platform ndb_waiter \
-+ ndb_drop_table ndb_delete_all \
-+ ndb_desc ndb_drop_index \
-+ ndb_show_tables ndb_select_all \
-+ ndb_select_count ndb_restore ndb_config
-+EXTRA_REPLACE_BIN = safe_mysqld mysqlanalyze mysqloptimize mysqlrepair mysqld-max isamchk \
-+ $(sql_libexec_REPLACE) $(ndbtools_bin_REPLACE) \
-+ $(instance_manager_libexec_REPLACE) $(client_bin_REPLACE) \
-+ $(extra_bin_REPLACE) $(myisam_bin_REPLACE) $(tools_bin_REPLACE) \
-+ $(cw_cpcd_ndbbin_REPLACE) $(kernel_ndbbin_REPLACE) $(mgmsrv_ndbbin_REPLACE) \
-+ $(sql_bin_REPLACE) $(tests_bin_REPLACE)
-+
- dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql
-
- # mysqlbug should be distributed built so that people can report build
-@@ -93,8 +119,17 @@
-
- .sh:
- @RM@ -f $@ $@-t
-+ bin_REPLACE='';\
-+ list='$(EXTRA_SCRIPTS) $(EXTRA_REPLACE_BIN)'; \
-+ for p in $${list}; do \
-+ f1=$${p/\.sh}; \
-+ f2=`echo "$${p}" | @SED@ -e 's|\.sh$$||' -e 's|^.*/||;$(transform)'`; \
-+ bin_REPLACE="$${bin_REPLACE}s!@mybin_$${f1}@!$${f2}!g;";\
-+ done; \
- @SED@ \
-+ -e "$${bin_REPLACE}" \
- -e 's!@''bindir''@!$(bindir)!g' \
-+ -e 's!@''sharedstatedir''@!$(sharedstatedir)!g' \
- -e 's!@''sbindir''@!$(sbindir)!g' \
- -e 's!@''scriptdir''@!$(bindir)!g' \
- -e 's!@''prefix''@!$(prefix)!g' \
-diff -Naur -Naur mysqlold/scripts/msql2mysql.sh mysql/scripts/msql2mysql.sh
---- mysqlold/scripts/msql2mysql.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/msql2mysql.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -13,4 +13,4 @@
- # described in the License. Among other things, the License requires that
- # the copyright notice and this notice be preserved on all copies.
-
--@bindir@/replace msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-+@bindir@/@mybin_replace@ msqlConnect mysql_connect msqlListDBs mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*
-diff -Naur -Naur mysqlold/scripts/mysqlaccess.sh mysql/scripts/mysqlaccess.sh
---- mysqlold/scripts/mysqlaccess.sh 2006-12-11 22:21:19.000000000 +0000
-+++ mysql/scripts/mysqlaccess.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -17,7 +17,7 @@
-
- # ****************************
- # information on MySQL
-- $MYSQL = '@bindir@/mysql'; # path to mysql executable
-+ $MYSQL = '@bindir@/@mybin_mysql@'; # path to mysql executable
- $SERVER = '3.21';
- $MYSQL_OPT = ' --batch --unbuffered';
- $ACCESS_DB = 'mysql'; # name of DB with grant-tables
-@@ -32,7 +32,7 @@
- $ACCESS_U_BCK = 'user_backup';
- $ACCESS_D_BCK = 'db_backup';
- $DIFF = '/usr/bin/diff';
-- $MYSQLDUMP = '@bindir@/mysqldump';
-+ $MYSQLDUMP = '@bindir@/@mybin_mysqldump@';
- #path to mysqldump executable
-
- $MYSQLADMIN= 'http://foobar.com/MySQLadmin';
-diff -Naur -Naur mysqlold/scripts/mysql_config.sh mysql/scripts/mysql_config.sh
---- mysqlold/scripts/mysql_config.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/mysql_config.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -77,7 +77,7 @@
-
- me=`get_full_path $0`
-
--basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
-+basedir=`echo $me | sed -e 's;/bin/@mybin_mysql_config@;;'`
-
- ldata='@localstatedir@'
- execdir='@libexecdir@'
-@@ -86,10 +86,10 @@
- # If installed, search for the compiled in directory first (might be "lib64")
- pkglibdir='@pkglibdir@'
- pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
--fix_path pkglibdir $pkglibdir_rel lib/mysql lib
-+fix_path pkglibdir $pkglibdir_rel "lib${pkglibdir##*lib}" lib/mysql lib
-
- pkgincludedir='@pkgincludedir@'
--fix_path pkgincludedir include/mysql include
-+fix_path pkgincludedir "include${pkgincludedir##*include}" include/mysql include
-
- version='@VERSION@'
- socket='@MYSQL_UNIX_ADDR@'
-diff -Naur -Naur mysqlold/scripts/mysql_create_system_tables.sh mysql/scripts/mysql_create_system_tables.sh
---- mysqlold/scripts/mysql_create_system_tables.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/mysql_create_system_tables.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -19,7 +19,7 @@
- new context from the manual (from fill_help_tables.sql).
-
- Usage:
-- mysql_create_system_tables [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
-+ @mybin_mysql_create_system_tables@ [test|verbose|real] <path to mysql-database directory> <hostname> <windows option>
- "
- exit
- fi
-diff -Naur -Naur mysqlold/scripts/mysqld_multi.sh mysql/scripts/mysqld_multi.sh
---- mysqlold/scripts/mysqld_multi.sh 2006-12-11 22:21:19.000000000 +0000
-+++ mysql/scripts/mysqld_multi.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -10,8 +10,8 @@
- $opt_example = 0;
- $opt_help = 0;
- $opt_log = undef();
--$opt_mysqladmin = "@bindir@/mysqladmin";
--$opt_mysqld = "@libexecdir@/mysqld";
-+$opt_mysqladmin = "@bindir@/@mybin_mysqladmin@";
-+$opt_mysqld = "@libexecdir@/@mybin_mysqld@";
- $opt_no_log = 0;
- $opt_password = undef();
- $opt_tcp_ip = 0;
-@@ -39,11 +39,11 @@
- {
- my $flag_exit= 0;
-
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
- # We can't throw out yet, since --version, --help, or --example may
- # have been given
-- print "WARNING: my_print_defaults command not found.\n";
-+ print "WARNING: @mybin_my_print_defaults@ command not found.\n";
- print "Please make sure you have this command available and\n";
- print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
-@@ -74,9 +74,9 @@
- }
- }
- }
-- my $com= "my_print_defaults ";
-+ my $com= "@mybin_my_print_defaults@ ";
- $com.= "--config-file=$opt_config_file " if (defined($opt_config_file));
-- $com.= "mysqld_multi";
-+ $com.= "@mybin_mysqld_multi@";
- my @defops = `$com`;
- chop @defops;
- splice @ARGV, 0, 0, @defops;
-@@ -113,9 +113,9 @@
- print "Error with an option, see $my_progname --help for more info.\n";
- exit(1);
- }
-- if (!defined(my_which(my_print_defaults)))
-+ if (!defined(my_which(@mybin_my_print_defaults@)))
- {
-- print "ABORT: Can't find command 'my_print_defaults'.\n";
-+ print "ABORT: Can't find command '@mybin_my_print_defaults@'.\n";
- print "This command is available from the latest MySQL\n";
- print "distribution. Please make sure you have the command\n";
- print "in your PATH.\n";
-@@ -202,7 +202,7 @@
- {
- if ($my_print_defaults_exists)
- {
-- @mysqld_opts= `my_print_defaults mysqld`;
-+ @mysqld_opts= `@mybin_my_print_defaults@ mysqld`;
- chomp @mysqld_opts;
- foreach my $opt (@mysqld_opts)
- {
-@@ -303,7 +303,7 @@
- @groups = &find_groups($groupids);
- for ($i = 0; defined($groups[$i]); $i++)
- {
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-@@ -330,7 +330,7 @@
- $tmp.= " $options[$j]";
- }
- }
-- if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
-+ if ($opt_verbose && $com =~ m/\/@mybin_safe_mysqld@$/ && !$info_sent)
- {
- print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
- print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-@@ -401,7 +401,7 @@
- my ($i, @groups)= @_;
- my ($mysqladmin_found, $com, $tmp, $j);
-
-- $com = "my_print_defaults";
-+ $com = "@mybin_my_print_defaults@";
- $com.= defined($opt_config_file) ? " --config-file=$opt_config_file" : "";
- $com.= " $groups[$i]";
- @options = `$com`;
-diff -Naur -Naur mysqlold/scripts/mysqld_safe.sh mysql/scripts/mysqld_safe.sh
---- mysqlold/scripts/mysqld_safe.sh 2006-12-11 22:21:19.000000000 +0000
-+++ mysql/scripts/mysqld_safe.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -91,7 +91,7 @@
- then
- MYSQLD="mysqld-$tmp"
- else
-- MYSQLD="mysqld"
-+ MYSQLD="@mybin_mysqld@"
- fi
- ;;
- --nice=*) niceness=`echo "$arg" | sed -e "s;--nice=;;"` ;;
-@@ -115,13 +115,13 @@
-
- MY_PWD=`pwd`
- # Check for the directories we would expect from a binary release install
--if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-+if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
- # Check for the directories we would expect from a source install
- elif test -f ./share/mysql/english/errmsg.sys -a \
-- -x ./libexec/mysqld
-+ -x ./libexec/@mybin_mysqld@
- then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
-@@ -183,17 +183,17 @@
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- append_arg_to_args () {
-@@ -222,7 +222,7 @@
- # If the user doesn't specify a binary, we assume name "mysqld"
- if test -z "$MYSQLD"
- then
-- MYSQLD=mysqld
-+ MYSQLD=@mybin_mysqld@
- fi
-
- if test ! -x $ledir/$MYSQLD
-@@ -230,7 +230,7 @@
- echo "The file $ledir/$MYSQLD doesn't exist or is not executable"
- echo "Please do a cd to the mysql installation directory and restart"
- echo "this script from there as follows:"
-- echo "./bin/mysqld_safe".
-+ echo "./bin/@mybin_mysqld_safe@".
- echo "See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
- echo "information"
- exit 1
-@@ -390,8 +390,8 @@
- # the manual for details.
- #
- # echo "Checking tables in $DATADIR"
--# $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
--# $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
-+# $MY_BASEDIR_VERSION/bin/@mybin_myisamchk@ --silent --force --fast --medium-check $DATADIR/*/*.MYI
-+# $MY_BASEDIR_VERSION/bin/@mybin_isamchk@ --silent --force $DATADIR/*/*.ISM
-
- echo "Starting $MYSQLD daemon with databases from $DATADIR"
-
-diff -Naur -Naur mysqlold/scripts/mysqldumpslow.sh mysql/scripts/mysqldumpslow.sh
---- mysqlold/scripts/mysqldumpslow.sh 2006-12-11 22:21:19.000000000 +0000
-+++ mysql/scripts/mysqldumpslow.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -34,16 +34,16 @@
- $opt{'help'} and usage();
-
- unless (@ARGV) {
-- my $defaults = `my_print_defaults mysqld`;
-+ my $defaults = `@mybin_my_print_defaults@ mysqld`;
- my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
-- or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
-+ or die "Can't determine basedir from '@mybin_my_print_defaults@ mysqld' output: $defaults";
- warn "basedir=$basedir\n" if $opt{v};
-
- my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
- if (!$datadir or $opt{i}) {
- # determine the datadir from the instances section of /etc/my.cnf, if any
-- my $instances = `my_print_defaults instances`;
-- die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
-+ my $instances = `@mybin_my_print_defaults@ instances`;
-+ die "Can't determine datadir from '@mybin_my_print_defaults@ mysqld' output: $defaults"
- unless $instances;
- my @instances = ($instances =~ m/^--(\w+)-/mg);
- die "No -i 'instance_name' specified to select among known instances: @instances.\n"
-@@ -51,7 +51,7 @@
- die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
- unless grep { $_ eq $opt{i} } @instances;
- $datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
-- or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
-+ or die "Can't determine --$opt{i}-datadir from '@mybin_my_print_defaults@ instances' output: $instances";
- warn "datadir=$datadir\n" if $opt{v};
- }
-
-diff -Naur -Naur mysqlold/scripts/mysql_fix_privilege_tables.sh mysql/scripts/mysql_fix_privilege_tables.sh
---- mysqlold/scripts/mysql_fix_privilege_tables.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/mysql_fix_privilege_tables.sh 2006-12-11 22:27:58.000000000 +0000
-@@ -77,17 +77,17 @@
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
-
--print_defaults=my_print_defaults
-+print_defaults=@mybin_my_print_defaults@
- for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
- do
-- if test -x $dir/my_print_defaults
-+ if test -x $dir/@mybin_my_print_defaults@
- then
-- print_defaults="$dir/my_print_defaults"
-+ print_defaults="$dir/@mybin_my_print_defaults@"
- break
- fi
- done
-
--parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-+parse_arguments `$print_defaults $defaults @mybin_mysql_install_db@ @mybin_mysql_fix_privilege_tables@`
- parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
- if test -z "$password"
-@@ -118,7 +118,7 @@
- exit 1
- fi
-
--cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host"
-+cmd="$bindir/@mybin_mysql@ --no-defaults --force --user=$user --host=$host"
- if test ! -z "$port"; then
- cmd="$cmd --port=$port"
- fi
-@@ -133,7 +133,7 @@
- fi
-
- # Find where first mysql_fix_privilege_tables.sql is located
--for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+for i in @sharedstatedir@ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
- do
- if test -f $i/$file
-diff -Naur -Naur mysqlold/scripts/mysql_install_db.sh mysql/scripts/mysql_install_db.sh
---- mysqlold/scripts/mysql_install_db.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/mysql_install_db.sh 2006-12-11 22:30:43.000000000 +0000
-@@ -58,20 +58,20 @@
-
- # Get first arguments from the my.cfg file, groups [mysqld] and
- # [mysql_install_db], and then merge with the command line arguments
--if test -x ./bin/my_print_defaults
-+if test -x "./bin/@mybin_my_print_defaults@"
- then
-- print_defaults="./bin/my_print_defaults"
--elif test -x ./extra/my_print_defaults
-+ print_defaults="./bin/@mybin_my_print_defaults@"
-+elif test -x "./extra/@mybin_my_print_defaults@"
- then
-- print_defaults="./extra/my_print_defaults"
--elif test -x @bindir@/my_print_defaults
-+ print_defaults="./extra/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/my_print_defaults"
--elif test -x @bindir@/mysql_print_defaults
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
-+elif test -x "@bindir@/@mybin_my_print_defaults@"
- then
-- print_defaults="@bindir@/mysql_print_defaults"
-+ print_defaults="@bindir@/@mybin_my_print_defaults@"
- else
-- print_defaults="my_print_defaults"
-+ print_defaults="@mybin_my_print_defaults@"
- fi
-
- args=
-@@ -96,10 +96,10 @@
- pkgdatadir=@pkgdatadir@
- else
- bindir="$basedir/bin"
-- if test -x "$basedir/libexec/mysqld"
-+ if test -x "$basedir/libexec/@mybin_mysqld@"
- then
- execdir="$basedir/libexec"
-- elif test -x "$basedir/sbin/mysqld"
-+ elif test -x "$basedir/sbin/@mybin_mysqld@"
- then
- execdir="$basedir/sbin"
- else
-@@ -112,7 +112,8 @@
- then
- fill_help_tables=$srcdir/scripts/fill_help_tables.sql
- else
-- for i in $basedir/support-files $basedir/share $basedir/share/mysql \
-+ for i in @sharedstatedir@ \
-+ $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
- do
- if test -f $i/fill_help_tables.sql
-@@ -131,13 +132,13 @@
- fi
-
- mdata=$ldata/mysql
--mysqld=$execdir/mysqld
-+mysqld=$execdir/@mybin_mysqld@
- mysqld_opt=""
- scriptdir=$bindir
-
- if test "$windows" = 1
- then
-- mysqld="./sql/mysqld"
-+ mysqld="./sql/@mybin_mysqld@"
- if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys
- then
- langdir=$srcdir/sql/share/english
-@@ -167,14 +168,14 @@
- # Check if hostname is valid
- if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0
- then
-- resolved=`$bindir/resolveip $hostname 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ $hostname 2>&1`
- if [ $? -ne 0 ]
- then
-- resolved=`$bindir/resolveip localhost 2>&1`
-+ resolved=`$bindir/@mybin_resolveip@ localhost 2>&1`
- if [ $? -ne 0 ]
- then
- echo "Neither host '$hostname' nor 'localhost' could be looked up with"
-- echo "$bindir/resolveip"
-+ echo "$bindir/@mybin_resolveip@"
- echo "Please configure the 'hostname' command to return a correct hostname."
- echo "If you want to solve this at a later stage, restart this script with"
- echo "the --force option"
-@@ -182,7 +183,7 @@
- fi
- echo "WARNING: The host '$hostname' could not be looked up with resolveip."
- echo "This probably means that your libc libraries are not 100 % compatible"
-- echo "with this binary MySQL version. The MySQL daemon, mysqld, should work"
-+ echo "with this binary MySQL version. The MySQL daemon, @mybin_mysqld@, should work"
- echo "normally with the exception that host name resolving will not work."
- echo "This means that you should use IP addresses instead of hostnames"
- echo "when specifying MySQL privileges !"
-@@ -227,7 +228,7 @@
- mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \
- --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \
- --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \
-+if $scriptdir/@mybin_mysql_create_system_tables@ $create_option $mdata $hostname $windows \
- | eval "$mysqld_install_cmd_line"
- then
- if test -n "$fill_help_tables"
-@@ -257,8 +258,8 @@
- then
- echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
- echo "To do so, start the server, then issue the following commands:"
-- echo "$bindir/mysqladmin -u root password 'new-password'"
-- echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root password 'new-password'"
-+ echo "$bindir/@mybin_mysqladmin@ -u root -h $hostname password 'new-password'"
- echo "See the manual for more instructions."
- #
- # Print message about upgrading unless we have created a new db table.
-@@ -266,14 +267,14 @@
- then
- echo
- echo "NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run"
-- echo "the $bindir/mysql_fix_privilege_tables. Otherwise you will not be"
-+ echo "the $bindir/@mybin_mysql_fix_privilege_tables@. Otherwise you will not be"
- echo "able to use the new GRANT command!"
- fi
- echo
- if test "$in_rpm" = "0"
- then
- echo "You can start the MySQL daemon with:"
-- echo "cd @prefix@ ; $bindir/mysqld_safe &"
-+ echo "cd @prefix@ ; $bindir/@mybin_mysqld_safe@ &"
- echo
- fi
- echo "Please report any problems with the @scriptdir@/mysqlbug script!"
-@@ -290,13 +291,13 @@
- echo "You can also try to start the mysqld daemon with:"
- echo "$mysqld --skip-grant &"
- echo "You can use the command line tool"
-- echo "$bindir/mysql to connect to the mysql"
-+ echo "$bindir/@mybin_mysql@ to connect to the mysql"
- echo "database and look at the grant tables:"
- echo
-- echo "shell> $bindir/mysql -u root mysql"
-+ echo "shell> $bindir/@mybin_mysql@ -u root mysql"
- echo "mysql> show tables"
- echo
-- echo "Try 'mysqld --help' if you have problems with paths. Using --log"
-+ echo "Try '@mybin_mysqld@ --help' if you have problems with paths. Using --log"
- echo "gives you a log in $ldata that may be helpful."
- echo
- echo "The latest information about MySQL is available on the web at"
-@@ -305,6 +306,6 @@
- echo "and the manual section that describes problems on your OS."
- echo "Another information source is the MySQL email archive."
- echo "Please check all of the above before mailing us!"
-- echo "And if you do mail us, you MUST use the @scriptdir@/mysqlbug script!"
-+ echo "And if you do mail us, you MUST use the @scriptdir@/@mybin_mysqlbug@ script!"
- exit 1
- fi
-diff -Naur -Naur mysqlold/scripts/mysql_secure_installation.sh mysql/scripts/mysql_secure_installation.sh
---- mysqlold/scripts/mysql_secure_installation.sh 2006-12-11 22:21:18.000000000 +0000
-+++ mysql/scripts/mysql_secure_installation.sh 2006-12-11 22:25:49.000000000 +0000
-@@ -30,7 +30,7 @@
-
- do_query() {
- echo $1 >$command
-- mysql --defaults-file=$config <$command
-+ @mybin_mysql@ --defaults-file=$config <$command
- return $?
- }
-
diff --git a/00810_all_slot_manager-5.0.19.patch b/00810_all_slot_manager-5.0.19.patch
deleted file mode 100644
index a55175e..0000000
--- a/00810_all_slot_manager-5.0.19.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- mysql-5.0.19.orig/server-tools/instance-manager/Makefile.am 2006-03-04 20:34:51.000000000 +0000
-+++ mysql-5.0.19.new/server-tools/instance-manager/Makefile.am 2006-03-24 17:54:43.000000000 +0000
-@@ -28,12 +28,12 @@
- noinst_LIBRARIES= libnet.a
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
-- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-- -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \
-- -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \
-- -DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \
-+ -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.pid" \
-+ -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.log" \
-+ -DDEFAULT_SOCKET_FILE_NAME="/@GENTOO_SOCK_PATH@/mysqlmanager@GENTOO_EXT@.sock" \
-+ -DDEFAULT_PASSWORD_FILE_NAME="/$(sysconfdir)/mysqlmanager.passwd" \
- -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
-- -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
-+ -DDEFAULT_CONFIG_FILE="/$(sysconfdir)/my.cnf" \
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
diff --git a/00810_all_slot_manager-5.1.10.patch b/00810_all_slot_manager-5.1.10.patch
deleted file mode 100644
index 756252b..0000000
--- a/00810_all_slot_manager-5.1.10.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -Naur mysql-5.1.10-beta-nightly-20060410.a/server-tools/instance-manager/Makefile.am mysql-5.1.10-beta-nightly-20060410.b/server-tools/instance-manager/Makefile.am
---- mysql-5.1.10-beta-nightly-20060410.a/server-tools/instance-manager/Makefile.am 2006-04-10 04:27:45.000000000 +0000
-+++ mysql-5.1.10-beta-nightly-20060410.b/server-tools/instance-manager/Makefile.am 2006-04-12 17:21:28.000000000 +0000
-@@ -28,12 +28,12 @@
- noinst_LIBRARIES= libnet.a
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
-- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-- -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \
-- -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \
-+ -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.pid" \
-+ -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.log" \
-+ -DDEFAULT_SOCKET_FILE_NAME="/@GENTOO_SOCK_PATH@/mysqlmanager@GENTOO_EXT@.sock" \
- -DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \
-- -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
-- -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
-+ -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld@GENTOO_EXT@$(EXEEXT)" \
-+ -DDEFAULT_CONFIG_FILE="/etc/mysql@GENTOO_EXT@/my.cnf" \
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
diff --git a/00810_all_slot_manager-5.1.7.patch b/00810_all_slot_manager-5.1.7.patch
deleted file mode 100644
index 9cf3dec..0000000
--- a/00810_all_slot_manager-5.1.7.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- mysql-5.1.7-beta.orig/server-tools/instance-manager/Makefile.am 2006-02-27 21:24:53.000000000 +0000
-+++ mysql-5.1.7-beta.new/server-tools/instance-manager/Makefile.am 2006-03-24 17:45:15.000000000 +0000
-@@ -27,12 +27,12 @@
- noinst_LIBRARIES= liboptions.a libnet.a
-
- liboptions_a_CXXFLAGS= $(CXXFLAGS) \
-- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-- -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \
-- -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \
-- -DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \
-- -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
-- -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
-+ -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.pid" \
-+ -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager@GENTOO_EXT@.log" \
-+ -DDEFAULT_SOCKET_FILE_NAME="/@GENTOO_SOCK_PATH@/mysqlmanager@GENTOO_EXT@.sock" \
-+ -DDEFAULT_PASSWORD_FILE_NAME="/$(sysconfdir)/mysqlmanager.passwd" \
-+ -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld@GENTOO_EXT@$(EXEEXT)" \
-+ -DDEFAULT_CONFIG_FILE="/$(sysconfdir)/my.cnf" \
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_a_SOURCES= options.h options.cc priv.h priv.cc
diff --git a/01000_all_bug23427-abi-breakage-5.0.26.patch b/01000_all_bug23427-abi-breakage-5.0.26.patch
deleted file mode 100644
index 26d6eed..0000000
--- a/01000_all_bug23427-abi-breakage-5.0.26.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From: Chad&nbsp;MILLERDate: October 20 2006 11:17pm
-Subject: bk commit into 5.0 tree (cmiller:1.2292) BUG#23427
-
-ChangeSet@stripped, 2006-10-20 17:17:24-04:00, cmiller@stripped +2 -0
- Bug #23427: incompatible ABI change in 5.0.26?
-
- Revert 1 June change enough to restore ABI compatibility with previous
- versions.
-
- include/mysql.h@stripped, 2006-10-20 17:17:22-04:00, cmiller@stripped +0 -6
- Revert patch that breaks ABI compatibility
-
- libmysqld/lib_sql.cc@stripped, 2006-10-20 17:17:22-04:00, cmiller@stripped +0 -1
- Remove useless assignment.
-
-Thanks to Sean Finney for discovering this (Debian MySQL maintainer).
-
---- 1.162/include/mysql.h 2006-10-20 17:17:28 -04:00
-+++ 1.163/include/mysql.h 2006-10-20 17:17:28 -04:00
-@@ -293,12 +293,6 @@ typedef struct st_mysql
- /* needed for embedded server - no net buffer to store the 'info' */
- char *info_buffer;
- #endif
-- /*
-- In embedded server it points to the statement that is processed
-- in the current query. We store some results directly in statement
-- fields then.
-- */
-- struct st_mysql_stmt *current_stmt;
- } MYSQL;
-
- typedef struct st_mysql_res {
-
---- 1.114/libmysqld/lib_sql.cc 2006-10-20 17:17:28 -04:00
-+++ 1.115/libmysqld/lib_sql.cc 2006-10-20 17:17:28 -04:00
-@@ -100,7 +100,6 @@ emb_advanced_command(MYSQL *mysql, enum
- mysql->affected_rows= ~(my_ulonglong) 0;
- mysql->field_count= 0;
- net->last_errno= 0;
-- mysql->current_stmt= stmt;
-
- thd->store_globals(); // Fix if more than one connect
- /*
diff --git a/01010_all_bootstrap_no_plugin.patch b/01010_all_bootstrap_no_plugin.patch
deleted file mode 100644
index de9258c..0000000
--- a/01010_all_bootstrap_no_plugin.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From: antony at mysql dot com
-Date: December 6 2006 8:27pm
-Subject: bk commit into 5.1 tree (antony:1.2325) BUG#24270
-
-Below is the list of changes that have just been committed into a local
-5.1 repository of antony. When antony does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2006-12-06 11:27:13-08:00, antony@stripped +1 -0
- Bug#24270
- "mysql_install_db doesn't work properly on 5.1"
- force default sql mode when in bootstrap. prevents entries in my.cnf
- from breaking the 'install'
-
- sql/mysqld.cc@stripped, 2006-12-06 11:27:10-08:00, antony@stripped +2 -0
- force default sql mode when in bootstrap. prevents entries in my.cnf
- from breaking the 'install'
-
-# This is a BitKeeper patch. What follows are the unified diffs for the
-# set of deltas contained in the patch. The rest of the patch, the part
-# that BitKeeper cares about, is below these diffs.
-# User: antony
-# Host: ppcg5.local
-# Root: /Users/antony/Work/p2-bug24270.1
-
---- 1.583/sql/mysqld.cc 2006-12-06 11:27:21 -08:00
-+++ 1.584/sql/mysqld.cc 2006-12-06 11:27:21 -08:00
-@@ -3640,6 +3640,8 @@
-
- if (opt_bootstrap)
- {
-+ global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
-+ global_system_variables.sql_mode= fix_sql_mode(0);
- select_thread_in_use= 0; // Allow 'kill' to work
- bootstrap(stdin);
- end_thr_alarm(1); // Don't allow alarms
diff --git a/02000_all_query-logging-bypass-5.0.21.patch b/02000_all_query-logging-bypass-5.0.21.patch
deleted file mode 100644
index 1af6175..0000000
--- a/02000_all_query-logging-bypass-5.0.21.patch
+++ /dev/null
@@ -1,208 +0,0 @@
-diff -Nru mysql-5.0.19/sql/sql_lex.cc mysql-5.0.19-logsec/sql/sql_lex.cc
---- mysql-5.0.19/sql/sql_lex.cc 2006-03-04 21:35:19.000000000 +0100
-+++ mysql-5.0.19-logsec/sql/sql_lex.cc 2006-04-07 22:33:16.000000000 +0200
-@@ -958,6 +958,9 @@
- while (lex->ptr != lex->end_of_query &&
- ((c=yyGet()) != '*' || yyPeek() != '/'))
- {
-+ if (c == '\0')
-+ return(ABORT_SYM); // NULLs illegal even in comments
-+
- if (c == '\n')
- lex->yylineno++;
- }
-diff -Naur -Naur mysql-5.0.19.orig/include/my_sys.h mysql-5.0.19.new/include/my_sys.h
---- mysql-5.0.19.orig/include/my_sys.h 2006-03-04 20:35:12.000000000 +0000
-+++ mysql-5.0.19.new/include/my_sys.h 2006-04-09 17:55:53.000000000 +0000
-@@ -599,6 +599,11 @@
- const char *sFile, uint uLine,
- myf MyFlag);
-
-+/* implemented in my_memmem.c */
-+extern void *my_memmem(const void *haystack, size_t haystacklen,
-+ const void *needle, size_t needlelen);
-+
-+
- #ifdef __WIN__
- extern int my_access(const char *path, int amode);
- extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
-diff -Naur -Naur mysql-5.0.19.orig/mysys/mf_iocache2.c mysql-5.0.19.new/mysys/mf_iocache2.c
---- mysql-5.0.19.orig/mysys/mf_iocache2.c 2006-03-04 20:34:51.000000000 +0000
-+++ mysql-5.0.19.new/mysys/mf_iocache2.c 2006-04-09 17:55:53.000000000 +0000
-@@ -252,6 +252,10 @@
- uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
- {
- uint out_length=0;
-+ uint minimum_width; /* as yet unimplemented */
-+ uint minimum_width_sign;
-+ uint precision; /* as yet unimplemented for anything but %b */
-+ const char* backtrack;
-
- for (; *fmt ; fmt++)
- {
-@@ -272,17 +276,53 @@
- fmt++;
- /* Found one '%' */
- }
-+ backtrack= fmt;
-+
-+ minimum_width= 0;
-+ precision= 0;
-+ minimum_width_sign= 1;
- /* Skip if max size is used (to be compatible with printf) */
-- while (my_isdigit(&my_charset_latin1, *fmt) || *fmt == '.' || *fmt == '-')
-+ while (*fmt == '-') { fmt++; minimum_width_sign= -1; }
-+ if (*fmt == '*') {
-+ precision= (int) va_arg(args, int);
-+ fmt++;
-+ } else {
-+ while (my_isdigit(&my_charset_latin1, *fmt)) {
-+ minimum_width=(minimum_width * 10) + (*fmt - '0');
-+ fmt++;
-+ }
-+ }
-+ minimum_width*= minimum_width_sign;
-+
-+ if (*fmt == '.') {
- fmt++;
-+ if (*fmt == '*') {
-+ precision= (int) va_arg(args, int);
-+ fmt++;
-+ } else {
-+ while (my_isdigit(&my_charset_latin1, *fmt)) {
-+ precision=(precision * 10) + (*fmt - '0');
-+ fmt++;
-+ }
-+ }
-+ }
-+
- if (*fmt == 's') /* String parameter */
- {
- reg2 char *par = va_arg(args, char *);
- uint length = (uint) strlen(par);
-+ /* TODO: implement minimum width and precision */
- out_length+=length;
- if (my_b_write(info, par, length))
- goto err;
- }
-+ else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
-+ {
-+ reg2 char *par = va_arg(args, char *);
-+ out_length+=precision;
-+ if (my_b_write(info, par, precision))
-+ goto err;
-+ }
- else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
- {
- register int iarg;
-@@ -320,6 +360,9 @@
- if (my_b_write(info, "%", 1))
- goto err;
- out_length++;
-+ if (my_b_write(info, backtrack, fmt-backtrack))
-+ goto err;
-+ out_length+= fmt-backtrack;
- }
- }
- return out_length;
-diff -Naur -Naur mysql-5.0.19.orig/mysys/my_memmem.c mysql-5.0.19.new/mysys/my_memmem.c
---- mysql-5.0.19.orig/mysys/my_memmem.c 1970-01-01 00:00:00.000000000 +0000
-+++ mysql-5.0.19.new/mysys/my_memmem.c 2006-04-09 17:56:16.000000000 +0000
-@@ -0,0 +1,21 @@
-+#include "my_base.h"
-+
-+/*
-+ * my_memmem, port of a GNU extension.
-+ *
-+ * Returns a pointer to the beginning of the substring, needle, or NULL if the
-+ * substring is not found in haystack.
-+ * */
-+void *my_memmem(const void *haystack, size_t haystacklen,
-+ const void *needle, size_t needlelen)
-+{
-+ const void *cursor;
-+ const void *end_of_search_beginning = haystack + haystacklen - needlelen;
-+
-+ for (cursor = haystack; cursor <= end_of_search_beginning; cursor++) {
-+ if (memcmp(needle, cursor, needlelen) == 0) {
-+ return((void *) cursor);
-+ }
-+ }
-+ return(NULL);
-+}
-diff -Naur -Naur mysql-5.0.19.orig/sql/sql_parse.cc mysql-5.0.19.new/sql/sql_parse.cc
---- mysql-5.0.19.orig/sql/sql_parse.cc 2006-03-04 20:34:48.000000000 +0000
-+++ mysql-5.0.19.new/sql/sql_parse.cc 2006-04-09 17:55:53.000000000 +0000
-@@ -1710,7 +1710,7 @@
- if (alloc_query(thd, packet, packet_length))
- break; // fatal error is set
- char *packet_end= thd->query + thd->query_length;
-- mysql_log.write(thd,command,"%s",thd->query);
-+ mysql_log.write(thd,command, "%.*b", thd->query_length, thd->query);
- DBUG_PRINT("query",("%-.4096s",thd->query));
-
- if (!(specialflag & SPECIAL_NO_PRIOR))
-diff -Naur -Naur mysql-5.0.19.orig/strings/my_vsnprintf.c mysql-5.0.19.new/strings/my_vsnprintf.c
---- mysql-5.0.19.orig/strings/my_vsnprintf.c 2006-03-04 20:34:49.000000000 +0000
-+++ mysql-5.0.19.new/strings/my_vsnprintf.c 2006-04-09 17:55:53.000000000 +0000
-@@ -27,6 +27,7 @@
- %#[l]d
- %#[l]u
- %#[l]x
-+ %#.#b Local format; note first # is ignored and second is REQUIRED
- %#.#s Note first # is ignored
-
- RETURN
-@@ -38,9 +39,18 @@
- char *start=to, *end=to+n-1;
- uint length, width, pre_zero, have_long;
-
-+ const char *backtrack;
-+ /*
-+ For the special case when we discover that we shouldn't have been
-+ interpreting a percent-format.
-+
-+ This is here so we can be forgiving about our special local formats.
-+ */
-+
- for (; *fmt ; fmt++)
- {
-- if (fmt[0] != '%')
-+ backtrack = fmt;
-+ if (*fmt != '%')
- {
- if (to == end) /* End of buffer */
- break;
-@@ -95,6 +105,12 @@
- to=strnmov(to,par,plen);
- continue;
- }
-+ else if (*fmt == 'b') /* Buffer parameter */
-+ {
-+ reg2 char *par = va_arg(ap, char *);
-+ to=memmove(to, par, abs(width));
-+ continue;
-+ }
- else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */
- {
- register long larg;
---- mysql-5.0.19.orig/mysys/Makefile.am 2006-04-17 21:33:44.000000000 +0200
-+++ mysql-5.0.19.new/mysys/Makefile.am 2006-04-17 21:36:16.000000000 +0200
-@@ -55,6 +55,7 @@
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
-+ my_memmem.c \
- my_windac.c my_access.c base64.c
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c
---- mysql-5.0.19.orig/mysys/Makefile.in 2006-04-17 21:36:59.000000000 +0200
-+++ mysql-5.0.19.new/mysys/Makefile.in 2006-04-17 21:37:52.000000000 +0200
-@@ -514,6 +514,7 @@
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
-+ my_memmem.c \
- my_windac.c my_access.c base64.c
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
diff --git a/02020_all_embedded-library-compile-5.0.38.patch b/02020_all_embedded-library-compile-5.0.38.patch
deleted file mode 100644
index e486614..0000000
--- a/02020_all_embedded-library-compile-5.0.38.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff -Nuar --exclude '*~' mysql.old/libmysqld/sql_parse.cc mysql/libmysqld/sql_parse.cc
---- mysql.old/libmysqld/sql_parse.cc 2007-03-20 11:12:46.000000000 -0800
-+++ mysql/libmysqld/sql_parse.cc 2007-04-15 01:25:22.240914696 -0700
-@@ -5405,9 +5405,7 @@
- {
- uint found=0;
- ulong found_access=0;
--#ifndef EMBEDDED_LIBRARY
- TABLE_LIST *org_tables= tables;
--#endif
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
-diff -Nuar --exclude '*~' mysql.old/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.old/sql/sql_parse.cc 2007-03-20 11:12:46.000000000 -0800
-+++ mysql/sql/sql_parse.cc 2007-04-15 01:25:15.065857026 -0700
-@@ -5405,9 +5405,7 @@
- {
- uint found=0;
- ulong found_access=0;
--#ifndef EMBEDDED_LIBRARY
- TABLE_LIST *org_tables= tables;
--#endif
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
diff --git a/02040_all_embedded-library-shared-5.0.76.patch b/02040_all_embedded-library-shared-5.0.76.patch
deleted file mode 100644
index 6581efc..0000000
--- a/02040_all_embedded-library-shared-5.0.76.patch
+++ /dev/null
@@ -1,1539 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-
-diff -ur mysql-5.0.76-old/client/Makefile.am mysql-5.0.76/client/Makefile.am
---- mysql-5.0.76-old/client/Makefile.am 2009-01-15 16:44:51.000000000 -0100
-+++ mysql-5.0.76/client/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -37,7 +37,7 @@
- $(top_srcdir)/mysys/my_copy.c \
- $(top_srcdir)/mysys/my_mkdir.c
-
--mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
-+mysqltest_LDADD = $(top_builddir)/regex/libregex.la $(LDADD)
- mysqlbinlog_SOURCES = mysqlbinlog.cc \
- $(top_srcdir)/mysys/mf_tempdir.c \
- $(top_srcdir)/mysys/my_new.cc
-diff -ur mysql-5.0.76-old/config/ac-macros/ha_innodb.m4 mysql-5.0.76/config/ac-macros/ha_innodb.m4
---- mysql-5.0.76-old/config/ac-macros/ha_innodb.m4 2009-01-15 16:44:57.000000000 -0100
-+++ mysql-5.0.76/config/ac-macros/ha_innodb.m4 2009-04-11 22:44:00.000000000 +0000
-@@ -25,40 +25,35 @@
- dnl Some libs are listed several times, in order for gcc to sort out
- dnl circular references.
- innodb_libs="\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/dict/libdict.a\
-- \$(top_builddir)/innobase/que/libque.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/row/librow.a\
-- \$(top_builddir)/innobase/pars/libpars.a\
-- \$(top_builddir)/innobase/btr/libbtr.a\
-- \$(top_builddir)/innobase/trx/libtrx.a\
-- \$(top_builddir)/innobase/read/libread.a\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/buf/libbuf.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/eval/libeval.a\
-- \$(top_builddir)/innobase/log/liblog.a\
-- \$(top_builddir)/innobase/fsp/libfsp.a\
-- \$(top_builddir)/innobase/fut/libfut.a\
-- \$(top_builddir)/innobase/fil/libfil.a\
-- \$(top_builddir)/innobase/lock/liblock.a\
-- \$(top_builddir)/innobase/mtr/libmtr.a\
-- \$(top_builddir)/innobase/page/libpage.a\
-- \$(top_builddir)/innobase/rem/librem.a\
-- \$(top_builddir)/innobase/thr/libthr.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/data/libdata.a\
-- \$(top_builddir)/innobase/mach/libmach.a\
-- \$(top_builddir)/innobase/ha/libha.a\
-- \$(top_builddir)/innobase/dyn/libdyn.a\
-- \$(top_builddir)/innobase/mem/libmem.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/ut/libut.a\
-- \$(top_builddir)/innobase/os/libos.a\
-- \$(top_builddir)/innobase/ut/libut.a"
-+ \$(top_builddir)/innobase/usr/libusr.la\
-+ \$(top_builddir)/innobase/srv/libsrv.la\
-+ \$(top_builddir)/innobase/dict/libdict.la\
-+ \$(top_builddir)/innobase/que/libque.la\
-+ \$(top_builddir)/innobase/ibuf/libibuf.la\
-+ \$(top_builddir)/innobase/row/librow.la\
-+ \$(top_builddir)/innobase/pars/libpars.la\
-+ \$(top_builddir)/innobase/btr/libbtr.la\
-+ \$(top_builddir)/innobase/trx/libtrx.la\
-+ \$(top_builddir)/innobase/read/libread.la\
-+ \$(top_builddir)/innobase/buf/libbuf.la\
-+ \$(top_builddir)/innobase/eval/libeval.la\
-+ \$(top_builddir)/innobase/log/liblog.la\
-+ \$(top_builddir)/innobase/fsp/libfsp.la\
-+ \$(top_builddir)/innobase/fut/libfut.la\
-+ \$(top_builddir)/innobase/fil/libfil.la\
-+ \$(top_builddir)/innobase/lock/liblock.la\
-+ \$(top_builddir)/innobase/mtr/libmtr.la\
-+ \$(top_builddir)/innobase/page/libpage.la\
-+ \$(top_builddir)/innobase/rem/librem.la\
-+ \$(top_builddir)/innobase/thr/libthr.la\
-+ \$(top_builddir)/innobase/sync/libsync.la\
-+ \$(top_builddir)/innobase/data/libdata.la\
-+ \$(top_builddir)/innobase/mach/libmach.la\
-+ \$(top_builddir)/innobase/ha/libha.la\
-+ \$(top_builddir)/innobase/dyn/libdyn.la\
-+ \$(top_builddir)/innobase/mem/libmem.la\
-+ \$(top_builddir)/innobase/ut/libut.la\
-+ \$(top_builddir)/innobase/os/libos.la"
-
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
- ;;
-diff -ur mysql-5.0.76-old/configure.in mysql-5.0.76/configure.in
---- mysql-5.0.76-old/configure.in 2009-01-15 16:44:57.000000000 -0100
-+++ mysql-5.0.76/configure.in 2009-04-11 22:44:00.000000000 +0000
-@@ -253,7 +253,7 @@
- fi
-
- # Still need ranlib for readline; local static use only so no libtool.
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- # We use libtool
- #AC_LIBTOOL_WIN32_DLL
- AC_PROG_LIBTOOL
-@@ -574,6 +574,9 @@
- # We need an ANSI C compiler
- AM_PROG_CC_STDC
-
-+# Testing as sugggested by Diego
-+AM_PROG_CC_C_O
-+
- # We need an assembler, too
- AM_PROG_AS
- CCASFLAGS="$CCASFLAGS $ASFLAGS"
-@@ -2692,9 +2695,9 @@
-
- if test "$THREAD_SAFE_CLIENT" = "no"
- then
-- sql_client_dirs="strings regex mysys dbug extra libmysql client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql client"
- else
-- sql_client_dirs="strings regex mysys dbug extra libmysql libmysql_r client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql libmysql_r client"
- linked_client_targets="$linked_client_targets linked_libmysql_r_sources"
- AC_CONFIG_FILES(libmysql_r/Makefile)
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
-@@ -2723,13 +2726,11 @@
- export CC CXX CFLAGS CXXFLAGS LD LDFLAGS AR
- ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'"
-
-+AM_CONDITIONAL([NEED_THREADS], [test x"$with_server" != xno -o x"$THREAD_SAFE_CLIENT" != xno])
- if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
-
- if test "$with_server" = "no"
-@@ -2737,7 +2738,7 @@
- AM_CONDITIONAL([BUILD_INNODB_TOOLS], [false])
- else
- server_scripts="mysqld_safe mysql_install_db"
-- sql_server_dirs="strings mysys dbug extra regex"
-+ sql_server_dirs="strings dbug mysys extra regex"
-
-
- #
-diff -ur mysql-5.0.76-old/dbug/Makefile.am mysql-5.0.76/dbug/Makefile.am
---- mysql-5.0.76-old/dbug/Makefile.am 2009-01-15 16:44:57.000000000 -0100
-+++ mysql-5.0.76/dbug/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
-+LDADD = ../mysys/libmysys.la ../strings/libmystrings.la
--pkglib_LIBRARIES = libdbug.a
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = example1.c example2.c example3.c \
- user.r monty.doc readme.prof dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-@@ -31,11 +30,11 @@
-
-
- # Must be linked with libs that are not compiled yet
--noinst_PROGRAMS = factorial dbug_analyze
-+EXTRA_PROGRAMS = factorial dbug_analyze
- factorial_SOURCES = my_main.c factorial.c
- dbug_analyze_SOURCES = dbug_analyze.c
-
--all: user.t user.ps
-+check-local: user.t user.ps
-
- user.t: user.r $(NROFF_INC)
- -nroff -mm user.r > $@
-diff -ur mysql-5.0.76-old/extra/Makefile.am mysql-5.0.76/extra/Makefile.am
---- mysql-5.0.76-old/extra/Makefile.am 2009-01-15 16:44:58.000000000 -0100
-+++ mysql-5.0.76/extra/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,8 +15,7 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- @ndbcluster_includes@ -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-diff -ur mysql-5.0.76-old/heap/Makefile.am mysql-5.0.76/heap/Makefile.am
---- mysql-5.0.76-old/heap/Makefile.am 2009-01-15 16:45:05.000000000 -0100
-+++ mysql-5.0.76/heap/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -14,14 +14,13 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libheap.a ../mysys/libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
--pkglib_LIBRARIES = libheap.a
-+LDADD = libheap.la ../mysys/libmysys.la
-+pkglib_LTLIBRARIES = libheap.la
- noinst_PROGRAMS = hp_test1 hp_test2
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
- noinst_HEADERS = heapdef.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
-diff -ur mysql-5.0.76-old/innobase/btr/Makefile.am mysql-5.0.76/innobase/btr/Makefile.am
---- mysql-5.0.76-old/innobase/btr/Makefile.am 2009-01-15 16:45:09.000000000 -0100
-+++ mysql-5.0.76/innobase/btr/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbtr.a
-+noinst_LTLIBRARIES = libbtr.la
-
--libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-+libbtr_la_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/buf/Makefile.am mysql-5.0.76/innobase/buf/Makefile.am
---- mysql-5.0.76-old/innobase/buf/Makefile.am 2009-01-15 16:45:09.000000000 -0100
-+++ mysql-5.0.76/innobase/buf/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbuf.a
-+noinst_LTLIBRARIES = libbuf.la
-
--libbuf_a_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-+libbuf_la_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/configure.in mysql-5.0.76/innobase/configure.in
---- mysql-5.0.76-old/innobase/configure.in 2009-01-15 16:45:09.000000000 -0100
-+++ mysql-5.0.76/innobase/configure.in 2009-04-11 22:44:00.000000000 +0000
-@@ -32,7 +32,7 @@
- CXXFLAGS="$CXXFLAGS "
-
- AC_PROG_CC
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- AC_PROG_INSTALL
- AC_PROG_LIBTOOL
- AC_CHECK_HEADERS(aio.h sched.h)
-@@ -126,14 +126,4 @@
- fi
- AC_SUBST(ARFLAGS)
-
--AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile dnl
-- buf/Makefile data/Makefile dnl
-- dict/Makefile dyn/Makefile dnl
-- eval/Makefile fil/Makefile fsp/Makefile fut/Makefile dnl
-- ha/Makefile ibuf/Makefile include/Makefile dnl
-- lock/Makefile log/Makefile dnl
-- mach/Makefile mem/Makefile mtr/Makefile dnl
-- page/Makefile pars/Makefile que/Makefile dnl
-- read/Makefile rem/Makefile row/Makefile dnl
-- srv/Makefile sync/Makefile thr/Makefile trx/Makefile dnl
-- usr/Makefile)
-+AC_OUTPUT(Makefile)
-diff -ur mysql-5.0.76-old/innobase/data/Makefile.am mysql-5.0.76/innobase/data/Makefile.am
---- mysql-5.0.76-old/innobase/data/Makefile.am 2009-01-15 16:45:09.000000000 -0100
-+++ mysql-5.0.76/innobase/data/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdata.a
-+noinst_LTLIBRARIES = libdata.la
-
--libdata_a_SOURCES = data0data.c data0type.c
-+libdata_la_SOURCES = data0data.c data0type.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/dict/Makefile.am mysql-5.0.76/innobase/dict/Makefile.am
---- mysql-5.0.76-old/innobase/dict/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/dict/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdict.a
-+noinst_LTLIBRARIES = libdict.la
-
--libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
-+libdict_la_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
- dict0mem.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.76-old/innobase/dyn/Makefile.am mysql-5.0.76/innobase/dyn/Makefile.am
---- mysql-5.0.76-old/innobase/dyn/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/dyn/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdyn.a
-+noinst_LTLIBRARIES = libdyn.la
-
--libdyn_a_SOURCES = dyn0dyn.c
-+libdyn_la_SOURCES = dyn0dyn.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/eval/Makefile.am mysql-5.0.76/innobase/eval/Makefile.am
---- mysql-5.0.76-old/innobase/eval/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/eval/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libeval.a
-+noinst_LTLIBRARIES = libeval.la
-
--libeval_a_SOURCES = eval0eval.c eval0proc.c
-+libeval_la_SOURCES = eval0eval.c eval0proc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/fil/Makefile.am mysql-5.0.76/innobase/fil/Makefile.am
---- mysql-5.0.76-old/innobase/fil/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/fil/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfil.a
-+noinst_LTLIBRARIES = libfil.la
-
--libfil_a_SOURCES = fil0fil.c
-+libfil_la_SOURCES = fil0fil.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/fsp/Makefile.am mysql-5.0.76/innobase/fsp/Makefile.am
---- mysql-5.0.76-old/innobase/fsp/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/fsp/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -16,9 +16,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfsp.a
-+noinst_LTLIBRARIES = libfsp.la
-
--libfsp_a_SOURCES = fsp0fsp.c
-+libfsp_la_SOURCES = fsp0fsp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/fut/Makefile.am mysql-5.0.76/innobase/fut/Makefile.am
---- mysql-5.0.76-old/innobase/fut/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/fut/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfut.a
-+noinst_LTLIBRARIES = libfut.la
-
--libfut_a_SOURCES = fut0fut.c fut0lst.c
-+libfut_la_SOURCES = fut0fut.c fut0lst.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/ha/Makefile.am mysql-5.0.76/innobase/ha/Makefile.am
---- mysql-5.0.76-old/innobase/ha/Makefile.am 2009-01-15 16:45:10.000000000 -0100
-+++ mysql-5.0.76/innobase/ha/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libha.a
-+noinst_LTLIBRARIES = libha.la
-
--libha_a_SOURCES = ha0ha.c hash0hash.c
-+libha_la_SOURCES = ha0ha.c hash0hash.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/ibuf/Makefile.am mysql-5.0.76/innobase/ibuf/Makefile.am
---- mysql-5.0.76-old/innobase/ibuf/Makefile.am 2009-01-15 16:45:11.000000000 -0100
-+++ mysql-5.0.76/innobase/ibuf/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libibuf.a
-+noinst_LTLIBRARIES = libibuf.la
-
--libibuf_a_SOURCES = ibuf0ibuf.c
-+libibuf_la_SOURCES = ibuf0ibuf.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/lock/Makefile.am mysql-5.0.76/innobase/lock/Makefile.am
---- mysql-5.0.76-old/innobase/lock/Makefile.am 2009-01-15 16:45:16.000000000 -0100
-+++ mysql-5.0.76/innobase/lock/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblock.a
-+noinst_LTLIBRARIES = liblock.la
-
--liblock_a_SOURCES = lock0lock.c
-+liblock_la_SOURCES = lock0lock.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/log/Makefile.am mysql-5.0.76/innobase/log/Makefile.am
---- mysql-5.0.76-old/innobase/log/Makefile.am 2009-01-15 16:45:16.000000000 -0100
-+++ mysql-5.0.76/innobase/log/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblog.a
-+noinst_LTLIBRARIES = liblog.la
-
--liblog_a_SOURCES = log0log.c log0recv.c
-+liblog_la_SOURCES = log0log.c log0recv.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/mach/Makefile.am mysql-5.0.76/innobase/mach/Makefile.am
---- mysql-5.0.76-old/innobase/mach/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/mach/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmach.a
-+noinst_LTLIBRARIES = libmach.la
-
--libmach_a_SOURCES = mach0data.c
-+libmach_la_SOURCES = mach0data.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/Makefile.am mysql-5.0.76/innobase/Makefile.am
---- mysql-5.0.76-old/innobase/Makefile.am 2009-01-15 16:45:09.000000000 -0100
-+++ mysql-5.0.76/innobase/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,14 +15,35 @@
-
- # Process this file with automake to create Makefile.in
-
--AUTOMAKE_OPTIONS = foreign
--TAR = gtar
--
- noinst_HEADERS = ib_config.h
-
--SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \
-- ha ibuf include lock log mach mem mtr page \
-- pars que read rem row srv sync thr trx usr
-+INCLUDES = -I$(srcdir)/include -I$(srcdir)/../include
-+
-+pkglib_LTLIBRARIES = libinnobase.la
-+
-+libinnobase_la_SOURCES = btr/btr0btr.c btr/btr0cur.c \
-+ btr/btr0pcur.c btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
-+ buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c \
-+ dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c \
-+ dict/dict0load.c dict/dict0mem.c dyn/dyn0dyn.c \
-+ eval/eval0eval.c eval/eval0proc.c fil/fil0fil.c \
-+ fsp/fsp0fsp.c fut/fut0fut.c fut/fut0lst.c ha/ha0ha.c \
-+ ha/hash0hash.c ibuf/ibuf0ibuf.c lock/lock0lock.c \
-+ log/log0log.c log/log0recv.c mach/mach0data.c \
-+ mem/mem0mem.c mem/mem0pool.c mtr/mtr0mtr.c mtr/mtr0log.c \
-+ os/os0proc.c os/os0sync.c os/os0thread.c os/os0file.c \
-+ page/page0page.c page/page0cur.c pars/pars0grm.c pars/lexyy.c \
-+ pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c \
-+ que/que0que.c read/read0read.c rem/rem0rec.c rem/rem0cmp.c \
-+ row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c \
-+ row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c \
-+ row/row0upd.c row/row0vers.c srv/srv0srv.c srv/srv0que.c \
-+ srv/srv0start.c sync/sync0arr.c sync/sync0rw.c \
-+ sync/sync0sync.c thr/thr0loc.c trx/trx0purge.c \
-+ trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c \
-+ trx/trx0trx.c trx/trx0undo.c usr/usr0sess.c ut/ut0byte.c \
-+ ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c
-+
- EXTRA_DIST = CMakeLists.txt
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.76-old/innobase/mem/Makefile.am mysql-5.0.76/innobase/mem/Makefile.am
---- mysql-5.0.76-old/innobase/mem/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/mem/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmem.a
-+noinst_LTLIBRARIES = libmem.la
-
--libmem_a_SOURCES = mem0mem.c mem0pool.c
-+libmem_la_SOURCES = mem0mem.c mem0pool.c
-
- EXTRA_DIST = mem0dbg.c
-
-diff -ur mysql-5.0.76-old/innobase/mtr/Makefile.am mysql-5.0.76/innobase/mtr/Makefile.am
---- mysql-5.0.76-old/innobase/mtr/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/mtr/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmtr.a
-+noinst_LTLIBRARIES = libmtr.la
-
--libmtr_a_SOURCES = mtr0mtr.c mtr0log.c
-+libmtr_la_SOURCES = mtr0mtr.c mtr0log.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/os/Makefile.am mysql-5.0.76/innobase/os/Makefile.am
---- mysql-5.0.76-old/innobase/os/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/os/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libos.a
-+noinst_LTLIBRARIES = libos.la
-
--libos_a_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-+libos_la_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/page/Makefile.am mysql-5.0.76/innobase/page/Makefile.am
---- mysql-5.0.76-old/innobase/page/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/page/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpage.a
-+noinst_LTLIBRARIES = libpage.la
-
--libpage_a_SOURCES = page0page.c page0cur.c
-+libpage_la_SOURCES = page0page.c page0cur.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/pars/Makefile.am mysql-5.0.76/innobase/pars/Makefile.am
---- mysql-5.0.76-old/innobase/pars/Makefile.am 2009-01-15 16:45:17.000000000 -0100
-+++ mysql-5.0.76/innobase/pars/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,11 +15,11 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpars.a
-+noinst_LTLIBRARIES = libpars.la
-
- noinst_HEADERS = pars0grm.h
-
--libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-+libpars_la_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/que/Makefile.am mysql-5.0.76/innobase/que/Makefile.am
---- mysql-5.0.76-old/innobase/que/Makefile.am 2009-01-15 16:45:18.000000000 -0100
-+++ mysql-5.0.76/innobase/que/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libque.a
-+noinst_LTLIBRARIES = libque.la
-
--libque_a_SOURCES = que0que.c
-+libque_la_SOURCES = que0que.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/read/Makefile.am mysql-5.0.76/innobase/read/Makefile.am
---- mysql-5.0.76-old/innobase/read/Makefile.am 2009-01-15 16:45:18.000000000 -0100
-+++ mysql-5.0.76/innobase/read/Makefile.am 2009-04-11 22:44:00.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libread.a
-+noinst_LTLIBRARIES = libread.la
-
--libread_a_SOURCES = read0read.c
-+libread_la_SOURCES = read0read.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/rem/Makefile.am mysql-5.0.76/innobase/rem/Makefile.am
---- mysql-5.0.76-old/innobase/rem/Makefile.am 2009-01-15 16:45:18.000000000 -0100
-+++ mysql-5.0.76/innobase/rem/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librem.a
-+noinst_LTLIBRARIES = librem.la
-
--librem_a_SOURCES = rem0rec.c rem0cmp.c
-+librem_la_SOURCES = rem0rec.c rem0cmp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/row/Makefile.am mysql-5.0.76/innobase/row/Makefile.am
---- mysql-5.0.76-old/innobase/row/Makefile.am 2009-01-15 16:45:18.000000000 -0100
-+++ mysql-5.0.76/innobase/row/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librow.a
-+noinst_LTLIBRARIES = librow.la
-
--librow_a_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
-+librow_la_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
- row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.76-old/innobase/srv/Makefile.am mysql-5.0.76/innobase/srv/Makefile.am
---- mysql-5.0.76-old/innobase/srv/Makefile.am 2009-01-15 16:45:18.000000000 -0100
-+++ mysql-5.0.76/innobase/srv/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsrv.a
-+noinst_LTLIBRARIES = libsrv.la
-
--libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
-+libsrv_la_SOURCES = srv0srv.c srv0que.c srv0start.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/sync/Makefile.am mysql-5.0.76/innobase/sync/Makefile.am
---- mysql-5.0.76-old/innobase/sync/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/innobase/sync/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsync.a
-+noinst_LTLIBRARIES = libsync.la
-
--libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-+libsync_la_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/thr/Makefile.am mysql-5.0.76/innobase/thr/Makefile.am
---- mysql-5.0.76-old/innobase/thr/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/innobase/thr/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libthr.a
-+noinst_LTLIBRARIES = libthr.la
-
--libthr_a_SOURCES = thr0loc.c
-+libthr_la_SOURCES = thr0loc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/trx/Makefile.am mysql-5.0.76/innobase/trx/Makefile.am
---- mysql-5.0.76-old/innobase/trx/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/innobase/trx/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libtrx.a
-+noinst_LTLIBRARIES = libtrx.la
-
--libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
-+libtrx_la_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
- trx0sys.c trx0trx.c trx0undo.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.76-old/innobase/usr/Makefile.am mysql-5.0.76/innobase/usr/Makefile.am
---- mysql-5.0.76-old/innobase/usr/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/innobase/usr/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libusr.a
-+noinst_LTLIBRARIES = libusr.la
-
--libusr_a_SOURCES = usr0sess.c
-+libusr_la_SOURCES = usr0sess.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/innobase/ut/Makefile.am mysql-5.0.76/innobase/ut/Makefile.am
---- mysql-5.0.76-old/innobase/ut/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/innobase/ut/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libut.a
-+noinst_LTLIBRARIES = libut.la
-
--libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-+libut_la_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.76-old/libmysql/Makefile.am mysql-5.0.76/libmysql/Makefile.am
---- mysql-5.0.76-old/libmysql/Makefile.am 2009-01-15 16:45:19.000000000 -0100
-+++ mysql-5.0.76/libmysql/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -106,8 +106,8 @@
- echo "# This file is autogenerated from Makefile.am" >> $$dir/Makefile; \
- echo 'CFLAGS= -I. -DUNDEF_THREADS_HACK' >>$$dir/Makefile; \
- echo "obj=$$objs" >>$$dir/Makefile; \
-- echo 'all: libmysql.a' >>$$dir/Makefile; \
-- echo 'libmysql.a: $$(obj)' >>$$dir/Makefile; \
-+ echo 'all: libmysql.la' >>$$dir/Makefile; \
-+ echo 'libmysql.la: $$(obj)' >>$$dir/Makefile; \
- echo ' $$(AR) r $$@ $$?' >>$$dir/Makefile; \
- gtar cvzf $$dir.tar.gz $$dir; \
- cd $$dir; gmake
-diff -ur mysql-5.0.76-old/libmysqld/examples/Makefile.am mysql-5.0.76/libmysqld/examples/Makefile.am
---- mysql-5.0.76-old/libmysqld/examples/Makefile.am 2009-01-15 16:45:20.000000000 -0100
-+++ mysql-5.0.76/libmysqld/examples/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -35,12 +35,12 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
- @NDB_SCI_LIBS@
-
- mysqltest_embedded_LINK = $(CXXLINK)
- mysqltest_embedded_SOURCES = mysqltest.c
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la
-
- mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
- my_readline.h sql_string.h completion_hash.h
-diff -ur mysql-5.0.76-old/libmysqld/Makefile.am mysql-5.0.76/libmysqld/Makefile.am
---- mysql-5.0.76-old/libmysqld/Makefile.am 2009-01-15 16:45:20.000000000 -0100
-+++ mysql-5.0.76/libmysqld/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -32,10 +32,10 @@
- -I$(top_srcdir)/regex \
- $(openssl_includes) @ZLIB_INCLUDES@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+noinst_LTLIBRARIES = libmysqld_int.la
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
--libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
-+#libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
- my_time.c
- sqlexamplessources = ha_example.cc ha_tina.cc
-@@ -66,50 +66,22 @@
- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
- ha_blackhole.cc ha_archive.cc my_user.c
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
--libmysqld_a_SOURCES=
-+libmysqld_int_la_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
-+#libmysqld_la_SOURCES=
-+libmysqld_la_SOURCES= libmysqld.c lib_sql.cc emb_qcache.cc
-
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
--# The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- @innodb_libs@ @bdb_libs_with_path@ \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a @NDB_SCI_LIBS@
-+# The following libraries should be included in libmysqld.la
-+libmysqld_la_LIBADD= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/innobase/libinnobase.la @bdb_libs_with_path@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/vio/libvio.la @NDB_SCI_LIBS@ \
-+ libmysqld_int.la
--
--
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u`
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \
-- else \
-- for arc in ./libmysqld_int.a $(INC_LIB); do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'`; \
-- $(AR) t $$arc|sed "s|^|$$arpath|"; \
-- done | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(RANLIB) libmysqld.a ; \
-- fi
--endif
-
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
-diff -ur mysql-5.0.76-old/myisam/Makefile.am mysql-5.0.76/myisam/Makefile.am
---- mysql-5.0.76-old/myisam/Makefile.am 2009-01-15 16:45:21.000000000 -0100
-+++ mysql-5.0.76/myisam/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -16,27 +16,27 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--pkglib_LIBRARIES = libmyisam.a
-+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
-+ -I$(top_builddir)/sql -I$(top_srcdir)/sql
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(ZLIB_LIBS)
-+noinst_LTLIBRARIES = libmyisam.la
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisampack_DEPENDENCIES=$(LIBRARIES)
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h fulltext.h ftdefs.h ft_test1.h ft_eval.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--rt_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_DEPENDENCIES= $(LIBRARIES)
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-diff -ur mysql-5.0.76-old/myisammrg/Makefile.am mysql-5.0.76/myisammrg/Makefile.am
---- mysql-5.0.76-old/myisammrg/Makefile.am 2009-01-15 16:45:25.000000000 -0100
-+++ mysql-5.0.76/myisammrg/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -14,9 +14,9 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la
- noinst_HEADERS = myrg_def.h
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
-diff -ur mysql-5.0.76-old/mysys/Makefile.am mysql-5.0.76/mysys/Makefile.am
---- mysql-5.0.76-old/mysys/Makefile.am 2009-01-15 16:47:01.000000000 -0100
-+++ mysql-5.0.76/mysys/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -18,14 +18,12 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
-+pkglib_LTLIBRARIES = libmysys.la
- noinst_HEADERS = mysys_priv.h my_static.h \
- my_os2cond.c my_os2dirsrch.c my_os2dirsrch.h \
- my_os2dlfcn.c my_os2file64.c my_os2mutex.c \
- my_os2thread.c my_os2tls.c
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -49,21 +47,26 @@
- my_quick.c my_lockmem.c my_static.c \
- my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
-- my_compress.c checksum.c raid.cc \
-+ my_compress.c checksum.c raid.cc \
- my_net.c my_port.c my_sleep.c \
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
-- my_memmem.c \
-- my_windac.c my_access.c base64.c my_libwrap.c
-+ my_memmem.c my_windac.c my_access.c base64.c \
-+ my_libwrap.c
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-+if NEED_THREADS
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c my_pthread.c my_thr_init.c
-+endif
-+
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c mf_soundex.c my_conio.c \
- my_wincond.c my_winthread.c CMakeLists.txt
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- EXTRA_PROGRAMS =
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DDATADIR="\"$(MYSQLDATAdir)\"" \
-@@ -74,8 +77,6 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -84,41 +85,41 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-diff -ur mysql-5.0.76-old/netware/Makefile.am mysql-5.0.76/netware/Makefile.am
---- mysql-5.0.76-old/netware/Makefile.am 2009-01-15 16:48:03.000000000 -0100
-+++ mysql-5.0.76/netware/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -16,14 +16,13 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
- mysql_test_run_SOURCES= mysql_test_run.c my_manage.c
- libmysql_SOURCES= libmysqlmain.c
--libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a \
-+libmysql_LDADD = ../libmysql/.libs/libmysqlclient.la \
- @openssl_libs@ @yassl_libs@
-
- netware_build_files = client/mysql.def client/mysqladmin.def \
-diff -ur mysql-5.0.76-old/pstack/Makefile.am mysql-5.0.76/pstack/Makefile.am
---- mysql-5.0.76-old/pstack/Makefile.am 2009-01-15 16:48:04.000000000 -0100
-+++ mysql-5.0.76/pstack/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -27,8 +27,8 @@
- EXTRA_DIST= $(SRC)
-
- if COMPILE_PSTACK
--pkglib_LIBRARIES = libpstack.a
--libpstack_a_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
-+pkglib_LTLIBRARIES = libpstack.la
-+libpstack_la_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
- endif
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.76-old/regex/Makefile.am mysql-5.0.76/regex/Makefile.am
---- mysql-5.0.76-old/regex/Makefile.am 2009-01-15 16:48:05.000000000 -0100
-+++ mysql-5.0.76/regex/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-diff -ur mysql-5.0.76-old/server-tools/instance-manager/Makefile.am mysql-5.0.76/server-tools/instance-manager/Makefile.am
---- mysql-5.0.76-old/server-tools/instance-manager/Makefile.am 2009-01-15 16:48:07.000000000 -0100
-+++ mysql-5.0.76/server-tools/instance-manager/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -24,8 +24,7 @@
- # default_options.h, generated from default_options.h.in)
- # See automake/autoconf docs for details
-
--noinst_LTLIBRARIES= liboptions.la
--noinst_LIBRARIES= libnet.a
-+noinst_LTLIBRARIES= liboptions.la libnet.la
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-@@ -37,17 +36,17 @@
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
--liboptions_la_LIBADD= $(top_builddir)/libmysql/get_password.lo
-+
-+liboptions_la_LIBADD= $(top_builddir)/libmysql/libmysqlclient.la
-
- # MySQL sometimes uses symlinks to reuse code
- # All symlinked files are grouped in libnet.a
-
--nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
--libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
-- $(top_builddir)/sql/pack.$(OBJEXT) \
-- $(top_builddir)/sql/sql_state.$(OBJEXT) \
-- $(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
-- $(top_builddir)/sql/client.$(OBJEXT)
-+nodist_libnet_la_SOURCES= net_serv.cc client_settings.h \
-+ $(srcdir)/../../sql/password.c $(srcdir)/../../sql/pack.c \
-+ $(srcdir)/../../sql/sql_state.c $(srcdir)/../../sql/mini_client_errors.c \
-+ $(srcdir)/../../sql/client.c
-+
-
- CLEANFILES= net_serv.cc client_settings.h
-
-@@ -79,11 +78,11 @@
- portability.h
-
- mysqlmanager_LDADD= liboptions.la \
-- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ libnet.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
-
-diff -ur mysql-5.0.76-old/sql/Makefile.am mysql-5.0.76/sql/Makefile.am
---- mysql-5.0.76-old/sql/Makefile.am 2009-01-15 16:48:09.000000000 -0100
-+++ mysql-5.0.76/sql/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -22,25 +22,24 @@
- @bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \
- -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/regex -I$(srcdir) \
-- $(openssl_includes)
-+ $(openssl_includes)
- WRAPLIBS= @WRAPLIBS@
- SUBDIRS = share
- libexec_PROGRAMS = mysqld
- EXTRA_PROGRAMS = gen_lex_hash
- bin_PROGRAMS = mysql_tzinfo_to_sql
- gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
--LDADD = $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ @NDB_SCI_LIBS@
--
--mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-- @bdb_libs@ @innodb_libs@ @pstack_libs@ \
-- @innodb_system_libs@ \
-+LDADD = $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+
-+mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-+ @bdb_libs@ $(top_builddir)/innobase/libinnobase.la \
-+ @pstack_libs@ @innodb_system_libs@ \
- @ndbcluster_libs@ @ndbcluster_system_libs@ \
- $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
- $(yassl_libs) $(openssl_libs) @MYSQLD_EXTRA_LIBS@
-@@ -52,43 +51,35 @@
- procedure.h sql_class.h sql_lex.h sql_list.h \
- sql_manager.h sql_map.h sql_string.h unireg.h \
- sql_error.h field.h handler.h mysqld_suffix.h \
-- ha_myisammrg.h\
-- ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \
-- ha_ndbcluster.h ha_ndbcluster_cond.h \
-- opt_range.h protocol.h \
-- sql_select.h structs.h table.h sql_udf.h hash_filo.h\
-- lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-- log_event.h sql_repl.h slave.h \
-- stacktrace.h sql_sort.h sql_cache.h set_var.h \
-- spatial.h gstream.h client_settings.h tzfile.h \
-- tztime.h my_decimal.h\
-+ ha_heap.h ha_berkeley.h ha_innodb.h \
-+ ha_ndbcluster.h ha_ndbcluster_cond.h opt_range.h \
-+ protocol.h sql_select.h structs.h table.h sql_udf.h \
-+ hash_filo.h lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-+ log_event.h sql_repl.h slave.h stacktrace.h sql_sort.h \
-+ sql_cache.h set_var.h spatial.h gstream.h \
-+ client_settings.h tzfile.h tztime.h my_decimal.h\
- sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
- parse_file.h sql_view.h sql_trigger.h \
-- sql_array.h sql_cursor.h \
-- examples/ha_example.h ha_archive.h \
-- examples/ha_tina.h ha_blackhole.h \
-+ sql_array.h sql_cursor.h examples/ha_example.h \
-+ ha_archive.h examples/ha_tina.h ha_blackhole.h \
- ha_federated.h
--mysqld_SOURCES = sql_lex.cc sql_handler.cc \
-- item.cc item_sum.cc item_buff.cc item_func.cc \
-- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-- thr_malloc.cc item_create.cc item_subselect.cc \
-- item_row.cc item_geofunc.cc \
-- field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \
-- net_serv.cc protocol.cc sql_state.c \
-- lock.cc my_lock.c \
-- sql_string.cc sql_manager.cc sql_map.cc \
-- mysqld.cc password.c hash_filo.cc hostname.cc \
-- set_var.cc sql_parse.cc sql_yacc.yy \
-- sql_base.cc table.cc sql_select.cc sql_insert.cc \
-- sql_prepare.cc sql_error.cc sql_locale.cc \
-- sql_update.cc sql_delete.cc uniques.cc sql_do.cc \
-- procedure.cc item_uniq.cc sql_test.cc \
-+mysqld_SOURCES = sql_lex.cc sql_handler.cc item.cc item_sum.cc \
-+ item_buff.cc item_func.cc item_cmpfunc.cc \
-+ item_strfunc.cc item_timefunc.cc thr_malloc.cc \
-+ item_create.cc item_subselect.cc item_row.cc \
-+ item_geofunc.cc field.cc strfunc.cc key.cc \
-+ sql_class.cc sql_list.cc net_serv.cc protocol.cc \
-+ sql_state.c lock.cc my_lock.c sql_string.cc \
-+ sql_manager.cc sql_map.cc mysqld.cc password.c \
-+ hash_filo.cc hostname.cc set_var.cc sql_parse.cc \
-+ sql_yacc.yy sql_base.cc table.cc sql_select.cc \
-+ sql_insert.cc sql_prepare.cc sql_error.cc \
-+ sql_locale.cc sql_update.cc sql_delete.cc uniques.cc \
-+ sql_do.cc procedure.cc item_uniq.cc sql_test.cc \
- log.cc log_event.cc init.cc derror.cc sql_acl.cc \
-- unireg.cc des_key_file.cc \
-- discover.cc time.cc opt_range.cc opt_sum.cc \
-- records.cc filesort.cc handler.cc \
-- ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
-- ha_berkeley.cc ha_innodb.cc \
-+ unireg.cc des_key_file.cc discover.cc time.cc \
-+ opt_range.cc opt_sum.cc records.cc filesort.cc \
-+ handler.cc ha_heap.cc ha_berkeley.cc ha_innodb.cc \
- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
- sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
- sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
-@@ -96,14 +87,13 @@
- slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
- client.c sql_client.cc mini_client_errors.c pack.c\
- stacktrace.c repl_failsafe.h repl_failsafe.cc \
-- sql_olap.cc sql_view.cc \
-- gstream.cc spatial.cc sql_help.cc sql_cursor.cc \
-- tztime.cc my_time.c my_user.c my_decimal.cc\
-- sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
-- sp_cache.cc parse_file.cc sql_trigger.cc \
-- examples/ha_example.cc ha_archive.cc \
-- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ sql_olap.cc sql_view.cc gstream.cc spatial.cc \
-+ sql_help.cc sql_cursor.cc tztime.cc my_time.c \
-+ my_user.c my_decimal.cc sp_head.cc sp_pcontext.cc \
-+ sp_rcontext.cc sp.cc sp_cache.cc parse_file.cc \
-+ sql_trigger.cc examples/ha_example.cc ha_archive.cc \
-+ examples/ha_tina.cc ha_blackhole.cc ha_federated.cc \
-+ ha_myisam.cc ha_myisammrg.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -ur mysql-5.0.76-old/strings/Makefile.am mysql-5.0.76/strings/Makefile.am
---- mysql-5.0.76-old/strings/Makefile.am 2009-01-15 16:48:34.000000000 -0100
-+++ mysql-5.0.76/strings/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- # Default charset definitions
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
-@@ -54,25 +54,25 @@
- strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
- t_ctype.h CMakeLists.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
--conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-+#conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- # This is because the dependency tracking misses @FOO@ vars in sources.
- #strtoull.o: @CHARSET_OBJS@
-
-
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
--test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
-+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.76-old/strings/strings-x86.s mysql-5.0.76/strings/strings-x86.s
---- mysql-5.0.76-old/strings/strings-x86.s 2009-01-15 16:48:37.000000000 -0100
-+++ mysql-5.0.76/strings/strings-x86.s 2009-04-11 22:46:03.000000000 +0000
-@@ -293,7 +293,7 @@
- movl %esp,%ebp
- pushl 12(%ebp) # search
- pushl 8(%ebp) # str
-- call strstr
-+ call strstr@plt
- add $8,%esp
- or %eax,%eax
- jz si_99 # Not found, return NULL
-diff -ur mysql-5.0.76-old/tests/Makefile.am mysql-5.0.76/tests/Makefile.am
---- mysql-5.0.76-old/tests/Makefile.am 2009-01-15 16:48:39.000000000 -0100
-+++ mysql-5.0.76/tests/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -42,11 +42,11 @@
-
- insert_test_SOURCES= insert_test.c
- select_test_SOURCES= select_test.c
--insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
--select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+insert_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-+select_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- bug25714_SOURCES= bug25714.c
--bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+bug25714_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- # Fix for mit-threads
- DEFS = -DUNDEF_THREADS_HACK
-diff -ur mysql-5.0.76-old/tools/Makefile.am mysql-5.0.76/tools/Makefile.am
---- mysql-5.0.76-old/tools/Makefile.am 2009-01-15 16:48:40.000000000 -0100
-+++ mysql-5.0.76/tools/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -23,7 +23,7 @@
-
- bin_PROGRAMS= mysqltestmanager
- mysqltestmanager_SOURCES= mysqlmanager.c
--mysqltestmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+mysqltestmanager_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
- DEF= -DUNDEF_THREADS_HACK
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.76-old/vio/Makefile.am mysql-5.0.76/vio/Makefile.am
---- mysql-5.0.76-old/vio/Makefile.am 2009-01-15 16:48:40.000000000 -0100
-+++ mysql-5.0.76/vio/Makefile.am 2009-04-11 22:44:01.000000000 +0000
-@@ -16,11 +16,12 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_LIBADD = -lssl
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
-diff -Nuar mysql.orig/ndb/src/common/util/Makefile.am mysql/ndb/src/common/util/Makefile.am
---- mysql.orig/ndb/src/common/util/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/common/util/Makefile.am 2009-04-11 16:36:38.520666040 -0700
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-diff -Nuar mysql.orig/ndb/src/cw/cpcd/Makefile.am mysql/ndb/src/cw/cpcd/Makefile.am
---- mysql.orig/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:36:32.185153480 -0700
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/ndb/config/common.mk.am
- include $(top_srcdir)/ndb/config/type_util.mk.am
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am mysql/ndb/src/kernel/blocks/dbdict/Makefile.am
---- mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:37:40.586744073 -0700
-@@ -26,9 +26,9 @@
- LDADD += \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/kernel/Makefile.am mysql/ndb/src/kernel/Makefile.am
---- mysql.orig/ndb/src/kernel/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/Makefile.am 2009-04-11 16:37:20.953412135 -0700
-@@ -66,9 +66,9 @@
- $(top_builddir)/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/mgmclient/Makefile.am mysql/ndb/src/mgmclient/Makefile.am
---- mysql.orig/ndb/src/mgmclient/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmclient/Makefile.am 2009-04-11 16:36:16.280363648 -0700
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-diff -Nuar mysql.orig/ndb/src/mgmsrv/Makefile.am mysql/ndb/src/mgmsrv/Makefile.am
---- mysql.orig/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:36:22.920358437 -0700
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-diff -Nuar mysql.orig/ndb/test/run-test/Makefile.am mysql/ndb/test/run-test/Makefile.am
---- mysql.orig/ndb/test/run-test/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/test/run-test/Makefile.am 2009-04-11 16:36:07.367509286 -0700
-@@ -32,9 +32,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include
- LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- wrappersdir=$(prefix)/bin
- wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run
-diff -Nuar mysql.orig/ndb/config/type_ndbapitest.mk.am mysql/ndb/config/type_ndbapitest.mk.am
---- mysql.orig/ndb/config/type_ndbapitest.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitest.mk.am 2009-04-11 16:44:10.268399273 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(top_srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/type_ndbapitools.mk.am mysql/ndb/config/type_ndbapitools.mk.am
---- mysql.orig/ndb/config/type_ndbapitools.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitools.mk.am 2009-04-11 16:44:04.156084503 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/win-libraries mysql/ndb/config/win-libraries
---- mysql.orig/ndb/config/win-libraries 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/win-libraries 2009-04-11 16:44:33.724336658 -0700
-@@ -21,7 +21,7 @@
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
diff --git a/02040_all_embedded-library-shared-5.0.77.patch b/02040_all_embedded-library-shared-5.0.77.patch
deleted file mode 100644
index 4b34d12..0000000
--- a/02040_all_embedded-library-shared-5.0.77.patch
+++ /dev/null
@@ -1,1544 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-
-diff -ur mysql-5.0.77-old/client/Makefile.am mysql-5.0.77/client/Makefile.am
---- mysql-5.0.77-old/client/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/client/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -37,7 +37,7 @@
- $(top_srcdir)/mysys/my_copy.c \
- $(top_srcdir)/mysys/my_mkdir.c
-
--mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
-+mysqltest_LDADD = $(top_builddir)/regex/libregex.la $(LDADD)
- mysqlbinlog_SOURCES = mysqlbinlog.cc \
- $(top_srcdir)/mysys/mf_tempdir.c \
- $(top_srcdir)/mysys/my_new.cc
-diff -ur mysql-5.0.77-old/config/ac-macros/ha_innodb.m4 mysql-5.0.77/config/ac-macros/ha_innodb.m4
---- mysql-5.0.77-old/config/ac-macros/ha_innodb.m4 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/config/ac-macros/ha_innodb.m4 2009-04-12 03:03:22.000000000 +0000
-@@ -25,40 +25,35 @@
- dnl Some libs are listed several times, in order for gcc to sort out
- dnl circular references.
- innodb_libs="\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/dict/libdict.a\
-- \$(top_builddir)/innobase/que/libque.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/row/librow.a\
-- \$(top_builddir)/innobase/pars/libpars.a\
-- \$(top_builddir)/innobase/btr/libbtr.a\
-- \$(top_builddir)/innobase/trx/libtrx.a\
-- \$(top_builddir)/innobase/read/libread.a\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/buf/libbuf.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/eval/libeval.a\
-- \$(top_builddir)/innobase/log/liblog.a\
-- \$(top_builddir)/innobase/fsp/libfsp.a\
-- \$(top_builddir)/innobase/fut/libfut.a\
-- \$(top_builddir)/innobase/fil/libfil.a\
-- \$(top_builddir)/innobase/lock/liblock.a\
-- \$(top_builddir)/innobase/mtr/libmtr.a\
-- \$(top_builddir)/innobase/page/libpage.a\
-- \$(top_builddir)/innobase/rem/librem.a\
-- \$(top_builddir)/innobase/thr/libthr.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/data/libdata.a\
-- \$(top_builddir)/innobase/mach/libmach.a\
-- \$(top_builddir)/innobase/ha/libha.a\
-- \$(top_builddir)/innobase/dyn/libdyn.a\
-- \$(top_builddir)/innobase/mem/libmem.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/ut/libut.a\
-- \$(top_builddir)/innobase/os/libos.a\
-- \$(top_builddir)/innobase/ut/libut.a"
-+ \$(top_builddir)/innobase/usr/libusr.la\
-+ \$(top_builddir)/innobase/srv/libsrv.la\
-+ \$(top_builddir)/innobase/dict/libdict.la\
-+ \$(top_builddir)/innobase/que/libque.la\
-+ \$(top_builddir)/innobase/ibuf/libibuf.la\
-+ \$(top_builddir)/innobase/row/librow.la\
-+ \$(top_builddir)/innobase/pars/libpars.la\
-+ \$(top_builddir)/innobase/btr/libbtr.la\
-+ \$(top_builddir)/innobase/trx/libtrx.la\
-+ \$(top_builddir)/innobase/read/libread.la\
-+ \$(top_builddir)/innobase/buf/libbuf.la\
-+ \$(top_builddir)/innobase/eval/libeval.la\
-+ \$(top_builddir)/innobase/log/liblog.la\
-+ \$(top_builddir)/innobase/fsp/libfsp.la\
-+ \$(top_builddir)/innobase/fut/libfut.la\
-+ \$(top_builddir)/innobase/fil/libfil.la\
-+ \$(top_builddir)/innobase/lock/liblock.la\
-+ \$(top_builddir)/innobase/mtr/libmtr.la\
-+ \$(top_builddir)/innobase/page/libpage.la\
-+ \$(top_builddir)/innobase/rem/librem.la\
-+ \$(top_builddir)/innobase/thr/libthr.la\
-+ \$(top_builddir)/innobase/sync/libsync.la\
-+ \$(top_builddir)/innobase/data/libdata.la\
-+ \$(top_builddir)/innobase/mach/libmach.la\
-+ \$(top_builddir)/innobase/ha/libha.la\
-+ \$(top_builddir)/innobase/dyn/libdyn.la\
-+ \$(top_builddir)/innobase/mem/libmem.la\
-+ \$(top_builddir)/innobase/ut/libut.la\
-+ \$(top_builddir)/innobase/os/libos.la"
-
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
- ;;
-diff -ur mysql-5.0.77-old/configure.in mysql-5.0.77/configure.in
---- mysql-5.0.77-old/configure.in 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/configure.in 2009-04-12 03:03:22.000000000 +0000
-@@ -253,7 +253,7 @@
- fi
-
- # Still need ranlib for readline; local static use only so no libtool.
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- # We use libtool
- #AC_LIBTOOL_WIN32_DLL
- AC_PROG_LIBTOOL
-@@ -574,6 +574,9 @@
- # We need an ANSI C compiler
- AM_PROG_CC_STDC
-
-+# Testing as sugggested by Diego
-+AM_PROG_CC_C_O
-+
- # We need an assembler, too
- AM_PROG_AS
- CCASFLAGS="$CCASFLAGS $ASFLAGS"
-@@ -2705,9 +2708,9 @@
-
- if test "$THREAD_SAFE_CLIENT" = "no"
- then
-- sql_client_dirs="strings regex mysys dbug extra libmysql client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql client"
- else
-- sql_client_dirs="strings regex mysys dbug extra libmysql libmysql_r client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql libmysql_r client"
- linked_client_targets="$linked_client_targets linked_libmysql_r_sources"
- AC_CONFIG_FILES(libmysql_r/Makefile)
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
-@@ -2736,13 +2739,11 @@
- export CC CXX CFLAGS CXXFLAGS LD LDFLAGS AR
- ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'"
-
-+AM_CONDITIONAL([NEED_THREADS], [test x"$with_server" != xno -o x"$THREAD_SAFE_CLIENT" != xno])
- if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
-
- if test "$with_server" = "no"
-@@ -2750,7 +2751,7 @@
- AM_CONDITIONAL([BUILD_INNODB_TOOLS], [false])
- else
- server_scripts="mysqld_safe mysql_install_db"
-- sql_server_dirs="strings mysys dbug extra regex"
-+ sql_server_dirs="strings dbug mysys extra regex"
-
-
- #
-diff -ur mysql-5.0.77-old/dbug/Makefile.am mysql-5.0.77/dbug/Makefile.am
---- mysql-5.0.77-old/dbug/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/dbug/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = ../mysys/libmysys.la ../strings/libmystrings.la
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = example1.c example2.c example3.c \
- user.r monty.doc readme.prof dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-@@ -31,11 +31,11 @@
-
-
- # Must be linked with libs that are not compiled yet
--noinst_PROGRAMS = factorial dbug_analyze
-+EXTRA_PROGRAMS = factorial dbug_analyze
- factorial_SOURCES = my_main.c factorial.c
- dbug_analyze_SOURCES = dbug_analyze.c
-
--all: user.t user.ps
-+check-local: user.t user.ps
-
- user.t: user.r $(NROFF_INC)
- -nroff -mm user.r > $@
-diff -ur mysql-5.0.77-old/extra/Makefile.am mysql-5.0.77/extra/Makefile.am
---- mysql-5.0.77-old/extra/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/extra/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,8 +15,7 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- @ndbcluster_includes@ -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-diff -ur mysql-5.0.77-old/heap/Makefile.am mysql-5.0.77/heap/Makefile.am
---- mysql-5.0.77-old/heap/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/heap/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -14,14 +14,13 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libheap.a ../mysys/libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
--pkglib_LIBRARIES = libheap.a
-+LDADD = libheap.la ../mysys/libmysys.la
-+pkglib_LTLIBRARIES = libheap.la
- noinst_PROGRAMS = hp_test1 hp_test2
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
- noinst_HEADERS = heapdef.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
-diff -ur mysql-5.0.77-old/innobase/btr/Makefile.am mysql-5.0.77/innobase/btr/Makefile.am
---- mysql-5.0.77-old/innobase/btr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/btr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbtr.a
-+noinst_LTLIBRARIES = libbtr.la
-
--libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-+libbtr_la_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/buf/Makefile.am mysql-5.0.77/innobase/buf/Makefile.am
---- mysql-5.0.77-old/innobase/buf/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/buf/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbuf.a
-+noinst_LTLIBRARIES = libbuf.la
-
--libbuf_a_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-+libbuf_la_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/configure.in mysql-5.0.77/innobase/configure.in
---- mysql-5.0.77-old/innobase/configure.in 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/configure.in 2009-04-12 03:03:22.000000000 +0000
-@@ -32,7 +32,7 @@
- CXXFLAGS="$CXXFLAGS "
-
- AC_PROG_CC
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- AC_PROG_INSTALL
- AC_PROG_LIBTOOL
- AC_CHECK_HEADERS(aio.h sched.h)
-@@ -126,14 +126,4 @@
- fi
- AC_SUBST(ARFLAGS)
-
--AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile dnl
-- buf/Makefile data/Makefile dnl
-- dict/Makefile dyn/Makefile dnl
-- eval/Makefile fil/Makefile fsp/Makefile fut/Makefile dnl
-- ha/Makefile ibuf/Makefile include/Makefile dnl
-- lock/Makefile log/Makefile dnl
-- mach/Makefile mem/Makefile mtr/Makefile dnl
-- page/Makefile pars/Makefile que/Makefile dnl
-- read/Makefile rem/Makefile row/Makefile dnl
-- srv/Makefile sync/Makefile thr/Makefile trx/Makefile dnl
-- usr/Makefile)
-+AC_OUTPUT(Makefile)
-diff -ur mysql-5.0.77-old/innobase/data/Makefile.am mysql-5.0.77/innobase/data/Makefile.am
---- mysql-5.0.77-old/innobase/data/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/data/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdata.a
-+noinst_LTLIBRARIES = libdata.la
-
--libdata_a_SOURCES = data0data.c data0type.c
-+libdata_la_SOURCES = data0data.c data0type.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/dict/Makefile.am mysql-5.0.77/innobase/dict/Makefile.am
---- mysql-5.0.77-old/innobase/dict/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/innobase/dict/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdict.a
-+noinst_LTLIBRARIES = libdict.la
-
--libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
-+libdict_la_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
- dict0mem.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/dyn/Makefile.am mysql-5.0.77/innobase/dyn/Makefile.am
---- mysql-5.0.77-old/innobase/dyn/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/dyn/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdyn.a
-+noinst_LTLIBRARIES = libdyn.la
-
--libdyn_a_SOURCES = dyn0dyn.c
-+libdyn_la_SOURCES = dyn0dyn.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/eval/Makefile.am mysql-5.0.77/innobase/eval/Makefile.am
---- mysql-5.0.77-old/innobase/eval/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/eval/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libeval.a
-+noinst_LTLIBRARIES = libeval.la
-
--libeval_a_SOURCES = eval0eval.c eval0proc.c
-+libeval_la_SOURCES = eval0eval.c eval0proc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fil/Makefile.am mysql-5.0.77/innobase/fil/Makefile.am
---- mysql-5.0.77-old/innobase/fil/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fil/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfil.a
-+noinst_LTLIBRARIES = libfil.la
-
--libfil_a_SOURCES = fil0fil.c
-+libfil_la_SOURCES = fil0fil.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fsp/Makefile.am mysql-5.0.77/innobase/fsp/Makefile.am
---- mysql-5.0.77-old/innobase/fsp/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fsp/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,9 +16,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfsp.a
-+noinst_LTLIBRARIES = libfsp.la
-
--libfsp_a_SOURCES = fsp0fsp.c
-+libfsp_la_SOURCES = fsp0fsp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fut/Makefile.am mysql-5.0.77/innobase/fut/Makefile.am
---- mysql-5.0.77-old/innobase/fut/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fut/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfut.a
-+noinst_LTLIBRARIES = libfut.la
-
--libfut_a_SOURCES = fut0fut.c fut0lst.c
-+libfut_la_SOURCES = fut0fut.c fut0lst.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ha/Makefile.am mysql-5.0.77/innobase/ha/Makefile.am
---- mysql-5.0.77-old/innobase/ha/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ha/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libha.a
-+noinst_LTLIBRARIES = libha.la
-
--libha_a_SOURCES = ha0ha.c hash0hash.c
-+libha_la_SOURCES = ha0ha.c hash0hash.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ibuf/Makefile.am mysql-5.0.77/innobase/ibuf/Makefile.am
---- mysql-5.0.77-old/innobase/ibuf/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ibuf/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libibuf.a
-+noinst_LTLIBRARIES = libibuf.la
-
--libibuf_a_SOURCES = ibuf0ibuf.c
-+libibuf_la_SOURCES = ibuf0ibuf.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/lock/Makefile.am mysql-5.0.77/innobase/lock/Makefile.am
---- mysql-5.0.77-old/innobase/lock/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/lock/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblock.a
-+noinst_LTLIBRARIES = liblock.la
-
--liblock_a_SOURCES = lock0lock.c
-+liblock_la_SOURCES = lock0lock.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/log/Makefile.am mysql-5.0.77/innobase/log/Makefile.am
---- mysql-5.0.77-old/innobase/log/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/log/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblog.a
-+noinst_LTLIBRARIES = liblog.la
-
--liblog_a_SOURCES = log0log.c log0recv.c
-+liblog_la_SOURCES = log0log.c log0recv.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/mach/Makefile.am mysql-5.0.77/innobase/mach/Makefile.am
---- mysql-5.0.77-old/innobase/mach/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mach/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmach.a
-+noinst_LTLIBRARIES = libmach.la
-
--libmach_a_SOURCES = mach0data.c
-+libmach_la_SOURCES = mach0data.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/Makefile.am mysql-5.0.77/innobase/Makefile.am
---- mysql-5.0.77-old/innobase/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,14 +15,35 @@
-
- # Process this file with automake to create Makefile.in
-
--AUTOMAKE_OPTIONS = foreign
--TAR = gtar
--
- noinst_HEADERS = ib_config.h
-
--SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \
-- ha ibuf include lock log mach mem mtr page \
-- pars que read rem row srv sync thr trx usr
-+INCLUDES = -I$(srcdir)/include -I$(srcdir)/../include
-+
-+pkglib_LTLIBRARIES = libinnobase.la
-+
-+libinnobase_la_SOURCES = btr/btr0btr.c btr/btr0cur.c \
-+ btr/btr0pcur.c btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
-+ buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c \
-+ dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c \
-+ dict/dict0load.c dict/dict0mem.c dyn/dyn0dyn.c \
-+ eval/eval0eval.c eval/eval0proc.c fil/fil0fil.c \
-+ fsp/fsp0fsp.c fut/fut0fut.c fut/fut0lst.c ha/ha0ha.c \
-+ ha/hash0hash.c ibuf/ibuf0ibuf.c lock/lock0lock.c \
-+ log/log0log.c log/log0recv.c mach/mach0data.c \
-+ mem/mem0mem.c mem/mem0pool.c mtr/mtr0mtr.c mtr/mtr0log.c \
-+ os/os0proc.c os/os0sync.c os/os0thread.c os/os0file.c \
-+ page/page0page.c page/page0cur.c pars/pars0grm.c pars/lexyy.c \
-+ pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c \
-+ que/que0que.c read/read0read.c rem/rem0rec.c rem/rem0cmp.c \
-+ row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c \
-+ row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c \
-+ row/row0upd.c row/row0vers.c srv/srv0srv.c srv/srv0que.c \
-+ srv/srv0start.c sync/sync0arr.c sync/sync0rw.c \
-+ sync/sync0sync.c thr/thr0loc.c trx/trx0purge.c \
-+ trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c \
-+ trx/trx0trx.c trx/trx0undo.c usr/usr0sess.c ut/ut0byte.c \
-+ ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c
-+
- EXTRA_DIST = CMakeLists.txt
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/innobase/mem/Makefile.am mysql-5.0.77/innobase/mem/Makefile.am
---- mysql-5.0.77-old/innobase/mem/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mem/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmem.a
-+noinst_LTLIBRARIES = libmem.la
-
--libmem_a_SOURCES = mem0mem.c mem0pool.c
-+libmem_la_SOURCES = mem0mem.c mem0pool.c
-
- EXTRA_DIST = mem0dbg.c
-
-diff -ur mysql-5.0.77-old/innobase/mtr/Makefile.am mysql-5.0.77/innobase/mtr/Makefile.am
---- mysql-5.0.77-old/innobase/mtr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mtr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmtr.a
-+noinst_LTLIBRARIES = libmtr.la
-
--libmtr_a_SOURCES = mtr0mtr.c mtr0log.c
-+libmtr_la_SOURCES = mtr0mtr.c mtr0log.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/os/Makefile.am mysql-5.0.77/innobase/os/Makefile.am
---- mysql-5.0.77-old/innobase/os/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/os/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libos.a
-+noinst_LTLIBRARIES = libos.la
-
--libos_a_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-+libos_la_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/page/Makefile.am mysql-5.0.77/innobase/page/Makefile.am
---- mysql-5.0.77-old/innobase/page/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/page/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpage.a
-+noinst_LTLIBRARIES = libpage.la
-
--libpage_a_SOURCES = page0page.c page0cur.c
-+libpage_la_SOURCES = page0page.c page0cur.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/pars/Makefile.am mysql-5.0.77/innobase/pars/Makefile.am
---- mysql-5.0.77-old/innobase/pars/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/pars/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,11 +15,11 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpars.a
-+noinst_LTLIBRARIES = libpars.la
-
- noinst_HEADERS = pars0grm.h
-
--libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-+libpars_la_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/que/Makefile.am mysql-5.0.77/innobase/que/Makefile.am
---- mysql-5.0.77-old/innobase/que/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/que/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libque.a
-+noinst_LTLIBRARIES = libque.la
-
--libque_a_SOURCES = que0que.c
-+libque_la_SOURCES = que0que.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/read/Makefile.am mysql-5.0.77/innobase/read/Makefile.am
---- mysql-5.0.77-old/innobase/read/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/read/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libread.a
-+noinst_LTLIBRARIES = libread.la
-
--libread_a_SOURCES = read0read.c
-+libread_la_SOURCES = read0read.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/rem/Makefile.am mysql-5.0.77/innobase/rem/Makefile.am
---- mysql-5.0.77-old/innobase/rem/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/rem/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librem.a
-+noinst_LTLIBRARIES = librem.la
-
--librem_a_SOURCES = rem0rec.c rem0cmp.c
-+librem_la_SOURCES = rem0rec.c rem0cmp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/row/Makefile.am mysql-5.0.77/innobase/row/Makefile.am
---- mysql-5.0.77-old/innobase/row/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/row/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librow.a
-+noinst_LTLIBRARIES = librow.la
-
--librow_a_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
-+librow_la_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
- row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/srv/Makefile.am mysql-5.0.77/innobase/srv/Makefile.am
---- mysql-5.0.77-old/innobase/srv/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/srv/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsrv.a
-+noinst_LTLIBRARIES = libsrv.la
-
--libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
-+libsrv_la_SOURCES = srv0srv.c srv0que.c srv0start.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/sync/Makefile.am mysql-5.0.77/innobase/sync/Makefile.am
---- mysql-5.0.77-old/innobase/sync/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/sync/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsync.a
-+noinst_LTLIBRARIES = libsync.la
-
--libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-+libsync_la_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/thr/Makefile.am mysql-5.0.77/innobase/thr/Makefile.am
---- mysql-5.0.77-old/innobase/thr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/thr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libthr.a
-+noinst_LTLIBRARIES = libthr.la
-
--libthr_a_SOURCES = thr0loc.c
-+libthr_la_SOURCES = thr0loc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/trx/Makefile.am mysql-5.0.77/innobase/trx/Makefile.am
---- mysql-5.0.77-old/innobase/trx/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/trx/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libtrx.a
-+noinst_LTLIBRARIES = libtrx.la
-
--libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
-+libtrx_la_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
- trx0sys.c trx0trx.c trx0undo.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/usr/Makefile.am mysql-5.0.77/innobase/usr/Makefile.am
---- mysql-5.0.77-old/innobase/usr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/usr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libusr.a
-+noinst_LTLIBRARIES = libusr.la
-
--libusr_a_SOURCES = usr0sess.c
-+libusr_la_SOURCES = usr0sess.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ut/Makefile.am mysql-5.0.77/innobase/ut/Makefile.am
---- mysql-5.0.77-old/innobase/ut/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ut/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libut.a
-+noinst_LTLIBRARIES = libut.la
-
--libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-+libut_la_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/libmysql/Makefile.am mysql-5.0.77/libmysql/Makefile.am
---- mysql-5.0.77-old/libmysql/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/libmysql/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -106,8 +106,8 @@
- echo "# This file is autogenerated from Makefile.am" >> $$dir/Makefile; \
- echo 'CFLAGS= -I. -DUNDEF_THREADS_HACK' >>$$dir/Makefile; \
- echo "obj=$$objs" >>$$dir/Makefile; \
-- echo 'all: libmysql.a' >>$$dir/Makefile; \
-- echo 'libmysql.a: $$(obj)' >>$$dir/Makefile; \
-+ echo 'all: libmysql.la' >>$$dir/Makefile; \
-+ echo 'libmysql.la: $$(obj)' >>$$dir/Makefile; \
- echo ' $$(AR) r $$@ $$?' >>$$dir/Makefile; \
- gtar cvzf $$dir.tar.gz $$dir; \
- cd $$dir; gmake
-diff -ur mysql-5.0.77-old/libmysqld/examples/Makefile.am mysql-5.0.77/libmysqld/examples/Makefile.am
---- mysql-5.0.77-old/libmysqld/examples/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/libmysqld/examples/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -35,12 +35,12 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
- @NDB_SCI_LIBS@
-
- mysqltest_embedded_LINK = $(CXXLINK)
- mysqltest_embedded_SOURCES = mysqltest.c
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la
-
- mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
- my_readline.h sql_string.h completion_hash.h
-diff -ur mysql-5.0.77-old/libmysqld/Makefile.am mysql-5.0.77/libmysqld/Makefile.am
---- mysql-5.0.77-old/libmysqld/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/libmysqld/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -32,10 +32,10 @@
- -I$(top_srcdir)/regex \
- $(openssl_includes) @ZLIB_INCLUDES@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+noinst_LTLIBRARIES = libmysqld_int.la
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
--libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
-+#libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
- my_time.c
- sqlexamplessources = ha_example.cc ha_tina.cc
-@@ -67,50 +67,22 @@
- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
- ha_blackhole.cc ha_archive.cc my_user.c
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
--libmysqld_a_SOURCES=
-+libmysqld_int_la_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
-+#libmysqld_la_SOURCES=
-+libmysqld_la_SOURCES= libmysqld.c lib_sql.cc emb_qcache.cc
-
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
--# The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- @innodb_libs@ @bdb_libs_with_path@ \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a @NDB_SCI_LIBS@
--
--
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u`
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \
-- else \
-- for arc in ./libmysqld_int.a $(INC_LIB); do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'`; \
-- $(AR) t $$arc|sed "s|^|$$arpath|"; \
-- done | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(RANLIB) libmysqld.a ; \
-- fi
--endif
-+# The following libraries should be included in libmysqld.la
-+libmysqld_la_LIBADD= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/innobase/libinnobase.la @bdb_libs_with_path@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/vio/libvio.la @NDB_SCI_LIBS@ \
-+ libmysqld_int.la
-
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
-diff -ur mysql-5.0.77-old/myisam/Makefile.am mysql-5.0.77/myisam/Makefile.am
---- mysql-5.0.77-old/myisam/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/myisam/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,27 +16,27 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--pkglib_LIBRARIES = libmyisam.a
-+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
-+ -I$(top_builddir)/sql -I$(top_srcdir)/sql
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(ZLIB_LIBS)
-+noinst_LTLIBRARIES = libmyisam.la
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisampack_DEPENDENCIES=$(LIBRARIES)
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h fulltext.h ftdefs.h ft_test1.h ft_eval.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--rt_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_DEPENDENCIES= $(LIBRARIES)
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-diff -ur mysql-5.0.77-old/myisammrg/Makefile.am mysql-5.0.77/myisammrg/Makefile.am
---- mysql-5.0.77-old/myisammrg/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/myisammrg/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -14,9 +14,9 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la
- noinst_HEADERS = myrg_def.h
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
-diff -ur mysql-5.0.77-old/mysys/Makefile.am mysql-5.0.77/mysys/Makefile.am
---- mysql-5.0.77-old/mysys/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/mysys/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -18,14 +18,12 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
-+pkglib_LTLIBRARIES = libmysys.la
- noinst_HEADERS = mysys_priv.h my_static.h \
- my_os2cond.c my_os2dirsrch.c my_os2dirsrch.h \
- my_os2dlfcn.c my_os2file64.c my_os2mutex.c \
- my_os2thread.c my_os2tls.c
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -49,21 +47,26 @@
- my_quick.c my_lockmem.c my_static.c \
- my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
-- my_compress.c checksum.c raid.cc \
-+ my_compress.c checksum.c raid.cc \
- my_net.c my_port.c my_sleep.c \
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
-- my_memmem.c \
-- my_windac.c my_access.c base64.c my_libwrap.c
-+ my_memmem.c my_windac.c my_access.c base64.c \
-+ my_libwrap.c
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-+if NEED_THREADS
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c my_pthread.c my_thr_init.c
-+endif
-+
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c mf_soundex.c my_conio.c \
- my_wincond.c my_winthread.c CMakeLists.txt
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- EXTRA_PROGRAMS =
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DDATADIR="\"$(MYSQLDATAdir)\"" \
-@@ -74,8 +77,6 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -84,41 +85,41 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-diff -ur mysql-5.0.77-old/netware/Makefile.am mysql-5.0.77/netware/Makefile.am
---- mysql-5.0.77-old/netware/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/netware/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,14 +16,13 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
- mysql_test_run_SOURCES= mysql_test_run.c my_manage.c
- libmysql_SOURCES= libmysqlmain.c
--libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a \
-+libmysql_LDADD = ../libmysql/.libs/libmysqlclient.la \
- @openssl_libs@ @yassl_libs@
-
- netware_build_files = client/mysql.def client/mysqladmin.def \
-diff -ur mysql-5.0.77-old/pstack/Makefile.am mysql-5.0.77/pstack/Makefile.am
---- mysql-5.0.77-old/pstack/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/pstack/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -27,8 +27,8 @@
- EXTRA_DIST= $(SRC)
-
- if COMPILE_PSTACK
--pkglib_LIBRARIES = libpstack.a
--libpstack_a_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
-+pkglib_LTLIBRARIES = libpstack.la
-+libpstack_la_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
- endif
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/regex/Makefile.am mysql-5.0.77/regex/Makefile.am
---- mysql-5.0.77-old/regex/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/regex/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-diff -ur mysql-5.0.77-old/server-tools/instance-manager/Makefile.am mysql-5.0.77/server-tools/instance-manager/Makefile.am
---- mysql-5.0.77-old/server-tools/instance-manager/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/server-tools/instance-manager/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -24,8 +24,7 @@
- # default_options.h, generated from default_options.h.in)
- # See automake/autoconf docs for details
-
--noinst_LTLIBRARIES= liboptions.la
--noinst_LIBRARIES= libnet.a
-+noinst_LTLIBRARIES= liboptions.la libnet.la
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-@@ -37,17 +36,17 @@
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
--liboptions_la_LIBADD= $(top_builddir)/libmysql/get_password.lo
-+
-+liboptions_la_LIBADD= $(top_builddir)/libmysql/libmysqlclient.la
-
- # MySQL sometimes uses symlinks to reuse code
- # All symlinked files are grouped in libnet.a
-
--nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
--libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
-- $(top_builddir)/sql/pack.$(OBJEXT) \
-- $(top_builddir)/sql/sql_state.$(OBJEXT) \
-- $(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
-- $(top_builddir)/sql/client.$(OBJEXT)
-+nodist_libnet_la_SOURCES= net_serv.cc client_settings.h \
-+ $(srcdir)/../../sql/password.c $(srcdir)/../../sql/pack.c \
-+ $(srcdir)/../../sql/sql_state.c $(srcdir)/../../sql/mini_client_errors.c \
-+ $(srcdir)/../../sql/client.c
-+
-
- CLEANFILES= net_serv.cc client_settings.h
-
-@@ -79,11 +78,11 @@
- portability.h
-
- mysqlmanager_LDADD= liboptions.la \
-- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ libnet.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
-
-diff -ur mysql-5.0.77-old/sql/Makefile.am mysql-5.0.77/sql/Makefile.am
---- mysql-5.0.77-old/sql/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/sql/Makefile.am 2009-04-12 05:04:23.000000000 +0000
-@@ -22,25 +22,24 @@
- @bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \
- -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/regex -I$(srcdir) \
-- $(openssl_includes)
-+ $(openssl_includes)
- WRAPLIBS= @WRAPLIBS@
- SUBDIRS = share
- libexec_PROGRAMS = mysqld
- EXTRA_PROGRAMS = gen_lex_hash
- bin_PROGRAMS = mysql_tzinfo_to_sql
- gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
--LDADD = $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ @NDB_SCI_LIBS@
--
--mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-- @bdb_libs@ @innodb_libs@ @pstack_libs@ \
-- @innodb_system_libs@ \
-+LDADD = $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+
-+mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-+ @bdb_libs@ $(top_builddir)/innobase/libinnobase.la \
-+ @pstack_libs@ @innodb_system_libs@ \
- @ndbcluster_libs@ @ndbcluster_system_libs@ \
- $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
- $(yassl_libs) $(openssl_libs) @MYSQLD_EXTRA_LIBS@
-@@ -52,45 +51,36 @@
- procedure.h sql_class.h sql_lex.h sql_list.h \
- sql_manager.h sql_map.h sql_string.h unireg.h \
- sql_error.h field.h handler.h mysqld_suffix.h \
-- sql_profile.h \
-- ha_myisammrg.h\
-- ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \
-- ha_ndbcluster.h ha_ndbcluster_cond.h \
-- opt_range.h protocol.h \
-- sql_select.h structs.h table.h sql_udf.h hash_filo.h\
-- lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-- log_event.h sql_repl.h slave.h \
-- stacktrace.h sql_sort.h sql_cache.h set_var.h \
-- spatial.h gstream.h client_settings.h tzfile.h \
-- tztime.h my_decimal.h\
-+ sql_profile.h ha_heap.h ha_berkeley.h ha_innodb.h \
-+ ha_ndbcluster.h ha_ndbcluster_cond.h opt_range.h \
-+ protocol.h sql_select.h structs.h table.h sql_udf.h \
-+ hash_filo.h lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-+ log_event.h sql_repl.h slave.h stacktrace.h sql_sort.h \
-+ sql_cache.h set_var.h spatial.h gstream.h \
-+ client_settings.h tzfile.h tztime.h my_decimal.h \
- sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
-- parse_file.h sql_view.h sql_trigger.h \
-- sql_array.h sql_cursor.h \
-- examples/ha_example.h ha_archive.h \
-- examples/ha_tina.h ha_blackhole.h \
-+ parse_file.h sql_view.h sql_trigger.h \
-+ sql_array.h sql_cursor.h examples/ha_example.h \
-+ ha_archive.h examples/ha_tina.h ha_blackhole.h \
- ha_federated.h
--mysqld_SOURCES = sql_lex.cc sql_handler.cc \
-- item.cc item_sum.cc item_buff.cc item_func.cc \
-- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-- thr_malloc.cc item_create.cc item_subselect.cc \
-- item_row.cc item_geofunc.cc \
-- field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \
-- net_serv.cc protocol.cc sql_state.c \
-- lock.cc my_lock.c \
-- sql_string.cc sql_manager.cc sql_map.cc \
-- mysqld.cc password.c hash_filo.cc hostname.cc \
-- set_var.cc sql_parse.cc sql_yacc.yy \
-- sql_base.cc table.cc sql_select.cc sql_insert.cc \
-- sql_prepare.cc sql_error.cc sql_locale.cc \
-- sql_profile.cc \
-- sql_update.cc sql_delete.cc uniques.cc sql_do.cc \
-- procedure.cc item_uniq.cc sql_test.cc \
-- log.cc log_event.cc init.cc derror.cc sql_acl.cc \
-- unireg.cc des_key_file.cc \
-- discover.cc time.cc opt_range.cc opt_sum.cc \
-- records.cc filesort.cc handler.cc \
-- ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
-- ha_berkeley.cc ha_innodb.cc \
-+mysqld_SOURCES = sql_lex.cc sql_handler.cc item.cc item_sum.cc \
-+ item_buff.cc item_func.cc item_cmpfunc.cc \
-+ item_strfunc.cc item_timefunc.cc thr_malloc.cc \
-+ item_create.cc item_subselect.cc item_row.cc \
-+ item_geofunc.cc field.cc strfunc.cc key.cc \
-+ sql_class.cc sql_list.cc net_serv.cc protocol.cc \
-+ sql_state.c lock.cc my_lock.c sql_string.cc \
-+ sql_manager.cc sql_map.cc mysqld.cc password.c \
-+ hash_filo.cc hostname.cc set_var.cc sql_parse.cc \
-+ sql_yacc.yy sql_base.cc table.cc sql_select.cc \
-+ sql_insert.cc sql_prepare.cc sql_error.cc \
-+ sql_locale.cc sql_profile.cc sql_update.cc \
-+ sql_delete.cc uniques.cc sql_do.cc procedure.cc \
-+ item_uniq.cc sql_test.cc log.cc log_event.cc \
-+ init.cc derror.cc sql_acl.cc unireg.cc \
-+ des_key_file.cc discover.cc time.cc opt_range.cc \
-+ opt_sum.cc records.cc filesort.cc handler.cc \
-+ ha_heap.cc ha_berkeley.cc ha_innodb.cc \
- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
- sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
- sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
-@@ -98,14 +88,13 @@
- slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
- client.c sql_client.cc mini_client_errors.c pack.c\
- stacktrace.c repl_failsafe.h repl_failsafe.cc \
-- sql_olap.cc sql_view.cc \
-- gstream.cc spatial.cc sql_help.cc sql_cursor.cc \
-- tztime.cc my_time.c my_user.c my_decimal.cc\
-- sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
-- sp_cache.cc parse_file.cc sql_trigger.cc \
-- examples/ha_example.cc ha_archive.cc \
-- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ sql_olap.cc sql_view.cc gstream.cc spatial.cc \
-+ sql_help.cc sql_cursor.cc tztime.cc my_time.c \
-+ my_user.c my_decimal.cc sp_head.cc sp_pcontext.cc \
-+ sp_rcontext.cc sp.cc sp_cache.cc parse_file.cc \
-+ sql_trigger.cc examples/ha_example.cc ha_archive.cc \
-+ examples/ha_tina.cc ha_blackhole.cc ha_federated.cc \
-+ ha_myisam.cc ha_myisammrg.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -ur mysql-5.0.77-old/strings/Makefile.am mysql-5.0.77/strings/Makefile.am
---- mysql-5.0.77-old/strings/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/strings/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- # Default charset definitions
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
-@@ -54,25 +54,25 @@
- strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
- t_ctype.h CMakeLists.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
--conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-+#conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- # This is because the dependency tracking misses @FOO@ vars in sources.
- #strtoull.o: @CHARSET_OBJS@
-
-
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
--test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
-+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/strings/strings-x86.s mysql-5.0.77/strings/strings-x86.s
---- mysql-5.0.77-old/strings/strings-x86.s 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/strings/strings-x86.s 2009-04-12 03:03:22.000000000 +0000
-@@ -293,7 +293,7 @@
- movl %esp,%ebp
- pushl 12(%ebp) # search
- pushl 8(%ebp) # str
-- call strstr
-+ call strstr@plt
- add $8,%esp
- or %eax,%eax
- jz si_99 # Not found, return NULL
-diff -ur mysql-5.0.77-old/tests/Makefile.am mysql-5.0.77/tests/Makefile.am
---- mysql-5.0.77-old/tests/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/tests/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -42,11 +42,11 @@
-
- insert_test_SOURCES= insert_test.c
- select_test_SOURCES= select_test.c
--insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
--select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+insert_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-+select_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- bug25714_SOURCES= bug25714.c
--bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+bug25714_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- # Fix for mit-threads
- DEFS = -DUNDEF_THREADS_HACK
-diff -ur mysql-5.0.77-old/tools/Makefile.am mysql-5.0.77/tools/Makefile.am
---- mysql-5.0.77-old/tools/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/tools/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -23,7 +23,7 @@
-
- bin_PROGRAMS= mysqltestmanager
- mysqltestmanager_SOURCES= mysqlmanager.c
--mysqltestmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+mysqltestmanager_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
- DEF= -DUNDEF_THREADS_HACK
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/vio/Makefile.am mysql-5.0.77/vio/Makefile.am
---- mysql-5.0.77-old/vio/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/vio/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,11 +16,12 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_LIBADD = -lssl
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
-diff -Nuar mysql.orig/ndb/src/common/util/Makefile.am mysql/ndb/src/common/util/Makefile.am
---- mysql.orig/ndb/src/common/util/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/common/util/Makefile.am 2009-04-11 16:36:38.520666040 -0700
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-diff -Nuar mysql.orig/ndb/src/cw/cpcd/Makefile.am mysql/ndb/src/cw/cpcd/Makefile.am
---- mysql.orig/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:36:32.185153480 -0700
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/ndb/config/common.mk.am
- include $(top_srcdir)/ndb/config/type_util.mk.am
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am mysql/ndb/src/kernel/blocks/dbdict/Makefile.am
---- mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:37:40.586744073 -0700
-@@ -26,9 +26,9 @@
- LDADD += \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/kernel/Makefile.am mysql/ndb/src/kernel/Makefile.am
---- mysql.orig/ndb/src/kernel/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/Makefile.am 2009-04-11 16:37:20.953412135 -0700
-@@ -66,9 +66,9 @@
- $(top_builddir)/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/mgmclient/Makefile.am mysql/ndb/src/mgmclient/Makefile.am
---- mysql.orig/ndb/src/mgmclient/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmclient/Makefile.am 2009-04-11 16:36:16.280363648 -0700
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-diff -Nuar mysql.orig/ndb/src/mgmsrv/Makefile.am mysql/ndb/src/mgmsrv/Makefile.am
---- mysql.orig/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:36:22.920358437 -0700
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-diff -Nuar mysql.orig/ndb/test/run-test/Makefile.am mysql/ndb/test/run-test/Makefile.am
---- mysql.orig/ndb/test/run-test/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/test/run-test/Makefile.am 2009-04-11 16:36:07.367509286 -0700
-@@ -32,9 +32,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include
- LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- wrappersdir=$(prefix)/bin
- wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run
-diff -Nuar mysql.orig/ndb/config/type_ndbapitest.mk.am mysql/ndb/config/type_ndbapitest.mk.am
---- mysql.orig/ndb/config/type_ndbapitest.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitest.mk.am 2009-04-11 16:44:10.268399273 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(top_srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/type_ndbapitools.mk.am mysql/ndb/config/type_ndbapitools.mk.am
---- mysql.orig/ndb/config/type_ndbapitools.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitools.mk.am 2009-04-11 16:44:04.156084503 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/win-libraries mysql/ndb/config/win-libraries
---- mysql.orig/ndb/config/win-libraries 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/win-libraries 2009-04-11 16:44:33.724336658 -0700
-@@ -21,7 +21,7 @@
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
diff --git a/02040_all_embedded-library-shared-5.0.83.patch b/02040_all_embedded-library-shared-5.0.83.patch
deleted file mode 120000
index 79e0610..0000000
--- a/02040_all_embedded-library-shared-5.0.83.patch
+++ /dev/null
@@ -1 +0,0 @@
-02040_all_embedded-library-shared-5.0.77.patch \ No newline at end of file
diff --git a/02040_all_embedded-library-shared-5.0.92.patch b/02040_all_embedded-library-shared-5.0.92.patch
deleted file mode 100644
index 913272b..0000000
--- a/02040_all_embedded-library-shared-5.0.92.patch
+++ /dev/null
@@ -1,1541 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-
-diff -ur mysql-5.0.77-old/client/Makefile.am mysql-5.0.77/client/Makefile.am
---- mysql-5.0.77-old/client/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/client/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -37,7 +37,7 @@
- $(top_srcdir)/mysys/my_copy.c \
- $(top_srcdir)/mysys/my_mkdir.c
-
--mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD)
-+mysqltest_LDADD = $(top_builddir)/regex/libregex.la $(LDADD)
- mysqlbinlog_SOURCES = mysqlbinlog.cc \
- $(top_srcdir)/mysys/mf_tempdir.c \
- $(top_srcdir)/mysys/my_new.cc
-diff -ur mysql-5.0.77-old/config/ac-macros/ha_innodb.m4 mysql-5.0.77/config/ac-macros/ha_innodb.m4
---- mysql-5.0.77-old/config/ac-macros/ha_innodb.m4 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/config/ac-macros/ha_innodb.m4 2009-04-12 03:03:22.000000000 +0000
-@@ -25,40 +25,35 @@
- dnl Some libs are listed several times, in order for gcc to sort out
- dnl circular references.
- innodb_libs="\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/dict/libdict.a\
-- \$(top_builddir)/innobase/que/libque.a\
-- \$(top_builddir)/innobase/srv/libsrv.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/row/librow.a\
-- \$(top_builddir)/innobase/pars/libpars.a\
-- \$(top_builddir)/innobase/btr/libbtr.a\
-- \$(top_builddir)/innobase/trx/libtrx.a\
-- \$(top_builddir)/innobase/read/libread.a\
-- \$(top_builddir)/innobase/usr/libusr.a\
-- \$(top_builddir)/innobase/buf/libbuf.a\
-- \$(top_builddir)/innobase/ibuf/libibuf.a\
-- \$(top_builddir)/innobase/eval/libeval.a\
-- \$(top_builddir)/innobase/log/liblog.a\
-- \$(top_builddir)/innobase/fsp/libfsp.a\
-- \$(top_builddir)/innobase/fut/libfut.a\
-- \$(top_builddir)/innobase/fil/libfil.a\
-- \$(top_builddir)/innobase/lock/liblock.a\
-- \$(top_builddir)/innobase/mtr/libmtr.a\
-- \$(top_builddir)/innobase/page/libpage.a\
-- \$(top_builddir)/innobase/rem/librem.a\
-- \$(top_builddir)/innobase/thr/libthr.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/data/libdata.a\
-- \$(top_builddir)/innobase/mach/libmach.a\
-- \$(top_builddir)/innobase/ha/libha.a\
-- \$(top_builddir)/innobase/dyn/libdyn.a\
-- \$(top_builddir)/innobase/mem/libmem.a\
-- \$(top_builddir)/innobase/sync/libsync.a\
-- \$(top_builddir)/innobase/ut/libut.a\
-- \$(top_builddir)/innobase/os/libos.a\
-- \$(top_builddir)/innobase/ut/libut.a"
-+ \$(top_builddir)/innobase/usr/libusr.la\
-+ \$(top_builddir)/innobase/srv/libsrv.la\
-+ \$(top_builddir)/innobase/dict/libdict.la\
-+ \$(top_builddir)/innobase/que/libque.la\
-+ \$(top_builddir)/innobase/ibuf/libibuf.la\
-+ \$(top_builddir)/innobase/row/librow.la\
-+ \$(top_builddir)/innobase/pars/libpars.la\
-+ \$(top_builddir)/innobase/btr/libbtr.la\
-+ \$(top_builddir)/innobase/trx/libtrx.la\
-+ \$(top_builddir)/innobase/read/libread.la\
-+ \$(top_builddir)/innobase/buf/libbuf.la\
-+ \$(top_builddir)/innobase/eval/libeval.la\
-+ \$(top_builddir)/innobase/log/liblog.la\
-+ \$(top_builddir)/innobase/fsp/libfsp.la\
-+ \$(top_builddir)/innobase/fut/libfut.la\
-+ \$(top_builddir)/innobase/fil/libfil.la\
-+ \$(top_builddir)/innobase/lock/liblock.la\
-+ \$(top_builddir)/innobase/mtr/libmtr.la\
-+ \$(top_builddir)/innobase/page/libpage.la\
-+ \$(top_builddir)/innobase/rem/librem.la\
-+ \$(top_builddir)/innobase/thr/libthr.la\
-+ \$(top_builddir)/innobase/sync/libsync.la\
-+ \$(top_builddir)/innobase/data/libdata.la\
-+ \$(top_builddir)/innobase/mach/libmach.la\
-+ \$(top_builddir)/innobase/ha/libha.la\
-+ \$(top_builddir)/innobase/dyn/libdyn.la\
-+ \$(top_builddir)/innobase/mem/libmem.la\
-+ \$(top_builddir)/innobase/ut/libut.la\
-+ \$(top_builddir)/innobase/os/libos.la"
-
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
- ;;
-diff -ur mysql-5.0.77-old/configure.in mysql-5.0.77/configure.in
---- mysql-5.0.77-old/configure.in 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/configure.in 2009-04-12 03:03:22.000000000 +0000
-@@ -253,7 +253,7 @@
- fi
-
- # Still need ranlib for readline; local static use only so no libtool.
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- # We use libtool
- #AC_LIBTOOL_WIN32_DLL
- AC_PROG_LIBTOOL
-@@ -574,6 +574,9 @@
- # We need an ANSI C compiler
- AM_PROG_CC_STDC
-
-+# Testing as sugggested by Diego
-+AM_PROG_CC_C_O
-+
- # We need an assembler, too
- AM_PROG_AS
- CCASFLAGS="$CCASFLAGS $ASFLAGS"
-@@ -2705,9 +2708,9 @@
-
- if test "$THREAD_SAFE_CLIENT" = "no"
- then
-- sql_client_dirs="strings regex mysys dbug extra libmysql client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql client"
- else
-- sql_client_dirs="strings regex mysys dbug extra libmysql libmysql_r client"
-+ sql_client_dirs="strings regex dbug mysys extra libmysql libmysql_r client"
- linked_client_targets="$linked_client_targets linked_libmysql_r_sources"
- AC_CONFIG_FILES(libmysql_r/Makefile)
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
-@@ -2736,13 +2739,11 @@
- export CC CXX CFLAGS CXXFLAGS LD LDFLAGS AR
- ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'"
-
-+AM_CONDITIONAL([NEED_THREADS], [test x"$with_server" != xno -o x"$THREAD_SAFE_CLIENT" != xno])
- if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
-
- if test "$with_server" = "no"
-@@ -2750,7 +2751,7 @@
- AM_CONDITIONAL([BUILD_INNODB_TOOLS], [false])
- else
- server_scripts="mysqld_safe mysql_install_db"
-- sql_server_dirs="strings mysys dbug extra regex"
-+ sql_server_dirs="strings dbug mysys extra regex"
-
-
- #
-diff -ur mysql-5.0.77-old/dbug/Makefile.am mysql-5.0.77/dbug/Makefile.am
---- mysql-5.0.77-old/dbug/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/dbug/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = ../mysys/libmysys.la ../strings/libmystrings.la
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = example1.c example2.c example3.c \
- user.r monty.doc readme.prof dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-@@ -31,11 +31,11 @@
-
-
- # Must be linked with libs that are not compiled yet
--noinst_PROGRAMS = factorial dbug_analyze
-+EXTRA_PROGRAMS = factorial dbug_analyze
- factorial_SOURCES = my_main.c factorial.c
- dbug_analyze_SOURCES = dbug_analyze.c
-
--all: user.t user.ps
-+check-local: user.t user.ps
-
- user.t: user.r $(NROFF_INC)
- -nroff -mm user.r > $@
-diff -ur mysql-5.0.77-old/extra/Makefile.am mysql-5.0.77/extra/Makefile.am
---- mysql-5.0.77-old/extra/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/extra/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,8 +15,7 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- @ndbcluster_includes@ -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-diff -ur mysql-5.0.77-old/heap/Makefile.am mysql-5.0.77/heap/Makefile.am
---- mysql-5.0.77-old/heap/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/heap/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -14,14 +14,13 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libheap.a ../mysys/libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
--pkglib_LIBRARIES = libheap.a
-+LDADD = libheap.la ../mysys/libmysys.la
-+pkglib_LTLIBRARIES = libheap.la
- noinst_PROGRAMS = hp_test1 hp_test2
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
- noinst_HEADERS = heapdef.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
-diff -ur mysql-5.0.77-old/innobase/btr/Makefile.am mysql-5.0.77/innobase/btr/Makefile.am
---- mysql-5.0.77-old/innobase/btr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/btr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbtr.a
-+noinst_LTLIBRARIES = libbtr.la
-
--libbtr_a_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-+libbtr_la_SOURCES = btr0btr.c btr0cur.c btr0pcur.c btr0sea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/buf/Makefile.am mysql-5.0.77/innobase/buf/Makefile.am
---- mysql-5.0.77-old/innobase/buf/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/buf/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libbuf.a
-+noinst_LTLIBRARIES = libbuf.la
-
--libbuf_a_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-+libbuf_la_SOURCES = buf0buf.c buf0flu.c buf0lru.c buf0rea.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/configure.in mysql-5.0.77/innobase/configure.in
---- mysql-5.0.77-old/innobase/configure.in 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/configure.in 2009-04-12 03:03:22.000000000 +0000
-@@ -32,7 +32,7 @@
- CXXFLAGS="$CXXFLAGS "
-
- AC_PROG_CC
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- AC_PROG_INSTALL
- AC_PROG_LIBTOOL
- AC_CHECK_HEADERS(aio.h sched.h)
-@@ -126,14 +126,4 @@
- fi
- AC_SUBST(ARFLAGS)
-
--AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile dnl
-- buf/Makefile data/Makefile dnl
-- dict/Makefile dyn/Makefile dnl
-- eval/Makefile fil/Makefile fsp/Makefile fut/Makefile dnl
-- ha/Makefile ibuf/Makefile include/Makefile dnl
-- lock/Makefile log/Makefile dnl
-- mach/Makefile mem/Makefile mtr/Makefile dnl
-- page/Makefile pars/Makefile que/Makefile dnl
-- read/Makefile rem/Makefile row/Makefile dnl
-- srv/Makefile sync/Makefile thr/Makefile trx/Makefile dnl
-- usr/Makefile)
-+AC_OUTPUT(Makefile)
-diff -ur mysql-5.0.77-old/innobase/data/Makefile.am mysql-5.0.77/innobase/data/Makefile.am
---- mysql-5.0.77-old/innobase/data/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/data/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdata.a
-+noinst_LTLIBRARIES = libdata.la
-
--libdata_a_SOURCES = data0data.c data0type.c
-+libdata_la_SOURCES = data0data.c data0type.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/dict/Makefile.am mysql-5.0.77/innobase/dict/Makefile.am
---- mysql-5.0.77-old/innobase/dict/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/innobase/dict/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdict.a
-+noinst_LTLIBRARIES = libdict.la
-
--libdict_a_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
-+libdict_la_SOURCES = dict0boot.c dict0crea.c dict0dict.c dict0load.c\
- dict0mem.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/dyn/Makefile.am mysql-5.0.77/innobase/dyn/Makefile.am
---- mysql-5.0.77-old/innobase/dyn/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/dyn/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libdyn.a
-+noinst_LTLIBRARIES = libdyn.la
-
--libdyn_a_SOURCES = dyn0dyn.c
-+libdyn_la_SOURCES = dyn0dyn.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/eval/Makefile.am mysql-5.0.77/innobase/eval/Makefile.am
---- mysql-5.0.77-old/innobase/eval/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/eval/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libeval.a
-+noinst_LTLIBRARIES = libeval.la
-
--libeval_a_SOURCES = eval0eval.c eval0proc.c
-+libeval_la_SOURCES = eval0eval.c eval0proc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fil/Makefile.am mysql-5.0.77/innobase/fil/Makefile.am
---- mysql-5.0.77-old/innobase/fil/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fil/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfil.a
-+noinst_LTLIBRARIES = libfil.la
-
--libfil_a_SOURCES = fil0fil.c
-+libfil_la_SOURCES = fil0fil.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fsp/Makefile.am mysql-5.0.77/innobase/fsp/Makefile.am
---- mysql-5.0.77-old/innobase/fsp/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fsp/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,9 +16,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfsp.a
-+noinst_LTLIBRARIES = libfsp.la
-
--libfsp_a_SOURCES = fsp0fsp.c
-+libfsp_la_SOURCES = fsp0fsp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/fut/Makefile.am mysql-5.0.77/innobase/fut/Makefile.am
---- mysql-5.0.77-old/innobase/fut/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/fut/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libfut.a
-+noinst_LTLIBRARIES = libfut.la
-
--libfut_a_SOURCES = fut0fut.c fut0lst.c
-+libfut_la_SOURCES = fut0fut.c fut0lst.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ha/Makefile.am mysql-5.0.77/innobase/ha/Makefile.am
---- mysql-5.0.77-old/innobase/ha/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ha/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libha.a
-+noinst_LTLIBRARIES = libha.la
-
--libha_a_SOURCES = ha0ha.c hash0hash.c
-+libha_la_SOURCES = ha0ha.c hash0hash.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ibuf/Makefile.am mysql-5.0.77/innobase/ibuf/Makefile.am
---- mysql-5.0.77-old/innobase/ibuf/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ibuf/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libibuf.a
-+noinst_LTLIBRARIES = libibuf.la
-
--libibuf_a_SOURCES = ibuf0ibuf.c
-+libibuf_la_SOURCES = ibuf0ibuf.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/lock/Makefile.am mysql-5.0.77/innobase/lock/Makefile.am
---- mysql-5.0.77-old/innobase/lock/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/lock/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblock.a
-+noinst_LTLIBRARIES = liblock.la
-
--liblock_a_SOURCES = lock0lock.c
-+liblock_la_SOURCES = lock0lock.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/log/Makefile.am mysql-5.0.77/innobase/log/Makefile.am
---- mysql-5.0.77-old/innobase/log/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/log/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = liblog.a
-+noinst_LTLIBRARIES = liblog.la
-
--liblog_a_SOURCES = log0log.c log0recv.c
-+liblog_la_SOURCES = log0log.c log0recv.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/mach/Makefile.am mysql-5.0.77/innobase/mach/Makefile.am
---- mysql-5.0.77-old/innobase/mach/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mach/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmach.a
-+noinst_LTLIBRARIES = libmach.la
-
--libmach_a_SOURCES = mach0data.c
-+libmach_la_SOURCES = mach0data.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/Makefile.am mysql-5.0.77/innobase/Makefile.am
---- mysql-5.0.77-old/innobase/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,14 +15,35 @@
-
- # Process this file with automake to create Makefile.in
-
--AUTOMAKE_OPTIONS = foreign
--TAR = gtar
--
- noinst_HEADERS = ib_config.h
-
--SUBDIRS = os ut btr buf data dict dyn eval fil fsp fut \
-- ha ibuf include lock log mach mem mtr page \
-- pars que read rem row srv sync thr trx usr
-+INCLUDES = -I$(srcdir)/include -I$(srcdir)/../include
-+
-+pkglib_LTLIBRARIES = libinnobase.la
-+
-+libinnobase_la_SOURCES = btr/btr0btr.c btr/btr0cur.c \
-+ btr/btr0pcur.c btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
-+ buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c \
-+ dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c \
-+ dict/dict0load.c dict/dict0mem.c dyn/dyn0dyn.c \
-+ eval/eval0eval.c eval/eval0proc.c fil/fil0fil.c \
-+ fsp/fsp0fsp.c fut/fut0fut.c fut/fut0lst.c ha/ha0ha.c \
-+ ha/hash0hash.c ibuf/ibuf0ibuf.c lock/lock0lock.c \
-+ log/log0log.c log/log0recv.c mach/mach0data.c \
-+ mem/mem0mem.c mem/mem0pool.c mtr/mtr0mtr.c mtr/mtr0log.c \
-+ os/os0proc.c os/os0sync.c os/os0thread.c os/os0file.c \
-+ page/page0page.c page/page0cur.c pars/pars0grm.c pars/lexyy.c \
-+ pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c \
-+ que/que0que.c read/read0read.c rem/rem0rec.c rem/rem0cmp.c \
-+ row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c \
-+ row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c \
-+ row/row0upd.c row/row0vers.c srv/srv0srv.c srv/srv0que.c \
-+ srv/srv0start.c sync/sync0arr.c sync/sync0rw.c \
-+ sync/sync0sync.c thr/thr0loc.c trx/trx0purge.c \
-+ trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c \
-+ trx/trx0trx.c trx/trx0undo.c usr/usr0sess.c ut/ut0byte.c \
-+ ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c
-+
- EXTRA_DIST = CMakeLists.txt
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/innobase/mem/Makefile.am mysql-5.0.77/innobase/mem/Makefile.am
---- mysql-5.0.77-old/innobase/mem/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mem/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmem.a
-+noinst_LTLIBRARIES = libmem.la
-
--libmem_a_SOURCES = mem0mem.c mem0pool.c
-+libmem_la_SOURCES = mem0mem.c mem0pool.c
-
- EXTRA_DIST = mem0dbg.c
-
-diff -ur mysql-5.0.77-old/innobase/mtr/Makefile.am mysql-5.0.77/innobase/mtr/Makefile.am
---- mysql-5.0.77-old/innobase/mtr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/mtr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libmtr.a
-+noinst_LTLIBRARIES = libmtr.la
-
--libmtr_a_SOURCES = mtr0mtr.c mtr0log.c
-+libmtr_la_SOURCES = mtr0mtr.c mtr0log.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/os/Makefile.am mysql-5.0.77/innobase/os/Makefile.am
---- mysql-5.0.77-old/innobase/os/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/os/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libos.a
-+noinst_LTLIBRARIES = libos.la
-
--libos_a_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-+libos_la_SOURCES = os0proc.c os0sync.c os0thread.c os0file.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/page/Makefile.am mysql-5.0.77/innobase/page/Makefile.am
---- mysql-5.0.77-old/innobase/page/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/page/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpage.a
-+noinst_LTLIBRARIES = libpage.la
-
--libpage_a_SOURCES = page0page.c page0cur.c
-+libpage_la_SOURCES = page0page.c page0cur.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/pars/Makefile.am mysql-5.0.77/innobase/pars/Makefile.am
---- mysql-5.0.77-old/innobase/pars/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/pars/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,11 +15,11 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libpars.a
-+noinst_LTLIBRARIES = libpars.la
-
- noinst_HEADERS = pars0grm.h
-
--libpars_a_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-+libpars_la_SOURCES = pars0grm.c lexyy.c pars0opt.c pars0pars.c pars0sym.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/que/Makefile.am mysql-5.0.77/innobase/que/Makefile.am
---- mysql-5.0.77-old/innobase/que/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/que/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libque.a
-+noinst_LTLIBRARIES = libque.la
-
--libque_a_SOURCES = que0que.c
-+libque_la_SOURCES = que0que.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/read/Makefile.am mysql-5.0.77/innobase/read/Makefile.am
---- mysql-5.0.77-old/innobase/read/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/read/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libread.a
-+noinst_LTLIBRARIES = libread.la
-
--libread_a_SOURCES = read0read.c
-+libread_la_SOURCES = read0read.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/rem/Makefile.am mysql-5.0.77/innobase/rem/Makefile.am
---- mysql-5.0.77-old/innobase/rem/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/rem/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librem.a
-+noinst_LTLIBRARIES = librem.la
-
--librem_a_SOURCES = rem0rec.c rem0cmp.c
-+librem_la_SOURCES = rem0rec.c rem0cmp.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/row/Makefile.am mysql-5.0.77/innobase/row/Makefile.am
---- mysql-5.0.77-old/innobase/row/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/row/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = librow.a
-+noinst_LTLIBRARIES = librow.la
-
--librow_a_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
-+librow_la_SOURCES = row0ins.c row0mysql.c row0purge.c row0row.c row0sel.c\
- row0uins.c row0umod.c row0undo.c row0upd.c row0vers.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/srv/Makefile.am mysql-5.0.77/innobase/srv/Makefile.am
---- mysql-5.0.77-old/innobase/srv/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/srv/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsrv.a
-+noinst_LTLIBRARIES = libsrv.la
-
--libsrv_a_SOURCES = srv0srv.c srv0que.c srv0start.c
-+libsrv_la_SOURCES = srv0srv.c srv0que.c srv0start.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/sync/Makefile.am mysql-5.0.77/innobase/sync/Makefile.am
---- mysql-5.0.77-old/innobase/sync/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/sync/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libsync.a
-+noinst_LTLIBRARIES = libsync.la
-
--libsync_a_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-+libsync_la_SOURCES = sync0arr.c sync0rw.c sync0sync.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/thr/Makefile.am mysql-5.0.77/innobase/thr/Makefile.am
---- mysql-5.0.77-old/innobase/thr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/thr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libthr.a
-+noinst_LTLIBRARIES = libthr.la
-
--libthr_a_SOURCES = thr0loc.c
-+libthr_la_SOURCES = thr0loc.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/trx/Makefile.am mysql-5.0.77/innobase/trx/Makefile.am
---- mysql-5.0.77-old/innobase/trx/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/trx/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libtrx.a
-+noinst_LTLIBRARIES = libtrx.la
-
--libtrx_a_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
-+libtrx_la_SOURCES = trx0purge.c trx0rec.c trx0roll.c trx0rseg.c\
- trx0sys.c trx0trx.c trx0undo.c
-
- EXTRA_PROGRAMS =
-diff -ur mysql-5.0.77-old/innobase/usr/Makefile.am mysql-5.0.77/innobase/usr/Makefile.am
---- mysql-5.0.77-old/innobase/usr/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/usr/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libusr.a
-+noinst_LTLIBRARIES = libusr.la
-
--libusr_a_SOURCES = usr0sess.c
-+libusr_la_SOURCES = usr0sess.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/innobase/ut/Makefile.am mysql-5.0.77/innobase/ut/Makefile.am
---- mysql-5.0.77-old/innobase/ut/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/innobase/ut/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -15,9 +15,9 @@
-
- include ../include/Makefile.i
-
--noinst_LIBRARIES = libut.a
-+noinst_LTLIBRARIES = libut.la
-
--libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-+libut_la_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
-
- EXTRA_PROGRAMS =
-
-diff -ur mysql-5.0.77-old/libmysql/Makefile.am mysql-5.0.77/libmysql/Makefile.am
---- mysql-5.0.77-old/libmysql/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/libmysql/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -106,8 +106,8 @@
- echo "# This file is autogenerated from Makefile.am" >> $$dir/Makefile; \
- echo 'CFLAGS= -I. -DUNDEF_THREADS_HACK' >>$$dir/Makefile; \
- echo "obj=$$objs" >>$$dir/Makefile; \
-- echo 'all: libmysql.a' >>$$dir/Makefile; \
-- echo 'libmysql.a: $$(obj)' >>$$dir/Makefile; \
-+ echo 'all: libmysql.la' >>$$dir/Makefile; \
-+ echo 'libmysql.la: $$(obj)' >>$$dir/Makefile; \
- echo ' $$(AR) r $$@ $$?' >>$$dir/Makefile; \
- gtar cvzf $$dir.tar.gz $$dir; \
- cd $$dir; gmake
-diff -ur mysql-5.0.77-old/libmysqld/examples/Makefile.am mysql-5.0.77/libmysqld/examples/Makefile.am
---- mysql-5.0.77-old/libmysqld/examples/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/libmysqld/examples/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -35,12 +35,12 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) \
- @NDB_SCI_LIBS@
-
- mysqltest_embedded_LINK = $(CXXLINK)
- mysqltest_embedded_SOURCES = mysqltest.c
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la
-
- mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
- my_readline.h sql_string.h completion_hash.h
-diff -ur mysql-5.0.77-old/libmysqld/Makefile.am mysql-5.0.77/libmysqld/Makefile.am
---- mysql-5.0.77-old/libmysqld/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/libmysqld/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -32,10 +32,10 @@
- -I$(top_srcdir)/regex \
- $(openssl_includes) @ZLIB_INCLUDES@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+noinst_LTLIBRARIES = libmysqld_int.la
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
--libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
-+#libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
- my_time.c
- sqlexamplessources = ha_example.cc ha_tina.cc
-@@ -67,50 +67,22 @@
- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
- ha_blackhole.cc ha_archive.cc my_user.c
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
--libmysqld_a_SOURCES=
-+libmysqld_int_la_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
-+#libmysqld_la_SOURCES=
-+libmysqld_la_SOURCES= libmysqld.c lib_sql.cc emb_qcache.cc
-
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
--# The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- @innodb_libs@ @bdb_libs_with_path@ \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a @NDB_SCI_LIBS@
--
--
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u`
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a libmysqld_int.a $(INC_LIB) ; \
-- else \
-- for arc in ./libmysqld_int.a $(INC_LIB); do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'`; \
-- $(AR) t $$arc|sed "s|^|$$arpath|"; \
-- done | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(RANLIB) libmysqld.a ; \
-- fi
--endif
-+# The following libraries should be included in libmysqld.la
-+libmysqld_la_LIBADD= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/innobase/libinnobase.la @bdb_libs_with_path@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/vio/libvio.la @NDB_SCI_LIBS@ \
-+ libmysqld_int.la
-
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
-diff -ur mysql-5.0.77-old/myisam/Makefile.am mysql-5.0.77/myisam/Makefile.am
---- mysql-5.0.77-old/myisam/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/myisam/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,27 +16,27 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--pkglib_LIBRARIES = libmyisam.a
-+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
-+ -I$(top_builddir)/sql -I$(top_srcdir)/sql
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(ZLIB_LIBS)
-+noinst_LTLIBRARIES = libmyisam.la
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisampack_DEPENDENCIES=$(LIBRARIES)
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h fulltext.h ftdefs.h ft_test1.h ft_eval.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--rt_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_DEPENDENCIES= $(LIBRARIES)
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-diff -ur mysql-5.0.77-old/myisammrg/Makefile.am mysql-5.0.77/myisammrg/Makefile.am
---- mysql-5.0.77-old/myisammrg/Makefile.am 2009-04-12 02:31:07.000000000 +0000
-+++ mysql-5.0.77/myisammrg/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -14,9 +14,9 @@
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la
- noinst_HEADERS = myrg_def.h
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
-diff -ur mysql-5.0.77-old/mysys/Makefile.am mysql-5.0.77/mysys/Makefile.am
---- mysql-5.0.77-old/mysys/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/mysys/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -18,11 +18,9 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a ../dbug/libdbug.a \
-- ../strings/libmystrings.a
-+pkglib_LTLIBRARIES = libmysys.la
- noinst_HEADERS = mysys_priv.h my_static.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -49,21 +47,26 @@
- my_quick.c my_lockmem.c my_static.c \
- my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
-- my_compress.c checksum.c raid.cc \
-+ my_compress.c checksum.c raid.cc \
- my_net.c my_port.c my_sleep.c \
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
-- my_memmem.c \
-- my_windac.c my_access.c base64.c my_libwrap.c
-+ my_memmem.c my_windac.c my_access.c base64.c \
-+ my_libwrap.c
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-+if NEED_THREADS
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c my_pthread.c my_thr_init.c
-+endif
-+
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c mf_soundex.c my_conio.c \
- my_wincond.c my_winthread.c CMakeLists.txt
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- EXTRA_PROGRAMS =
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DDATADIR="\"$(MYSQLDATAdir)\"" \
-@@ -74,8 +77,6 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -84,41 +85,41 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-diff -ur mysql-5.0.77-old/netware/Makefile.am mysql-5.0.77/netware/Makefile.am
---- mysql-5.0.77-old/netware/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/netware/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,14 +16,13 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
- mysql_test_run_SOURCES= mysql_test_run.c my_manage.c
- libmysql_SOURCES= libmysqlmain.c
--libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a \
-+libmysql_LDADD = ../libmysql/.libs/libmysqlclient.la \
- @openssl_libs@ @yassl_libs@
-
- netware_build_files = client/mysql.def client/mysqladmin.def \
-diff -ur mysql-5.0.77-old/pstack/Makefile.am mysql-5.0.77/pstack/Makefile.am
---- mysql-5.0.77-old/pstack/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/pstack/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -27,8 +27,8 @@
- EXTRA_DIST= $(SRC)
-
- if COMPILE_PSTACK
--pkglib_LIBRARIES = libpstack.a
--libpstack_a_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
-+pkglib_LTLIBRARIES = libpstack.la
-+libpstack_la_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
- endif
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/regex/Makefile.am mysql-5.0.77/regex/Makefile.am
---- mysql-5.0.77-old/regex/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/regex/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-diff -ur mysql-5.0.77-old/server-tools/instance-manager/Makefile.am mysql-5.0.77/server-tools/instance-manager/Makefile.am
---- mysql-5.0.77-old/server-tools/instance-manager/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/server-tools/instance-manager/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -24,8 +24,7 @@
- # default_options.h, generated from default_options.h.in)
- # See automake/autoconf docs for details
-
--noinst_LTLIBRARIES= liboptions.la
--noinst_LIBRARIES= libnet.a
-+noinst_LTLIBRARIES= liboptions.la libnet.la
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-@@ -37,17 +36,17 @@
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
--liboptions_la_LIBADD= $(top_builddir)/libmysql/get_password.lo
-+
-+liboptions_la_LIBADD= $(top_builddir)/libmysql/libmysqlclient.la
-
- # MySQL sometimes uses symlinks to reuse code
- # All symlinked files are grouped in libnet.a
-
--nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
--libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
-- $(top_builddir)/sql/pack.$(OBJEXT) \
-- $(top_builddir)/sql/sql_state.$(OBJEXT) \
-- $(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
-- $(top_builddir)/sql/client.$(OBJEXT)
-+nodist_libnet_la_SOURCES= net_serv.cc client_settings.h \
-+ $(srcdir)/../../sql/password.c $(srcdir)/../../sql/pack.c \
-+ $(srcdir)/../../sql/sql_state.c $(srcdir)/../../sql/mini_client_errors.c \
-+ $(srcdir)/../../sql/client.c
-+
-
- CLEANFILES= net_serv.cc client_settings.h
-
-@@ -79,11 +78,11 @@
- portability.h
-
- mysqlmanager_LDADD= liboptions.la \
-- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ libnet.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
-
-diff -ur mysql-5.0.77-old/sql/Makefile.am mysql-5.0.77/sql/Makefile.am
---- mysql-5.0.77-old/sql/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/sql/Makefile.am 2009-04-12 05:04:23.000000000 +0000
-@@ -22,25 +22,24 @@
- @bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \
- -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/regex -I$(srcdir) \
-- $(openssl_includes)
-+ $(openssl_includes)
- WRAPLIBS= @WRAPLIBS@
- SUBDIRS = share
- libexec_PROGRAMS = mysqld
- EXTRA_PROGRAMS = gen_lex_hash
- bin_PROGRAMS = mysql_tzinfo_to_sql
- gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@
--LDADD = $(top_builddir)/myisam/libmyisam.a \
-- $(top_builddir)/myisammrg/libmyisammrg.a \
-- $(top_builddir)/heap/libheap.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ @NDB_SCI_LIBS@
--
--mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-- @bdb_libs@ @innodb_libs@ @pstack_libs@ \
-- @innodb_system_libs@ \
-+LDADD = $(top_builddir)/myisam/libmyisam.la \
-+ $(top_builddir)/myisammrg/libmyisammrg.la \
-+ $(top_builddir)/heap/libheap.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+
-+mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
-+ @bdb_libs@ $(top_builddir)/innobase/libinnobase.la \
-+ @pstack_libs@ @innodb_system_libs@ \
- @ndbcluster_libs@ @ndbcluster_system_libs@ \
- $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
- $(yassl_libs) $(openssl_libs) @MYSQLD_EXTRA_LIBS@
-@@ -52,45 +51,36 @@
- procedure.h sql_class.h sql_lex.h sql_list.h \
- sql_manager.h sql_map.h sql_string.h unireg.h \
- sql_error.h field.h handler.h mysqld_suffix.h \
-- sql_profile.h \
-- ha_myisammrg.h\
-- ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \
-- ha_ndbcluster.h ha_ndbcluster_cond.h \
-- opt_range.h protocol.h \
-- sql_select.h structs.h table.h sql_udf.h hash_filo.h\
-- lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-- log_event.h sql_repl.h slave.h \
-- stacktrace.h sql_sort.h sql_cache.h set_var.h \
-- spatial.h gstream.h client_settings.h tzfile.h \
-- tztime.h my_decimal.h\
-+ sql_profile.h ha_heap.h ha_berkeley.h ha_innodb.h \
-+ ha_ndbcluster.h ha_ndbcluster_cond.h opt_range.h \
-+ protocol.h sql_select.h structs.h table.h sql_udf.h \
-+ hash_filo.h lex.h lex_symbol.h sql_acl.h sql_crypt.h \
-+ log_event.h sql_repl.h slave.h stacktrace.h sql_sort.h \
-+ sql_cache.h set_var.h spatial.h gstream.h \
-+ client_settings.h tzfile.h tztime.h my_decimal.h \
- sp_head.h sp_pcontext.h sp_rcontext.h sp.h sp_cache.h \
-- parse_file.h sql_view.h sql_trigger.h \
-- sql_array.h sql_cursor.h \
-- examples/ha_example.h ha_archive.h \
-- examples/ha_tina.h ha_blackhole.h \
-+ parse_file.h sql_view.h sql_trigger.h \
-+ sql_array.h sql_cursor.h examples/ha_example.h \
-+ ha_archive.h examples/ha_tina.h ha_blackhole.h \
- ha_federated.h
--mysqld_SOURCES = sql_lex.cc sql_handler.cc \
-- item.cc item_sum.cc item_buff.cc item_func.cc \
-- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-- thr_malloc.cc item_create.cc item_subselect.cc \
-- item_row.cc item_geofunc.cc \
-- field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \
-- net_serv.cc protocol.cc sql_state.c \
-- lock.cc my_lock.c \
-- sql_string.cc sql_manager.cc sql_map.cc \
-- mysqld.cc password.c hash_filo.cc hostname.cc \
-- set_var.cc sql_parse.cc sql_yacc.yy \
-- sql_base.cc table.cc sql_select.cc sql_insert.cc \
-- sql_prepare.cc sql_error.cc sql_locale.cc \
-- sql_profile.cc \
-- sql_update.cc sql_delete.cc uniques.cc sql_do.cc \
-- procedure.cc item_uniq.cc sql_test.cc \
-- log.cc log_event.cc init.cc derror.cc sql_acl.cc \
-- unireg.cc des_key_file.cc \
-- discover.cc time.cc opt_range.cc opt_sum.cc \
-- records.cc filesort.cc handler.cc \
-- ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
-- ha_berkeley.cc ha_innodb.cc \
-+mysqld_SOURCES = sql_lex.cc sql_handler.cc item.cc item_sum.cc \
-+ item_buff.cc item_func.cc item_cmpfunc.cc \
-+ item_strfunc.cc item_timefunc.cc thr_malloc.cc \
-+ item_create.cc item_subselect.cc item_row.cc \
-+ item_geofunc.cc field.cc strfunc.cc key.cc \
-+ sql_class.cc sql_list.cc net_serv.cc protocol.cc \
-+ sql_state.c lock.cc my_lock.c sql_string.cc \
-+ sql_manager.cc sql_map.cc mysqld.cc password.c \
-+ hash_filo.cc hostname.cc set_var.cc sql_parse.cc \
-+ sql_yacc.yy sql_base.cc table.cc sql_select.cc \
-+ sql_insert.cc sql_prepare.cc sql_error.cc \
-+ sql_locale.cc sql_profile.cc sql_update.cc \
-+ sql_delete.cc uniques.cc sql_do.cc procedure.cc \
-+ item_uniq.cc sql_test.cc log.cc log_event.cc \
-+ init.cc derror.cc sql_acl.cc unireg.cc \
-+ des_key_file.cc discover.cc time.cc opt_range.cc \
-+ opt_sum.cc records.cc filesort.cc handler.cc \
-+ ha_heap.cc ha_berkeley.cc ha_innodb.cc \
- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
- sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
- sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
-@@ -98,14 +88,13 @@
- slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
- client.c sql_client.cc mini_client_errors.c pack.c\
- stacktrace.c repl_failsafe.h repl_failsafe.cc \
-- sql_olap.cc sql_view.cc \
-- gstream.cc spatial.cc sql_help.cc sql_cursor.cc \
-- tztime.cc my_time.c my_user.c my_decimal.cc\
-- sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \
-- sp_cache.cc parse_file.cc sql_trigger.cc \
-- examples/ha_example.cc ha_archive.cc \
-- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ sql_olap.cc sql_view.cc gstream.cc spatial.cc \
-+ sql_help.cc sql_cursor.cc tztime.cc my_time.c \
-+ my_user.c my_decimal.cc sp_head.cc sp_pcontext.cc \
-+ sp_rcontext.cc sp.cc sp_cache.cc parse_file.cc \
-+ sql_trigger.cc examples/ha_example.cc ha_archive.cc \
-+ examples/ha_tina.cc ha_blackhole.cc ha_federated.cc \
-+ ha_myisam.cc ha_myisammrg.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -ur mysql-5.0.77-old/strings/Makefile.am mysql-5.0.77/strings/Makefile.am
---- mysql-5.0.77-old/strings/Makefile.am 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/strings/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- # Default charset definitions
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
-@@ -54,25 +54,25 @@
- strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
- t_ctype.h CMakeLists.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
--conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-+#conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- # This is because the dependency tracking misses @FOO@ vars in sources.
- #strtoull.o: @CHARSET_OBJS@
-
-
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
--test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
-+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/strings/strings-x86.s mysql-5.0.77/strings/strings-x86.s
---- mysql-5.0.77-old/strings/strings-x86.s 2009-04-12 02:30:57.000000000 +0000
-+++ mysql-5.0.77/strings/strings-x86.s 2009-04-12 03:03:22.000000000 +0000
-@@ -293,7 +293,7 @@
- movl %esp,%ebp
- pushl 12(%ebp) # search
- pushl 8(%ebp) # str
-- call strstr
-+ call strstr@plt
- add $8,%esp
- or %eax,%eax
- jz si_99 # Not found, return NULL
-diff -ur mysql-5.0.77-old/tests/Makefile.am mysql-5.0.77/tests/Makefile.am
---- mysql-5.0.77-old/tests/Makefile.am 2009-04-12 02:31:04.000000000 +0000
-+++ mysql-5.0.77/tests/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -42,11 +42,11 @@
-
- insert_test_SOURCES= insert_test.c
- select_test_SOURCES= select_test.c
--insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
--select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+insert_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-+select_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- bug25714_SOURCES= bug25714.c
--bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+bug25714_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- # Fix for mit-threads
- DEFS = -DUNDEF_THREADS_HACK
-diff -ur mysql-5.0.77-old/tools/Makefile.am mysql-5.0.77/tools/Makefile.am
---- mysql-5.0.77-old/tools/Makefile.am 2009-04-12 02:30:58.000000000 +0000
-+++ mysql-5.0.77/tools/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -23,7 +23,7 @@
-
- bin_PROGRAMS= mysqltestmanager
- mysqltestmanager_SOURCES= mysqlmanager.c
--mysqltestmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+mysqltestmanager_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
- DEF= -DUNDEF_THREADS_HACK
-
- # Don't update the files from bitkeeper
-diff -ur mysql-5.0.77-old/vio/Makefile.am mysql-5.0.77/vio/Makefile.am
---- mysql-5.0.77-old/vio/Makefile.am 2009-04-12 02:30:59.000000000 +0000
-+++ mysql-5.0.77/vio/Makefile.am 2009-04-12 03:03:22.000000000 +0000
-@@ -16,11 +16,12 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_LIBADD = -lssl
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
-diff -Nuar mysql.orig/ndb/src/common/util/Makefile.am mysql/ndb/src/common/util/Makefile.am
---- mysql.orig/ndb/src/common/util/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/common/util/Makefile.am 2009-04-11 16:36:38.520666040 -0700
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-diff -Nuar mysql.orig/ndb/src/cw/cpcd/Makefile.am mysql/ndb/src/cw/cpcd/Makefile.am
---- mysql.orig/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/cw/cpcd/Makefile.am 2009-04-11 16:36:32.185153480 -0700
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/ndb/config/common.mk.am
- include $(top_srcdir)/ndb/config/type_util.mk.am
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am mysql/ndb/src/kernel/blocks/dbdict/Makefile.am
---- mysql.orig/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/blocks/dbdict/Makefile.am 2009-04-11 16:37:40.586744073 -0700
-@@ -26,9 +26,9 @@
- LDADD += \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/kernel/Makefile.am mysql/ndb/src/kernel/Makefile.am
---- mysql.orig/ndb/src/kernel/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/kernel/Makefile.am 2009-04-11 16:37:20.953412135 -0700
-@@ -66,9 +66,9 @@
- $(top_builddir)/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -Nuar mysql.orig/ndb/src/mgmclient/Makefile.am mysql/ndb/src/mgmclient/Makefile.am
---- mysql.orig/ndb/src/mgmclient/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmclient/Makefile.am 2009-04-11 16:36:16.280363648 -0700
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-diff -Nuar mysql.orig/ndb/src/mgmsrv/Makefile.am mysql/ndb/src/mgmsrv/Makefile.am
---- mysql.orig/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/src/mgmsrv/Makefile.am 2009-04-11 16:36:22.920358437 -0700
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-diff -Nuar mysql.orig/ndb/test/run-test/Makefile.am mysql/ndb/test/run-test/Makefile.am
---- mysql.orig/ndb/test/run-test/Makefile.am 2009-04-11 16:31:18.000000000 -0700
-+++ mysql/ndb/test/run-test/Makefile.am 2009-04-11 16:36:07.367509286 -0700
-@@ -32,9 +32,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include
- LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- wrappersdir=$(prefix)/bin
- wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run
-diff -Nuar mysql.orig/ndb/config/type_ndbapitest.mk.am mysql/ndb/config/type_ndbapitest.mk.am
---- mysql.orig/ndb/config/type_ndbapitest.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitest.mk.am 2009-04-11 16:44:10.268399273 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(top_srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/type_ndbapitools.mk.am mysql/ndb/config/type_ndbapitools.mk.am
---- mysql.orig/ndb/config/type_ndbapitools.mk.am 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/type_ndbapitools.mk.am 2009-04-11 16:44:04.156084503 -0700
-@@ -15,9 +15,9 @@
-
- LDADD += \
- $(top_builddir)/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(srcdir) \
- -I$(top_builddir)/include \
-diff -Nuar mysql.orig/ndb/config/win-libraries mysql/ndb/config/win-libraries
---- mysql.orig/ndb/config/win-libraries 2009-01-15 09:47:06.000000000 -0800
-+++ mysql/ndb/config/win-libraries 2009-04-11 16:44:33.724336658 -0700
-@@ -21,7 +21,7 @@
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
diff --git a/02040_all_embedded-library-shared-5.1.39.patch b/02040_all_embedded-library-shared-5.1.39.patch
deleted file mode 100644
index 26e30b0..0000000
--- a/02040_all_embedded-library-shared-5.1.39.patch
+++ /dev/null
@@ -1,933 +0,0 @@
-diff -urN mysql-orig/client/Makefile.am mysql/client/Makefile.am
---- mysql-orig/client/Makefile.am 2010-01-18 01:46:52.550600312 -0100
-+++ mysql/client/Makefile.am 2010-01-18 01:47:04.212349982 -0100
-@@ -75,7 +75,7 @@
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +84,15 @@
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-diff -urN mysql-orig/configure.in mysql/configure.in
---- mysql-orig/configure.in 2010-01-18 01:46:52.590602692 -0100
-+++ mysql/configure.in 2010-01-18 01:47:04.219349120 -0100
-@@ -227,7 +227,7 @@
- fi
-
- # Still need ranlib for readline; local static use only so no libtool.
--AC_PROG_RANLIB
-+#AC_PROG_RANLIB
- # We use libtool
- #AC_LIBTOOL_WIN32_DLL
- AC_PROG_LIBTOOL
-@@ -528,6 +528,9 @@
- # We need an ANSI C compiler
- AM_PROG_CC_STDC
-
-+# Testing as sugggested by Diego
-+AM_PROG_CC_C_O
-+
- # We need an assembler, too
- AM_PROG_AS
- CCASFLAGS="$CCASFLAGS $ASFLAGS"
-@@ -2779,15 +2782,13 @@
- AC_SUBST(netware_dir)
- AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware")
-
--if test "$with_server" = "yes" -o "$THREAD_SAFE_CLIENT" != "no"
-+AM_CONDITIONAL([NEED_THREADS], [test x"$with_server" != xno -o x"$THREAD_SAFE_CLIENT" != xno])
-+if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- server_scripts="mysqld_safe mysql_install_db"
-- sql_server_dirs="strings mysys dbug extra regex"
-+ sql_server_dirs="strings dbug mysys extra regex"
-
- sql_server="vio sql"
- fi
-diff -urN mysql-orig/dbug/Makefile.am mysql/dbug/Makefile.am
---- mysql-orig/dbug/Makefile.am 2010-01-18 01:46:52.557379772 -0100
-+++ mysql/dbug/Makefile.am 2010-01-18 01:47:04.222349294 -0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = ../mysys/libmysys.la ../strings/libmystrings.la
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-@@ -31,11 +31,11 @@
-
-
- # Must be linked with libs that are not compiled yet
--noinst_PROGRAMS = factorial dbug_analyze
-+EXTRA_PROGRAMS = factorial dbug_analyze
- factorial_SOURCES = my_main.c factorial.c
- dbug_analyze_SOURCES = dbug_analyze.c
-
--all: user.t user.ps
-+check-local: user.t user.ps
-
- user.t: user.r $(NROFF_INC)
- -nroff -mm user.r > $@
-diff -urN mysql-orig/extra/Makefile.am mysql/extra/Makefile.am
---- mysql-orig/extra/Makefile.am 2010-01-18 01:46:52.556600091 -0100
-+++ mysql/extra/Makefile.am 2010-01-18 01:47:04.222349294 -0100
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-diff -urN mysql-orig/libmysqld/Makefile.am mysql/libmysqld/Makefile.am
---- mysql-orig/libmysqld/Makefile.am 2010-01-18 01:46:52.465599546 -0100
-+++ mysql/libmysqld/Makefile.am 2010-01-18 01:47:04.223349106 -0100
-@@ -36,8 +36,8 @@
- $(openssl_includes) @ZLIB_INCLUDES@ \
- @condition_dependent_plugin_includes@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+noinst_LTLIBRARIES = libmysqld_int.la
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
- libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
-@@ -78,9 +78,9 @@
- rpl_injector.cc my_user.c partition_info.cc \
- sql_servers.cc event_parse_data.cc
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
-+libmysqld_int_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_int_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_SOURCES=
-
- sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
- storagesources = @condition_dependent_plugin_modules@
-@@ -90,19 +90,19 @@
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
--# The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-+# The following libraries should be included in libmysqld.la
-+INC_LIB= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
- @NDB_SCI_LIBS@ \
- @mysql_plugin_libs@ \
- $(yassl_inc_libs)
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.la
- endif
-
- # Storage engine specific compilation options
-@@ -140,7 +140,7 @@
-
- #
- # To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
-+# generate a total libmysqld.la from all library files,
-
- # note - InnoDB libraries have circular dependencies, so in INC_LIB
- # few libraries are present two times. Metrowerks linker doesn't like
-@@ -148,7 +148,7 @@
- # need to add the same file twice to the library, so 'sort -u' save us
- # some time and spares unnecessary work.
-
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
-+libmysqld.la: libmysqld_int.la $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
- if DARWIN_MWCC
- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
- else
-diff -urN mysql-orig/mysys/Makefile.am mysql/mysys/Makefile.am
---- mysql-orig/mysys/Makefile.am 2010-01-18 01:46:52.560601059 -0100
-+++ mysql/mysys/Makefile.am 2010-01-18 01:48:11.044349196 -0100
-@@ -18,10 +18,9 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+pkglib_LTLIBRARIES = libmysys.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -46,18 +45,22 @@
- my_quick.c my_lockmem.c my_static.c \
- my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
-- my_compress.c checksum.c \
-+ my_compress.c checksum.c \
- my_net.c my_port.c my_sleep.c \
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
- my_handler.c my_netware.c my_largepage.c \
- my_memmem.c stacktrace.c \
- my_windac.c my_access.c base64.c my_libwrap.c
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-+if NEED_THREADS
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c my_pthread.c my_thr_init.c
-+endif
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
- # test_dir_DEPENDENCIES= $(LIBRARIES)
- # testhash_DEPENDENCIES= $(LIBRARIES)
- # test_charset_DEPENDENCIES= $(LIBRARIES)
-@@ -71,57 +74,55 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
- #
- # The CP .. RM stuff is to avoid problems with some compilers (like alpha ccc)
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-diff -urN mysql-orig/netware/BUILD/compile-linux-tools mysql/netware/BUILD/compile-linux-tools
---- mysql-orig/netware/BUILD/compile-linux-tools 2010-01-18 01:46:52.466599396 -0100
-+++ mysql/netware/BUILD/compile-linux-tools 2010-01-18 01:47:04.224349576 -0100
-@@ -34,14 +34,14 @@
- # Create mysql_version.h which was deleted my previous step
- ./config.status include/mysql_version.h
-
--(cd dbug; make libdbug.a)
--(cd strings; make libmystrings.a)
--(cd mysys; make libmysys.a)
--(cd storage/heap; make libheap.a)
--(cd vio; make libvio.a)
--(cd regex; make libregex.a)
--(cd storage/myisam; make libmyisam.a)
--(cd storage/myisammrg; make libmyisammrg.a)
-+(cd dbug; make libdbug.la)
-+(cd strings; make libmystrings.la)
-+(cd mysys; make libmysys.la)
-+(cd storage/heap; make libheap.la)
-+(cd vio; make libvio.la)
-+(cd regex; make libregex.la)
-+(cd storage/myisam; make libmyisam.la)
-+(cd storage/myisammrg; make libmyisammrg.la)
- (cd extra; make comp_err)
- (cd libmysql; make conf_to_src)
- (cd libmysql_r; make conf_to_src)
-diff -urN mysql-orig/netware/Makefile.am mysql/netware/Makefile.am
---- mysql-orig/netware/Makefile.am 2010-01-18 01:46:52.465599546 -0100
-+++ mysql/netware/Makefile.am 2010-01-18 01:47:04.224349576 -0100
-@@ -16,14 +16,14 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
- mysql_test_run_SOURCES= mysql_test_run.c my_manage.c
- libmysql_SOURCES= libmysqlmain.c
--libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a \
-+libmysql_LDADD = ../libmysql/.libs/libmysqlclient.la \
- @openssl_libs@ @yassl_libs@
-
- netware_build_files = client/mysql.def client/mysqladmin.def \
-diff -urN mysql-orig/regex/Makefile.am mysql/regex/Makefile.am
---- mysql-orig/regex/Makefile.am 2010-01-18 01:46:52.552600210 -0100
-+++ mysql/regex/Makefile.am 2010-01-18 01:47:04.225349352 -0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-diff -urN mysql-orig/server-tools/instance-manager/Makefile.am mysql/server-tools/instance-manager/Makefile.am
---- mysql-orig/server-tools/instance-manager/Makefile.am 2010-01-18 01:46:52.328599488 -0100
-+++ mysql/server-tools/instance-manager/Makefile.am 2010-01-18 01:47:04.225349352 -0100
-@@ -87,10 +87,10 @@
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-diff -urN mysql-orig/sql/Makefile.am mysql/sql/Makefile.am
---- mysql-orig/sql/Makefile.am 2010-01-18 01:46:52.485600506 -0100
-+++ mysql/sql/Makefile.am 2010-01-18 01:47:04.226349803 -0100
-@@ -32,11 +32,11 @@
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
- LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
- mysqld_LDADD = libndb.la \
-diff -urN mysql-orig/storage/archive/Makefile.am mysql/storage/archive/Makefile.am
---- mysql-orig/storage/archive/Makefile.am 2010-01-18 01:46:52.548600217 -0100
-+++ mysql/storage/archive/Makefile.am 2010-01-18 01:47:04.226349803 -0100
-@@ -50,17 +50,17 @@
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-diff -urN mysql-orig/storage/heap/Makefile.am mysql/storage/heap/Makefile.am
---- mysql-orig/storage/heap/Makefile.am 2010-01-18 01:46:52.547599931 -0100
-+++ mysql/storage/heap/Makefile.am 2010-01-18 01:47:04.226349803 -0100
-@@ -26,21 +26,20 @@
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
-+noinst_LTLIBRARIES = libheap.la
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
-diff -urN mysql-orig/storage/myisam/Makefile.am mysql/storage/myisam/Makefile.am
---- mysql-orig/storage/myisam/Makefile.am 2010-01-18 01:46:52.523600801 -0100
-+++ mysql/storage/myisam/Makefile.am 2010-01-18 01:47:04.227349669 -0100
-@@ -30,60 +30,60 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--pkglib_LIBRARIES = libmyisam.a
-+pkglib_LTLIBRARIES = libmyisam.la
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
-+myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-@@ -100,6 +100,8 @@
- ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c \
- ha_myisam.cc \
- rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/libmysqld/libmysqld.la $(ZLIB_LIBS)
- CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-
- # Move to automake rules ?
-diff -urN mysql-orig/storage/ndb/src/common/util/Makefile.am mysql/storage/ndb/src/common/util/Makefile.am
---- mysql-orig/storage/ndb/src/common/util/Makefile.am 2010-01-18 01:46:52.517599678 -0100
-+++ mysql/storage/ndb/src/common/util/Makefile.am 2010-01-18 01:47:04.227349669 -0100
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-diff -urN mysql-orig/storage/ndb/src/cw/cpcd/Makefile.am mysql/storage/ndb/src/cw/cpcd/Makefile.am
---- mysql-orig/storage/ndb/src/cw/cpcd/Makefile.am 2010-01-18 01:46:52.502599230 -0100
-+++ mysql/storage/ndb/src/cw/cpcd/Makefile.am 2010-01-18 01:47:04.228349376 -0100
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/backup/Makefile.am mysql/storage/ndb/src/kernel/blocks/backup/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-01-18 01:46:52.513600285 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-01-18 01:47:04.228349376 -0100
-@@ -17,9 +17,9 @@
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/dbdict/Makefile.am mysql/storage/ndb/src/kernel/blocks/dbdict/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-01-18 01:46:52.511599989 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-01-18 01:47:04.229349503 -0100
-@@ -19,17 +19,17 @@
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/dbdih/Makefile.am mysql/storage/ndb/src/kernel/blocks/dbdih/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-01-18 01:46:52.511599989 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-01-18 01:47:04.229349503 -0100
-@@ -17,9 +17,9 @@
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/dblqh/Makefile.am mysql/storage/ndb/src/kernel/blocks/dblqh/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-01-18 01:46:52.509350647 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-01-18 01:47:04.229349503 -0100
-@@ -23,9 +23,9 @@
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/dbtup/Makefile.am mysql/storage/ndb/src/kernel/blocks/dbtup/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-01-18 01:46:52.508599179 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-01-18 01:47:04.230349438 -0100
-@@ -20,9 +20,9 @@
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/Makefile.am mysql/storage/ndb/src/kernel/blocks/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/blocks/Makefile.am 2010-01-18 01:46:52.506600310 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/Makefile.am 2010-01-18 01:47:04.230349438 -0100
-@@ -57,9 +57,9 @@
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-diff -urN mysql-orig/storage/ndb/src/kernel/Makefile.am mysql/storage/ndb/src/kernel/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/Makefile.am 2010-01-18 01:46:52.515599481 -0100
-+++ mysql/storage/ndb/src/kernel/Makefile.am 2010-01-18 01:47:04.231349739 -0100
-@@ -53,9 +53,9 @@
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- windoze-dsp: ndbd.dsp
-
-diff -urN mysql-orig/storage/ndb/src/kernel/vm/Makefile.am mysql/storage/ndb/src/kernel/vm/Makefile.am
---- mysql-orig/storage/ndb/src/kernel/vm/Makefile.am 2010-01-18 01:46:52.515599481 -0100
-+++ mysql/storage/ndb/src/kernel/vm/Makefile.am 2010-01-18 01:47:04.231349739 -0100
-@@ -65,24 +65,24 @@
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
- bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-diff -urN mysql-orig/storage/ndb/src/mgmclient/Makefile.am mysql/storage/ndb/src/mgmclient/Makefile.am
---- mysql-orig/storage/ndb/src/mgmclient/Makefile.am 2010-01-18 01:46:52.502599230 -0100
-+++ mysql/storage/ndb/src/mgmclient/Makefile.am 2010-01-18 01:47:04.232349675 -0100
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-diff -urN mysql-orig/storage/ndb/src/mgmsrv/Makefile.am mysql/storage/ndb/src/mgmsrv/Makefile.am
---- mysql-orig/storage/ndb/src/mgmsrv/Makefile.am 2010-01-18 01:46:52.505600159 -0100
-+++ mysql/storage/ndb/src/mgmsrv/Makefile.am 2010-01-18 01:47:04.232349675 -0100
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-diff -urN mysql-orig/storage/ndb/src/ndbapi/Makefile.am mysql/storage/ndb/src/ndbapi/Makefile.am
---- mysql-orig/storage/ndb/src/ndbapi/Makefile.am 2010-01-18 01:46:52.504600208 -0100
-+++ mysql/storage/ndb/src/ndbapi/Makefile.am 2010-01-18 01:47:04.233349487 -0100
-@@ -67,9 +67,9 @@
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
- ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql-orig/storage/ndb/test/run-test/Makefile.am mysql/storage/ndb/test/run-test/Makefile.am
---- mysql-orig/storage/ndb/test/run-test/Makefile.am 2010-01-18 01:46:52.496599991 -0100
-+++ mysql/storage/ndb/test/run-test/Makefile.am 2010-01-18 01:47:04.233349487 -0100
-@@ -34,9 +34,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-diff -urN mysql-orig/strings/Makefile.am mysql/strings/Makefile.am
---- mysql-orig/strings/Makefile.am 2010-01-18 01:46:52.566599874 -0100
-+++ mysql/strings/Makefile.am 2010-01-18 01:52:17.941349607 -0100
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,9 +56,9 @@
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD= libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
- conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-@@ -67,17 +67,17 @@
- #strtoull.o: @CHARSET_OBJS@
-
-
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
--test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
-+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-diff -urN mysql-orig/unittest/mysys/Makefile.am mysql/unittest/mysys/Makefile.am
---- mysql-orig/unittest/mysys/Makefile.am 2010-01-18 01:46:52.549600599 -0100
-+++ mysql/unittest/mysys/Makefile.am 2010-01-18 01:47:04.234349398 -0100
-@@ -17,9 +17,9 @@
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- noinst_PROGRAMS = bitmap-t base64-t my_atomic-t
-
-diff -urN mysql-orig/vio/Makefile.am mysql/vio/Makefile.am
---- mysql-orig/vio/Makefile.am 2010-01-18 01:46:52.572599866 -0100
-+++ mysql/vio/Makefile.am 2010-01-18 01:47:04.234349398 -0100
-@@ -16,11 +16,11 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/02040_all_embedded-library-shared-5.1.43.patch b/02040_all_embedded-library-shared-5.1.43.patch
deleted file mode 100644
index 8553647..0000000
--- a/02040_all_embedded-library-shared-5.1.43.patch
+++ /dev/null
@@ -1,1460 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-
-diff -urN mysql/client/Makefile.am mysql-new//client/Makefile.am
---- mysql/client/Makefile.am 2010-04-06 14:03:47.000000000 +0000
-+++ mysql-new//client/Makefile.am 2010-05-16 23:46:17.136327166 +0000
-@@ -75,7 +75,7 @@
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +84,15 @@
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-diff -urN mysql/configure.in mysql-new//configure.in
---- mysql/configure.in 2010-04-06 14:03:56.000000000 +0000
-+++ mysql-new//configure.in 2010-05-16 23:46:17.137201998 +0000
-@@ -2789,7 +2789,7 @@
-
- dnl This probably should be cleaned up more - for now the threaded
- dnl client is just using plain-old libs.
--sql_client_dirs="strings mysys dbug extra regex libmysql"
-+sql_client_dirs="strings regex dbug mysys extra libmysql"
-
- AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no")
-
-@@ -2817,20 +2817,18 @@
- AC_SUBST(netware_dir)
- AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware")
-
-+AM_CONDITIONAL([NEED_THREADS], [test x"$with_server" != xno -o x"$THREAD_SAFE_CLIENT" != xno])
- if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
- AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
-
- if test "$with_server" != "no"
- then
- server_scripts="mysqld_safe mysql_install_db"
-- sql_server_dirs="strings mysys dbug extra regex storage plugin"
-+ sql_server_dirs="strings dbug mysys extra regex storage plugin"
-
- sql_server="vio sql"
- fi
-diff -urN mysql/dbug/Makefile.am mysql-new//dbug/Makefile.am
---- mysql/dbug/Makefile.am 2010-04-06 14:03:56.000000000 +0000
-+++ mysql-new//dbug/Makefile.am 2010-05-16 23:46:17.138201427 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = ../mysys/libmysys.la ../strings/libmystrings.la
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-@@ -31,11 +31,11 @@
-
-
- # Must be linked with libs that are not compiled yet
--noinst_PROGRAMS = factorial dbug_analyze
-+EXTRA_PROGRAMS = factorial dbug_analyze
- factorial_SOURCES = my_main.c factorial.c
- dbug_analyze_SOURCES = dbug_analyze.c
-
--all: user.t user.ps
-+check-local: user.t user.ps
-
- user.t: user.r $(NROFF_INC)
- -nroff -mm user.r > $@
-diff -urN mysql/extra/Makefile.am mysql-new//extra/Makefile.am
---- mysql/extra/Makefile.am 2010-04-06 14:03:58.000000000 +0000
-+++ mysql-new//extra/Makefile.am 2010-05-16 23:46:17.139451376 +0000
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-diff -urN mysql/libmysql/Makefile.am mysql-new//libmysql/Makefile.am
---- mysql/libmysql/Makefile.am 2010-04-06 14:04:04.000000000 +0000
-+++ mysql-new//libmysql/Makefile.am 2010-05-16 23:46:17.139451376 +0000
-@@ -106,8 +106,8 @@
- echo "# This file is autogenerated from Makefile.am" >> $$dir/Makefile; \
- echo 'CFLAGS= -I. -DMYSQL_CLIENT_NO_THREADS' >>$$dir/Makefile; \
- echo "obj=$$objs" >>$$dir/Makefile; \
-- echo 'all: libmysql.a' >>$$dir/Makefile; \
-- echo 'libmysql.a: $$(obj)' >>$$dir/Makefile; \
-+ echo 'all: libmysql.la' >>$$dir/Makefile; \
-+ echo 'libmysql.la: $$(obj)' >>$$dir/Makefile; \
- echo ' $$(AR) r $$@ $$?' >>$$dir/Makefile; \
- gtar cvzf $$dir.tar.gz $$dir; \
- cd $$dir; gmake
-diff -urN mysql/libmysqld/examples/Makefile.am mysql-new//libmysqld/examples/Makefile.am
---- mysql/libmysqld/examples/Makefile.am 2010-04-06 14:04:05.000000000 +0000
-+++ mysql-new//libmysqld/examples/Makefile.am 2010-05-16 23:46:17.139451376 +0000
-@@ -37,12 +37,15 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
-- @NDB_SCI_LIBS@
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
-+ @NDB_SCI_LIBS@ ../../libmysql/libmysqlclient.la \
-+ ../../mysys/libmysys.la ../../regex/libregex.la \
-+ ../../storage/heap/libheap.la ../../storage/myisam/libmyisam.la
-
- mysqltest_embedded_LINK = $(CXXLINK)
- nodist_mysqltest_embedded_SOURCES = mysqltest.cc
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la
-+mysqltest_embedded_LDFLAGS = -static
-
- nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
- my_readline.h sql_string.h completion_hash.h
-@@ -50,6 +53,7 @@
-
- mysql_client_test_embedded_LINK = $(CXXLINK)
- nodist_mysql_client_test_embedded_SOURCES = mysql_client_test.c
-+mysql_client_test_embedded_LDFLAGS = -static
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql/libmysqld/Makefile.am mysql-new//libmysqld/Makefile.am
---- mysql/libmysqld/Makefile.am 2010-04-06 14:04:05.000000000 +0000
-+++ mysql-new//libmysqld/Makefile.am 2010-05-16 23:46:17.140454367 +0000
-@@ -36,10 +36,10 @@
- $(openssl_includes) @ZLIB_INCLUDES@ \
- @condition_dependent_plugin_includes@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+noinst_LTLIBRARIES = libmysqld_int.la
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
--libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
-+#libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
- my_time.c
-
-@@ -79,11 +79,11 @@
- rpl_injector.cc my_user.c partition_info.cc \
- sql_servers.cc event_parse_data.cc
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
-+libmysqld_int_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_int_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_SOURCES=$(libmysqld_sources)
-
--sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
-+sqlstoragesources = $(EXTRA_libmysqld_la_SOURCES)
- storagesources = @condition_dependent_plugin_modules@
- storageobjects = @condition_dependent_plugin_objects@
- storagesourceslinks = @condition_dependent_plugin_links@
-@@ -91,19 +91,20 @@
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
--# The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-- @NDB_SCI_LIBS@ \
-+# The following libraries should be included in libmysqld.la
-+libmysqld_la_LIBADD= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
-+ @NDB_SCI_LIBS@ \
- @mysql_plugin_libs@ \
-- $(yassl_inc_libs)
-+ $(yassl_inc_libs) \
-+ libmysqld_int.la
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
- endif
-
- # Storage engine specific compilation options
-@@ -139,44 +140,6 @@
- ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
-- else \
-- current_dir=`pwd`; \
-- rm -rf tmp; mkdir tmp; \
-- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
-- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
-- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
-- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
-- mkdir $$artmp; cd $$artmp > /dev/null; \
-- $(AR) x ../../$$arc; \
-- cd $$current_dir > /dev/null; \
-- ls $$artmp/* | grep -v SYMDEF; \
-- continue 2; fi; done; \
-- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(AR) r libmysqld.a $(storageobjects); \
-- $(RANLIB) libmysqld.a ; \
-- rm -rf tmp; \
-- fi
--endif
--
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
- ## libmysqld interface to change without affecting the standard
-diff -urN mysql/mysys/Makefile.am mysql-new//mysys/Makefile.am
---- mysql/mysys/Makefile.am 2010-04-06 14:06:01.000000000 +0000
-+++ mysql-new//mysys/Makefile.am 2010-05-16 23:46:17.141226881 +0000
-@@ -18,10 +18,9 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+pkglib_LTLIBRARIES = libmysys.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -46,7 +45,7 @@
- my_quick.c my_lockmem.c my_static.c \
- my_sync.c my_getopt.c my_mkdir.c \
- default_modify.c default.c \
-- my_compress.c checksum.c \
-+ my_compress.c checksum.c \
- my_net.c my_port.c my_sleep.c \
- charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
- my_gethostbyname.c rijndael.c my_aes.c sha1.c \
-@@ -54,22 +53,23 @@
- my_memmem.c stacktrace.c \
- my_windac.c my_access.c base64.c my_libwrap.c
-
-+libmysys_la_LIBADD = $(top_builddir)/dbug/libdbug.la $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
- if NEED_THREAD
- # mf_keycache is used only in the server, so it is safe to leave the file
- # out of the non-threaded library.
- # In fact, it will currently not compile without thread support.
--libmysys_a_SOURCES += mf_keycache.c
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c my_pthread.c my_thr_init.c mf_keycache.c
- endif
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-@@ -79,8 +79,6 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -89,39 +87,39 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
- test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-@@ -129,7 +127,7 @@
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-diff -urN mysql/netware/Makefile.am mysql-new//netware/Makefile.am
---- mysql/netware/Makefile.am 2010-04-06 14:06:03.000000000 +0000
-+++ mysql-new//netware/Makefile.am 2010-05-16 23:46:17.141226881 +0000
-@@ -16,14 +16,13 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
- mysql_test_run_SOURCES= mysql_test_run.c my_manage.c
- libmysql_SOURCES= libmysqlmain.c
--libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a \
-+libmysql_LDADD = ../libmysql/.libs/libmysqlclient.la \
- @openssl_libs@ @yassl_libs@
-
- netware_build_files = client/mysql.def client/mysqladmin.def \
-diff -urN mysql/pstack/Makefile.am mysql-new//pstack/Makefile.am
---- mysql/pstack/Makefile.am 2010-04-06 14:06:03.000000000 +0000
-+++ mysql-new//pstack/Makefile.am 2010-05-16 23:46:17.142361104 +0000
-@@ -22,8 +22,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
-
--pkglib_LIBRARIES = libpstack.a
--libpstack_a_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c \
-+pkglib_LTLIBRARIES = libpstack.la
-+libpstack_la_SOURCES = bucomm.c filemode.c linuxthreads.c rddbg.c \
- debug.c ieee.c pstack.c stabs.c
- noinst_HEADERS = bucomm.h debug.h ieee.h budbg.h demangle.h \
- linuxthreads.h pstack.h pstacktrace.h
-diff -urN mysql/regex/Makefile.am mysql-new//regex/Makefile.am
---- mysql/regex/Makefile.am 2010-04-06 14:06:04.000000000 +0000
-+++ mysql-new//regex/Makefile.am 2010-05-16 23:46:17.142361104 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+pkglib_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-diff -urN mysql/server-tools/instance-manager/Makefile.am mysql-new//server-tools/instance-manager/Makefile.am
---- mysql/server-tools/instance-manager/Makefile.am 2010-04-06 14:06:04.000000000 +0000
-+++ mysql-new//server-tools/instance-manager/Makefile.am 2010-05-16 23:46:17.143218964 +0000
-@@ -23,8 +23,7 @@
- # default_options.h, generated from default_options.h.in)
- # See automake/autoconf docs for details
-
--noinst_LTLIBRARIES= liboptions.la
--noinst_LIBRARIES= libnet.a
-+noinst_LTLIBRARIES= liboptions.la libnet.la
-
- liboptions_la_CXXFLAGS= $(CXXFLAGS) \
- -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \
-@@ -36,17 +35,17 @@
- -DPROTOCOL_VERSION=@PROTOCOL_VERSION@
-
- liboptions_la_SOURCES= options.h options.cc priv.h priv.cc
--liboptions_la_LIBADD= $(top_builddir)/libmysql/get_password.lo
-+
-+liboptions_la_LIBADD= $(top_builddir)/libmysql/libmysqlclient.la
-
- # MySQL sometimes uses symlinks to reuse code
- # All symlinked files are grouped in libnet.a
-
--nodist_libnet_a_SOURCES= net_serv.cc client_settings.h
--libnet_a_LIBADD= $(top_builddir)/sql/password.$(OBJEXT) \
-- $(top_builddir)/sql/pack.$(OBJEXT) \
-- $(top_builddir)/sql/sql_state.$(OBJEXT) \
-- $(top_builddir)/sql/mini_client_errors.$(OBJEXT)\
-- $(top_builddir)/sql/client.$(OBJEXT)
-+nodist_libnet_la_SOURCES= net_serv.cc client_settings.h \
-+ $(srcdir)/../../sql/password.c $(srcdir)/../../sql/pack.c \
-+ $(srcdir)/../../sql/sql_state.c $(srcdir)/../../sql/mini_client_errors.c \
-+ $(srcdir)/../../sql/client.c
-+
-
- CLEANFILES= net_serv.cc client_settings.h
-
-@@ -86,11 +85,11 @@
-
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
-- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ libnet.la \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-diff -ur mysql/sql/Makefile.am mysql-new/sql/Makefile.am
---- mysql/sql/Makefile.am 2010-04-24 23:20:52.000000000 +0000
-+++ mysql-new/sql/Makefile.am 2010-04-24 23:54:16.000000000 +0000
-@@ -32,11 +32,12 @@
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
- LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
- mysqld_LDADD = libndb.la \
-diff -urN mysql/storage/archive/Makefile.am mysql-new//storage/archive/Makefile.am
---- mysql/storage/archive/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/archive/Makefile.am 2010-05-16 23:52:49.143203084 +0000
-@@ -23,17 +23,18 @@
- INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
- -I$(top_srcdir)/regex \
- -I$(top_srcdir)/sql \
-- -I$(srcdir) @ZLIB_INCLUDES@
-+ -I$(srcdir) @ZLIB_INCLUDES@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
- noinst_HEADERS = ha_archive.h azlib.h
- noinst_PROGRAMS = archive_test archive_reader
-
--EXTRA_LTLIBRARIES = ha_archive.la
-+EXTRA_LTLIBRARIES = ha_archive.la libarchive.la
- pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
- ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_archive_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -41,26 +42,25 @@
- ha_archive_la_SOURCES = ha_archive.cc azio.c
-
-
--EXTRA_LIBRARIES = libarchive.a
--noinst_LIBRARIES = @plugin_archive_static_target@
--libarchive_a_CXXFLAGS = $(AM_CFLAGS)
--libarchive_a_CFLAGS = $(AM_CFLAGS)
--libarchive_a_SOURCES = ha_archive.cc azio.c
-+noinst_LTLIBRARIES = @plugin_archive_static_target@
-+libarchive_la_CXXFLAGS = $(AM_CFLAGS)
-+libarchive_la_CFLAGS = $(AM_CFLAGS)
-+libarchive_la_SOURCES = ha_archive.cc azio.c
-
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-diff -urN mysql/storage/archive/plug.in mysql-new//storage/archive/plug.in
---- mysql/storage/archive/plug.in 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/archive/plug.in 2010-05-16 23:46:17.144453060 +0000
-@@ -1,4 +1,4 @@
- MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
- [Archive Storage Engine], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
-+MYSQL_PLUGIN_STATIC(archive, [libarchive.la])
- MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
-diff -urN mysql/storage/blackhole/Makefile.am mysql-new//storage/blackhole/Makefile.am
---- mysql/storage/blackhole/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/blackhole/Makefile.am 2010-05-16 23:53:10.512201289 +0000
-@@ -27,12 +27,13 @@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
- noinst_HEADERS = ha_blackhole.h
-
--EXTRA_LTLIBRARIES = ha_blackhole.la
-+EXTRA_LTLIBRARIES = ha_blackhole.la libblackhole.la
- pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
- ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
- ha_blackhole_la_CXXFLAGS=$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +41,10 @@
- ha_blackhole_la_SOURCES=ha_blackhole.cc
-
-
--EXTRA_LIBRARIES = libblackhole.a
--noinst_LIBRARIES = @plugin_blackhole_static_target@
--libblackhole_a_CXXFLAGS=$(AM_CFLAGS)
--libblackhole_a_CFLAGS = $(AM_CFLAGS)
--libblackhole_a_SOURCES= ha_blackhole.cc
-+noinst_LTLIBRARIES = @plugin_blackhole_static_target@
-+libblackhole_la_CXXFLAGS=$(AM_CFLAGS)
-+libblackhole_la_CFLAGS = $(AM_CFLAGS)
-+libblackhole_la_SOURCES= ha_blackhole.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-diff -urN mysql/storage/blackhole/plug.in mysql-new//storage/blackhole/plug.in
---- mysql/storage/blackhole/plug.in 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/blackhole/plug.in 2010-05-16 23:46:17.144453060 +0000
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
- [Basic Write-only Read-never tables], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
--MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
-+MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.la])
- MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
--
-diff -urN mysql/storage/csv/Makefile.am mysql-new//storage/csv/Makefile.am
---- mysql/storage/csv/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/csv/Makefile.am 2010-05-16 23:53:21.492201900 +0000
-@@ -25,21 +25,22 @@
- -I$(top_srcdir)/sql \
- -I$(srcdir)
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
- noinst_HEADERS = ha_tina.h transparent_file.h
-
--EXTRA_LTLIBRARIES = ha_csv.la
-+EXTRA_LTLIBRARIES = ha_csv.la libcsv.la
- pkglib_LTLIBRARIES = @plugin_csv_shared_target@
- ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
- ha_csv_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_PLUGIN
- ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc
-
--EXTRA_LIBRARIES = libcsv.a
--noinst_LIBRARIES = @plugin_csv_static_target@
--libcsv_a_CXXFLAGS = $(AM_CFLAGS)
--libcsv_a_SOURCES = transparent_file.cc ha_tina.cc
-+noinst_LTLIBRARIES = @plugin_csv_static_target@
-+libcsv_la_CXXFLAGS = $(AM_CFLAGS)
-+libcsv_la_SOURCES = transparent_file.cc ha_tina.cc
-
- EXTRA_DIST = CMakeLists.txt plug.in
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-+
-diff -urN mysql/storage/csv/plug.in mysql-new//storage/csv/plug.in
---- mysql/storage/csv/plug.in 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/csv/plug.in 2010-05-16 23:46:17.145453187 +0000
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
- [Stores tables in text CSV format])
- MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
--MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
--MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
-+MYSQL_PLUGIN_STATIC(csv, [libcsv.la])
-+MYSQL_PLUGIN_DYNAMIC(csv, [ha_csv.la])
-diff -urN mysql/storage/example/Makefile.am mysql-new//storage/example/Makefile.am
---- mysql/storage/example/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/example/Makefile.am 2010-05-16 23:53:31.706327579 +0000
-@@ -27,6 +27,7 @@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
-diff -urN mysql/storage/federated/Makefile.am mysql-new//storage/federated/Makefile.am
---- mysql/storage/federated/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/federated/Makefile.am 2010-05-16 23:53:40.856451099 +0000
-@@ -27,12 +27,13 @@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
- noinst_HEADERS = ha_federated.h
-
--EXTRA_LTLIBRARIES = ha_federated.la
-+EXTRA_LTLIBRARIES = ha_federated.la libfederated.la
- pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
- ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_federated_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +41,10 @@
- ha_federated_la_SOURCES = ha_federated.cc
-
-
--EXTRA_LIBRARIES = libfederated.a
--noinst_LIBRARIES = @plugin_federated_static_target@
--libfederated_a_CXXFLAGS = $(AM_CFLAGS)
--libfederated_a_CFLAGS = $(AM_CFLAGS)
--libfederated_a_SOURCES= ha_federated.cc
-+noinst_LTLIBRARIES = @plugin_federated_static_target@
-+libfederated_la_CXXFLAGS = $(AM_CFLAGS)
-+libfederated_la_CFLAGS = $(AM_CFLAGS)
-+libfederated_la_SOURCES= ha_federated.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-diff -urN mysql/storage/federated/plug.in mysql-new//storage/federated/plug.in
---- mysql/storage/federated/plug.in 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/federated/plug.in 2010-05-16 23:46:17.148333581 +0000
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
- [Connects to tables on remote MySQL servers], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(federated, [libfederated.a])
--MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
-+MYSQL_PLUGIN_STATIC(federated, [libfederated.la])
- MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federated.cc])
-+MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
-diff -urN mysql/storage/heap/Makefile.am mysql-new//storage/heap/Makefile.am
---- mysql/storage/heap/Makefile.am 2010-04-06 14:07:07.000000000 +0000
-+++ mysql-new//storage/heap/Makefile.am 2010-05-16 23:54:15.908202903 +0000
-@@ -24,23 +24,23 @@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
-+pkglib_LTLIBRARIES = libheap.la
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
-diff -urN mysql/storage/heap/plug.in mysql-new//storage/heap/plug.in
---- mysql/storage/heap/plug.in 2010-04-06 14:07:08.000000000 +0000
-+++ mysql-new//storage/heap/plug.in 2010-05-16 23:46:17.148333581 +0000
-@@ -1,7 +1,5 @@
- MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
- [Volatile memory based tables])
- MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
--MYSQL_PLUGIN_STATIC(heap, [libheap.a])
--MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
-+MYSQL_PLUGIN_DYNAMIC(heap, [libheap.la])
- MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(heap, [ha_heap.cc])
--
-diff -urN mysql/storage/ibmdb2i/Makefile.am mysql-new//storage/ibmdb2i/Makefile.am
---- mysql/storage/ibmdb2i/Makefile.am 2010-04-06 14:07:08.000000000 +0000
-+++ mysql-new//storage/ibmdb2i/Makefile.am 2010-05-16 23:54:27.492203982 +0000
-@@ -21,6 +21,7 @@
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
-diff -urN mysql/storage/innobase/Makefile.am mysql-new//storage/innobase/Makefile.am
---- mysql/storage/innobase/Makefile.am 2010-04-06 14:07:08.000000000 +0000
-+++ mysql-new//storage/innobase/Makefile.am 2010-05-16 23:46:17.149453486 +0000
-@@ -122,9 +122,9 @@
- include/ut0list.ic include/ut0wqueue.h \
- include/ha_prototypes.h handler/ha_innodb.h
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innobase_static_target@
--libinnobase_a_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
-+EXTRA_LTLIBRARIES= ha_innodb.la libinnobase.la
-+noinst_LTLIBRARIES= @plugin_innobase_static_target@
-+libinnobase_la_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
- btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
- buf/buf0lru.c buf/buf0rea.c data/data0data.c \
- data/data0type.c dict/dict0boot.c \
-@@ -156,10 +156,9 @@
- ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c \
- handler/ha_innodb.cc
-
--libinnobase_a_CXXFLAGS= $(AM_CFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CFLAGS= $(AM_CFLAGS)
-
--EXTRA_LTLIBRARIES= ha_innodb.la
- pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@
-
- ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir)
-diff -urN mysql/storage/innobase/plug.in mysql-new//storage/innobase/plug.in
---- mysql/storage/innobase/plug.in 2010-04-06 14:07:11.000000000 +0000
-+++ mysql-new//storage/innobase/plug.in 2010-05-16 23:46:17.149453486 +0000
-@@ -1,8 +1,8 @@
- MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
- [Transactional Tables using InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
--MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
--MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
-+MYSQL_PLUGIN_STATIC(innobase, [libinnobase.la])
-+MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.so])
- MYSQL_PLUGIN_ACTIONS(innobase, [
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
- AC_SUBST(innodb_system_libs)
-diff -urN mysql/storage/innobase/plug.in.orig mysql-new//storage/innobase/plug.in.orig
---- mysql/storage/innobase/plug.in.orig 1969-12-31 23:00:00.000000000 -0100
-+++ mysql-new//storage/innobase/plug.in.orig 2010-05-16 23:46:06.583212585 +0000
-@@ -0,0 +1,44 @@
-+MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
-+ [Transactional Tables using InnoDB], [max,max-no-ndb])
-+MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
-+MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
-+MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
-+MYSQL_PLUGIN_ACTIONS(innobase, [
-+ AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
-+ AC_SUBST(innodb_system_libs)
-+ AC_CHECK_HEADERS(aio.h sched.h)
-+ AC_CHECK_SIZEOF(int, 4)
-+ AC_CHECK_SIZEOF(long, 4)
-+ AC_CHECK_SIZEOF(void*, 4)
-+ AC_CHECK_FUNCS(sched_yield)
-+ AC_CHECK_FUNCS(fdatasync)
-+ AC_CHECK_FUNCS(localtime_r)
-+ AC_C_BIGENDIAN
-+ case "$target_os" in
-+ lin*)
-+ CFLAGS="$CFLAGS -DUNIV_LINUX";;
-+ hpux10*)
-+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
-+ hp*)
-+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
-+ aix*)
-+ CFLAGS="$CFLAGS -DUNIV_AIX";;
-+ irix*|osf*|sysv5uw7*|openbsd*)
-+ CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
-+ *solaris*|*SunOS*)
-+ CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
-+ esac
-+ INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN"
-+ case "$target_cpu" in
-+ x86_64)
-+ # The AMD64 ABI forbids absolute addresses in shared libraries
-+ ;;
-+ *86)
-+ # Use absolute addresses on IA-32
-+ INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic"
-+ ;;
-+ esac
-+ AC_SUBST(INNODB_DYNAMIC_CFLAGS)
-+ ])
-+
-+# vim: set ft=config:
-diff -urN mysql/storage/myisam/Makefile.am mysql-new//storage/myisam/Makefile.am
---- mysql/storage/myisam/Makefile.am 2010-04-06 14:07:14.000000000 +0000
-+++ mysql-new//storage/myisam/Makefile.am 2010-05-16 23:55:47.541203043 +0000
-@@ -20,70 +20,38 @@
- INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
- -I$(top_srcdir)/regex \
- -I$(top_srcdir)/sql \
-- -I$(srcdir)
-+ -I$(srcdir)
- WRAPLIBS=
-
--LDADD =
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
-
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--pkglib_LIBRARIES = libmyisam.a
-+noinst_LTLIBRARIES = libmyisam.la
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+libmyisam_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-diff -urN mysql/storage/myisam/plug.in mysql-new//storage/myisam/plug.in
---- mysql/storage/myisam/plug.in 2010-04-06 14:07:15.000000000 +0000
-+++ mysql-new//storage/myisam/plug.in 2010-05-16 23:46:17.150202464 +0000
-@@ -1,7 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- [Traditional non-transactional MySQL tables])
- MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
--MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
-+MYSQL_PLUGIN_DYNAMIC(myisam, [libmyisam.la])
- MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
--
-diff -urN mysql/storage/myisammrg/Makefile.am mysql-new//storage/myisammrg/Makefile.am
---- mysql/storage/myisammrg/Makefile.am 2010-04-06 14:07:15.000000000 +0000
-+++ mysql-new//storage/myisammrg/Makefile.am 2010-05-16 23:55:55.856202762 +0000
-@@ -20,16 +20,16 @@
- INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
- -I$(top_srcdir)/regex \
- -I$(top_srcdir)/sql \
-- -I$(srcdir)
-+ -I$(srcdir)
- WRAPLIBS=
-
- LDADD =
-+LDFLAGS = --whole-archive
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la
- noinst_HEADERS = myrg_def.h ha_myisammrg.h
--noinst_LIBRARIES = libmyisammrg.a
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
-diff -urN mysql/storage/myisammrg/plug.in mysql-new//storage/myisammrg/plug.in
---- mysql/storage/myisammrg/plug.in 2010-04-06 14:07:16.000000000 +0000
-+++ mysql-new//storage/myisammrg/plug.in 2010-05-16 23:46:17.153203963 +0000
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
- [Merge multiple MySQL tables into one])
- MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
--MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
--MYSQL_PLUGIN_MANDATORY(myisammrg)
-+MYSQL_PLUGIN_DYNAMIC(myisammrg, [libmyisammrg.la])
- MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc])
-diff -urN mysql/storage/ndb/config/type_ndbapitest.mk.am mysql-new//storage/ndb/config/type_ndbapitest.mk.am
---- mysql/storage/ndb/config/type_ndbapitest.mk.am 2010-04-06 14:07:16.000000000 +0000
-+++ mysql-new//storage/ndb/config/type_ndbapitest.mk.am 2010-05-16 23:46:17.153203963 +0000
-@@ -15,9 +15,9 @@
-
- LDADD += $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- INCLUDES += -I$(top_srcdir) \
- -I$(top_builddir)/include \
-diff -urN mysql/storage/ndb/config/type_ndbapitools.mk.am mysql-new//storage/ndb/config/type_ndbapitools.mk.am
---- mysql/storage/ndb/config/type_ndbapitools.mk.am 2010-04-06 14:07:16.000000000 +0000
-+++ mysql-new//storage/ndb/config/type_ndbapitools.mk.am 2010-05-16 23:46:17.154204509 +0000
-@@ -15,9 +15,9 @@
-
- LDADD += \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ @ZLIB_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ @ZLIB_LIBS@
-
- INCLUDES += -I$(srcdir) \
- -I$(top_builddir)/include \
-diff -urN mysql/storage/ndb/config/win-libraries mysql-new//storage/ndb/config/win-libraries
---- mysql/storage/ndb/config/win-libraries 2010-04-06 14:07:16.000000000 +0000
-+++ mysql-new//storage/ndb/config/win-libraries 2010-05-16 23:46:17.154204509 +0000
-@@ -21,7 +21,7 @@
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
-diff -urN mysql/storage/ndb/src/common/util/Makefile.am mysql-new//storage/ndb/src/common/util/Makefile.am
---- mysql/storage/ndb/src/common/util/Makefile.am 2010-04-06 14:07:20.000000000 +0000
-+++ mysql-new//storage/ndb/src/common/util/Makefile.am 2010-05-16 23:46:17.155202332 +0000
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-diff -urN mysql/storage/ndb/src/cw/cpcd/Makefile.am mysql-new//storage/ndb/src/cw/cpcd/Makefile.am
---- mysql/storage/ndb/src/cw/cpcd/Makefile.am 2010-04-06 14:07:21.000000000 +0000
-+++ mysql-new//storage/ndb/src/cw/cpcd/Makefile.am 2010-05-16 23:46:17.156204554 +0000
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-diff -urN mysql/storage/ndb/src/kernel/blocks/backup/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/backup/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-04-06 14:07:21.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-05-16 23:46:17.156204554 +0000
-@@ -17,9 +17,9 @@
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-diff -urN mysql/storage/ndb/src/kernel/blocks/dbdict/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/dbdict/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-04-06 14:07:22.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-05-16 23:46:17.156204554 +0000
-@@ -19,17 +19,17 @@
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql/storage/ndb/src/kernel/blocks/dbdih/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/dbdih/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-04-06 14:07:22.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-05-16 23:46:17.157203285 +0000
-@@ -17,9 +17,9 @@
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-diff -urN mysql/storage/ndb/src/kernel/blocks/dblqh/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/dblqh/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-04-06 14:07:22.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-05-16 23:46:17.157203285 +0000
-@@ -23,9 +23,9 @@
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql/storage/ndb/src/kernel/blocks/dbtup/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/dbtup/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-04-06 14:07:23.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-05-16 23:46:17.158202224 +0000
-@@ -20,9 +20,9 @@
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql/storage/ndb/src/kernel/blocks/Makefile.am mysql-new//storage/ndb/src/kernel/blocks/Makefile.am
---- mysql/storage/ndb/src/kernel/blocks/Makefile.am 2010-04-06 14:07:21.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/blocks/Makefile.am 2010-05-16 23:46:17.158202224 +0000
-@@ -57,9 +57,9 @@
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-diff -urN mysql/storage/ndb/src/kernel/Makefile.am mysql-new//storage/ndb/src/kernel/Makefile.am
---- mysql/storage/ndb/src/kernel/Makefile.am 2010-04-06 14:07:21.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/Makefile.am 2010-05-16 23:46:17.158202224 +0000
-@@ -53,9 +53,9 @@
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- windoze-dsp: ndbd.dsp
-
-diff -urN mysql/storage/ndb/src/kernel/vm/Makefile.am mysql-new//storage/ndb/src/kernel/vm/Makefile.am
---- mysql/storage/ndb/src/kernel/vm/Makefile.am 2010-04-06 14:07:24.000000000 +0000
-+++ mysql-new//storage/ndb/src/kernel/vm/Makefile.am 2010-05-16 23:46:17.159203329 +0000
-@@ -65,24 +65,24 @@
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
- bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-diff -urN mysql/storage/ndb/src/mgmclient/Makefile.am mysql-new//storage/ndb/src/mgmclient/Makefile.am
---- mysql/storage/ndb/src/mgmclient/Makefile.am 2010-04-06 14:07:24.000000000 +0000
-+++ mysql-new//storage/ndb/src/mgmclient/Makefile.am 2010-05-16 23:46:17.159203329 +0000
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-diff -urN mysql/storage/ndb/src/mgmsrv/Makefile.am mysql-new//storage/ndb/src/mgmsrv/Makefile.am
---- mysql/storage/ndb/src/mgmsrv/Makefile.am 2010-04-06 14:07:25.000000000 +0000
-+++ mysql-new//storage/ndb/src/mgmsrv/Makefile.am 2010-05-16 23:46:17.160203317 +0000
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-diff -urN mysql/storage/ndb/src/ndbapi/Makefile.am mysql-new//storage/ndb/src/ndbapi/Makefile.am
---- mysql/storage/ndb/src/ndbapi/Makefile.am 2010-04-06 14:07:25.000000000 +0000
-+++ mysql-new//storage/ndb/src/ndbapi/Makefile.am 2010-05-16 23:46:17.163533838 +0000
-@@ -67,9 +67,9 @@
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
- ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -urN mysql/storage/ndb/test/run-test/Makefile.am mysql-new//storage/ndb/test/run-test/Makefile.am
---- mysql/storage/ndb/test/run-test/Makefile.am 2010-04-06 14:07:28.000000000 +0000
-+++ mysql-new//storage/ndb/test/run-test/Makefile.am 2010-05-16 23:46:17.163533838 +0000
-@@ -34,9 +34,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-diff -urN mysql/strings/Makefile.am mysql-new//strings/Makefile.am
---- mysql/strings/Makefile.am 2010-04-06 14:07:29.000000000 +0000
-+++ mysql-new//strings/Makefile.am 2010-05-16 23:46:17.164577337 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+pkglib_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,28 +56,27 @@
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
--conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- # This is because the dependency tracking misses @FOO@ vars in sources.
- #strtoull.o: @CHARSET_OBJS@
-
-
--FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-+FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
--test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
-+test_decimal$(EXEEXT): decimal.c $(pkglib_LTLIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-diff -urN mysql/strings/strings-x86.s mysql-new//strings/strings-x86.s
---- mysql/strings/strings-x86.s 2010-04-06 14:07:30.000000000 +0000
-+++ mysql-new//strings/strings-x86.s 2010-05-16 23:46:17.164577337 +0000
-@@ -293,7 +293,7 @@
- movl %esp,%ebp
- pushl 12(%ebp) # search
- pushl 8(%ebp) # str
-- call strstr
-+ call strstr@plt
- add $8,%esp
- or %eax,%eax
- jz si_99 # Not found, return NULL
-diff -urN mysql/tests/Makefile.am mysql-new//tests/Makefile.am
---- mysql/tests/Makefile.am 2010-04-06 14:07:31.000000000 +0000
-+++ mysql-new//tests/Makefile.am 2010-05-16 23:46:17.166201915 +0000
-@@ -49,11 +49,11 @@
-
- insert_test_SOURCES= insert_test.c
- select_test_SOURCES= select_test.c
--insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
--select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+insert_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-+select_test_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- bug25714_SOURCES= bug25714.c
--bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
-+bug25714_DEPENDENCIES= $(LTLIBRARIES) $(pkglib_LTLIBRARIES)
-
- # Fix for mit-threads
- DEFS = -DMYSQL_CLIENT_NO_THREADS
-diff -urN mysql/unittest/mysys/Makefile.am mysql-new//unittest/mysys/Makefile.am
---- mysql/unittest/mysys/Makefile.am 2010-04-06 14:07:31.000000000 +0000
-+++ mysql-new//unittest/mysys/Makefile.am 2010-05-16 23:46:17.166201915 +0000
-@@ -17,9 +17,9 @@
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- noinst_PROGRAMS = bitmap-t base64-t
-
-diff -urN mysql/vio/Makefile.am mysql-new//vio/Makefile.am
---- mysql/vio/Makefile.am 2010-04-06 14:07:31.000000000 +0000
-+++ mysql-new//vio/Makefile.am 2010-05-16 23:46:17.167454169 +0000
-@@ -16,11 +16,12 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_LIBADD = -lssl
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/02040_all_embedded-library-shared-5.1.50.patch b/02040_all_embedded-library-shared-5.1.50.patch
deleted file mode 100644
index f81440d..0000000
--- a/02040_all_embedded-library-shared-5.1.50.patch
+++ /dev/null
@@ -1,2298 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-Thanks to Maciej Mrozowski <reavertm@gentoo.org> for working in the redo of the
-patch for mysql-5.1.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
-
-=== modified file 'client/Makefile.am'
----
- client/Makefile.am | 11 -
- config/ac-macros/plugins.m4 | 107 ++++++++-----
- configure.in | 8 -
- dbug/Makefile.am | 6
- extra/Makefile.am | 4
- libmysqld/Makefile.am | 184 ++++++++---------------
- libmysqld/examples/Makefile.am | 10 -
- mysys/Makefile.am | 42 ++---
- netware/BUILD/compile-linux-tools | 16 +-
- netware/Makefile.am | 4
- regex/Makefile.am | 6
- server-tools/instance-manager/Makefile.am | 8 -
- sql/Makefile.am | 12 -
- storage/archive/Makefile.am | 23 +-
- storage/archive/plug.in | 2
- storage/blackhole/Makefile.am | 11 -
- storage/blackhole/plug.in | 2
- storage/csv/Makefile.am | 9 -
- storage/csv/plug.in | 2
- storage/example/Makefile.am | 11 -
- storage/federated/Makefile.am | 15 +
- storage/federated/plug.in | 3
- storage/heap/Makefile.am | 37 +++-
- storage/heap/plug.in | 3
- storage/innobase/Makefile.am | 40 ++---
- storage/innobase/plug.in | 2
- storage/innodb_plugin/Makefile.am | 13 -
- storage/myisam/Makefile.am | 118 ++++++++------
- storage/myisam/plug.in | 4
- storage/myisammrg/Makefile.am | 20 ++
- storage/myisammrg/plug.in | 3
- storage/ndb/config/type_ndbapitest.mk.am | 31 ++-
- storage/ndb/config/type_ndbapitools.mk.am | 33 ++--
- storage/ndb/config/win-libraries | 2
- storage/ndb/src/common/util/Makefile.am | 6
- storage/ndb/src/cw/cpcd/Makefile.am | 6
- storage/ndb/src/kernel/Makefile.am | 7
- storage/ndb/src/kernel/blocks/Makefile.am | 10 -
- storage/ndb/src/kernel/blocks/backup/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dbdict/Makefile.am | 12 -
- storage/ndb/src/kernel/blocks/dbdih/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dblqh/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dbtup/Makefile.am | 6
- storage/ndb/src/kernel/vm/Makefile.am | 82 +++++-----
- storage/ndb/src/mgmclient/Makefile.am | 65 ++++----
- storage/ndb/src/mgmsrv/Makefile.am | 70 ++++----
- storage/ndb/src/ndbapi/Makefile.am | 98 ++++++------
- storage/ndb/test/run-test/Makefile.am | 6
- strings/Makefile.am | 16 +-
- unittest/mysys/Makefile.am | 15 +
- unittest/strings/Makefile.am | 9 -
- unittest/unit.pl | 2
- vio/Makefile.am | 4
- 53 files changed, 622 insertions(+), 612 deletions(-)
-
-Index: client/Makefile.am
-===================================================================
---- client/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ client/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -75,7 +75,8 @@ mysqlimport_CFLAGS= -DTHREAD -UUNDEF_TH
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +85,17 @@ mysqlslap_CFLAGS= -DTHREAD -UMYSQL_CLIE
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-Index: config/ac-macros/plugins.m4
-===================================================================
---- config/ac-macros/plugins.m4.orig 2010-11-27 15:02:45.000000000 +0100
-+++ config/ac-macros/plugins.m4 2010-11-27 15:02:49.000000000 +0100
-@@ -115,18 +115,32 @@ dnl ------------------------------------
- dnl Macro: MYSQL_PLUGIN_STATIC
- dnl
- dnl SYNOPSIS
--dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
-+dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a],[libmyplugin_embedded.a])
- dnl
- dnl DESCRIPTION
--dnl Declare the name for the static library
-+dnl Declare the name for the static library
-+dnl
-+dnl Third argument is optional, only needed for special plugins that depend
-+dnl on server internals and have source files that must be compiled specially
-+dnl with -DEMBEDDED_LIBRARY for embedded server. If specified, the third
-+dnl argument is used to link embedded server instead of the second.
- dnl
- dnl ---------------------------------------------------------------------------
-
- AC_DEFUN([MYSQL_PLUGIN_STATIC],[
- MYSQL_REQUIRE_PLUGIN([$1])
- m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
-+ ifelse($#, 3, [
-+ m4_define([MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]), [$3])
-+ ])
- ])
-
-+dnl ---------------------------------------------------------------------------
-+dnl Substitution variable to use to compile source files specially for
-+dnl embedded server.
-+dnl To be used by plugins that have sources that depend on server internals.
-+dnl ---------------------------------------------------------------------------
-+AC_SUBST([plugin_embedded_defs], ["-DEMBEDDED_LIBRARY -DMYSQL_SERVER"])
-
- dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_PLUGIN_DYNAMIC
-@@ -254,29 +268,6 @@ AC_DEFUN([MYSQL_PLUGIN_ACTIONS],[
- ])
-
- dnl ---------------------------------------------------------------------------
--dnl Macro: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS
--dnl
--dnl SYNOPSIS
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS([name],[file name])
--dnl
--dnl DESCRIPTION
--dnl Some modules in plugins keep dependance on structures
--dnl declared in sql/ (THD class usually)
--dnl That has to be fixed in the future, but until then
--dnl we have to recompile these modules when we want to
--dnl to compile server parts with the different #defines
--dnl Normally it happens when we compile the embedded server
--dnl Thus one should mark such files in his handler using this macro
--dnl (currently only one such a file per plugin is supported)
--dnl
--dnl ---------------------------------------------------------------------------
--
--AC_DEFUN([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS],[
-- MYSQL_REQUIRE_PLUGIN([$1])
-- m4_define([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]), [$2])
--])
--
--dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_CONFIGURE_PLUGINS
- dnl
- dnl SYNOPSIS
-@@ -336,11 +327,25 @@ AC_DEFUN([_MYSQL_EMIT_CHECK_PLUGIN],[
- [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
-- [MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]),
-+ [MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
- )
- ])
-
-+# __MYSQL_EMIT_CHECK_PLUGIN arguments:
-+#
-+# 1 - plugin identifying name
-+# 2 - plugin identifying name, with `-' replaced by `_'
-+# 3 - plugin long name
-+# 4 - plugin description
-+# 5 - mysql_plugin_define (eg. WITH_xxx_STORAGE_ENGINE)
-+# 6 - directory
-+# 7 - static target (if supports static build)
-+# 8 - dynamic target (if supports dynamic build)
-+# 9 - mandatory flag
-+# 10 - disabled flag
-+# 11 - static target for libmysqld (if different from mysqld)
-+# 12 - actions
- AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- m4_ifdef([$5],[
- AH_TEMPLATE($5, [Include ]$4[ into mysqld])
-@@ -407,6 +412,7 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- ])
- AC_SUBST([plugin_]$2[_shared_target], "$8")
- AC_SUBST([plugin_]$2[_static_target], [""])
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
- [with_plugin_]$2=yes
- AC_MSG_RESULT([plugin])
- m4_ifdef([$6],[
-@@ -421,32 +427,47 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- ])
- else
- m4_ifdef([$7],[
-- ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
--dnl change above "-2" to "0" to enable this section
--dnl Although this is "pretty", it breaks libmysqld build
-- m4_ifdef([$6],[
-- mysql_use_plugin_dir="$6"
-- mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
-- ])
-- mysql_plugin_libs="$mysql_plugin_libs dnl
--[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
-- ], m4_bregexp($7, [^\\\$]), 0, [
-+ ifelse(m4_bregexp($7, [^\\\$]), 0, [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- ])
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ], [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$7"
-+ ])
- ],[
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ])
- ])
- m4_ifdef([$5],[
- AC_DEFINE($5)
- ])
- AC_SUBST([plugin_]$2[_static_target], "$7")
-+ m4_ifdef([$11], [
-+ if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_]$2[_embedded_static_target], "$11")
-+ else
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ fi
-+ ], [
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ ])
- AC_SUBST([plugin_]$2[_shared_target], [""])
- ],[
- m4_ifdef([$6],[
-@@ -463,12 +484,6 @@ dnl Although this is "pretty", it breaks
- mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
- [with_plugin_]$2=yes
- AC_MSG_RESULT([yes])
-- m4_ifdef([$11],[
-- condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp($11, [[^/]+$], [\&])"
-- condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp($11, [[^/]+\.], [\&o])"
-- condition_dependent_plugin_links="$condition_dependent_plugin_links $6/$11"
-- condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
-- ])
- fi
- fi
-
-@@ -516,6 +531,14 @@ dnl
- ])
- ])
-
-+dnl If not building libmysqld embedded server, then there is no need to build
-+dnl shared object versions of static plugins.
-+if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_static_if_no_embedded], "")
-+else
-+ AC_SUBST([plugin_static_if_no_embedded], "-static")
-+fi
-+
- AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
- ifelse($#, 0, [], $#, 1, [
- _MYSQL_EMIT_PLUGIN_ACTION([$1])
-Index: configure.in
-===================================================================
---- configure.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ configure.in 2010-11-27 19:41:49.000000000 +0100
-@@ -2483,8 +2483,6 @@ MYSQL_STORAGE_ENGINE(partition, partitio
-
- dnl -- ndbcluster requires partition to be enabled
-
--MYSQL_CONFIGURE_PLUGINS([none])
--
- # Only build client code?
- AC_ARG_WITH(server,
- [ --without-server Only build the client.],
-@@ -2498,6 +2496,8 @@ AC_ARG_WITH(embedded-server,
- [with_embedded_server=no]
- )
-
-+MYSQL_CONFIGURE_PLUGINS([none])
-+
- AC_ARG_WITH(query_cache,
- [ --without-query-cache Do not build query cache.],
- [with_query_cache=$withval],
-@@ -2801,9 +2801,6 @@ if test "$with_server" != "no" -o "$THRE
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
- AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
-
-@@ -2831,6 +2828,7 @@ AC_SUBST(server_scripts)
-
- AC_SUBST(mysql_plugin_dirs)
- AC_SUBST(mysql_plugin_libs)
-+AC_SUBST(mysql_embedded_plugin_libs)
- AC_SUBST(mysql_plugin_defs)
-
-
-Index: dbug/Makefile.am
-===================================================================
---- dbug/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ dbug/Makefile.am 2010-11-27 19:42:26.000000000 +0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = libdbug.la ../mysys/libmysys.la ../strings/libmystrings.la $(ZLIB_LIBS)
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-Index: extra/Makefile.am
-===================================================================
---- extra/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ extra/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-Index: libmysqld/Makefile.am
-===================================================================
---- libmysqld/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ libmysqld/Makefile.am 2010-11-27 20:58:00.000000000 +0100
-@@ -17,95 +17,91 @@
- #
- # This file is public domain and comes with NO WARRANTY of any kind
-
--MYSQLDATAdir = $(localstatedir)
--MYSQLSHAREdir = $(pkgdatadir)
--MYSQLBASEdir= $(prefix)
--MYSQLLIBdir= $(libdir)
--pkgplugindir = $(pkglibdir)/plugin
-+MYSQLDATAdir = $(localstatedir)
-+MYSQLSHAREdir = $(pkgdatadir)
-+MYSQLBASEdir = $(prefix)
-+MYSQLLIBdir = $(libdir)
-+pkgplugindir = $(pkglibdir)/plugin
-
--EXTRA_DIST = libmysqld.def CMakeLists.txt
--DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
-+EXTRA_DIST = libmysqld.def CMakeLists.txt
-+DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
- -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- -DPLUGINDIR="\"$(pkgplugindir)\""
--INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include \
-+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_builddir)/sql -I$(top_srcdir)/sql \
- -I$(top_srcdir)/sql/examples \
- -I$(top_srcdir)/regex \
-- $(openssl_includes) @ZLIB_INCLUDES@ \
-- @condition_dependent_plugin_includes@
-+ $(openssl_includes) $(ZLIB_INCLUDES) \
-+ @condition_dependent_plugin_includes@ \
-+ $(ndbcluster_includes)
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
--SUBDIRS = . examples
-+pkglib_LTLIBRARIES = libmysqld.la
-+SUBDIRS = . examples
- libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
-- my_time.c
-+ my_time.c
-
- noinst_HEADERS = embedded_priv.h emb_qcache.h
-
--sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
-- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
-- ha_ndbcluster_binlog.cc ha_partition.cc \
-- handler.cc sql_handler.cc \
-- hostname.cc init.cc password.c \
-- item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
-- item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
-- item_geofunc.cc item_subselect.cc item_row.cc\
-- item_xmlfunc.cc \
-- key.cc lock.cc log.cc sql_state.c \
-- log_event.cc rpl_record.cc \
-- log_event_old.cc rpl_record_old.cc \
-- protocol.cc net_serv.cc opt_range.cc \
-- opt_sum.cc procedure.cc records.cc sql_acl.cc \
-- sql_load.cc discover.cc sql_locale.cc \
-- sql_profile.cc \
-- sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
-- sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
-- sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
-- scheduler.cc sql_connect.cc sql_parse.cc \
-- sql_prepare.cc sql_derived.cc sql_rename.cc \
-- sql_select.cc sql_do.cc sql_show.cc set_var.cc \
-- sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
-- sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
-- unireg.cc uniques.cc sql_union.cc hash_filo.cc \
-- spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
-- sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
-- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
-- rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
-- debug_sync.cc \
-- sql_tablespace.cc \
-- rpl_injector.cc my_user.c partition_info.cc \
-- sql_servers.cc event_parse_data.cc
--
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
--
--sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
--storagesources = @condition_dependent_plugin_modules@
--storageobjects = @condition_dependent_plugin_objects@
--storagesourceslinks = @condition_dependent_plugin_links@
-+sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
-+ ha_ndbcluster.cc ha_ndbcluster_cond.cc \
-+ ha_ndbcluster_binlog.cc ha_partition.cc \
-+ handler.cc sql_handler.cc \
-+ hostname.cc init.cc password.c \
-+ item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
-+ item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
-+ item_geofunc.cc item_subselect.cc item_row.cc\
-+ item_xmlfunc.cc \
-+ key.cc lock.cc log.cc sql_state.c \
-+ log_event.cc rpl_record.cc \
-+ log_event_old.cc rpl_record_old.cc \
-+ protocol.cc net_serv.cc opt_range.cc \
-+ opt_sum.cc procedure.cc records.cc sql_acl.cc \
-+ sql_load.cc discover.cc sql_locale.cc \
-+ sql_profile.cc \
-+ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
-+ sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
-+ sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
-+ scheduler.cc sql_connect.cc sql_parse.cc \
-+ sql_prepare.cc sql_derived.cc sql_rename.cc \
-+ sql_select.cc sql_do.cc sql_show.cc set_var.cc \
-+ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
-+ sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
-+ unireg.cc uniques.cc sql_union.cc hash_filo.cc \
-+ spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
-+ sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
-+ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
-+ rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
-+ debug_sync.cc \
-+ sql_tablespace.cc \
-+ rpl_injector.cc my_user.c partition_info.cc \
-+ sql_servers.cc event_parse_data.cc
-
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
- # The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-- @NDB_SCI_LIBS@ \
-- @mysql_plugin_libs@ \
-- $(yassl_inc_libs)
-+INC_LIB= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
-+ @ZLIB_LIBS@ @LIBDL@ \
-+ $(NDB_SCI_LIBS) \
-+ $(mysql_embedded_plugin_libs) \
-+ $(yassl_inc_libs)
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
- endif
-
-+libmysqld_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_LIBADD = $(INC_LIB)
-+
- # Storage engine specific compilation options
- ha_ndbcluster.o:ha_ndbcluster.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-@@ -139,44 +135,6 @@ ha_myisam.o:ha_myisam.cc
- ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
-- else \
-- current_dir=`pwd`; \
-- rm -rf tmp; mkdir tmp; \
-- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
-- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
-- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
-- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
-- mkdir $$artmp; cd $$artmp > /dev/null; \
-- $(AR) x ../../$$arc; \
-- cd $$current_dir > /dev/null; \
-- ls $$artmp/* | grep -v SYMDEF; \
-- continue 2; fi; done; \
-- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(AR) r libmysqld.a $(storageobjects); \
-- $(RANLIB) libmysqld.a ; \
-- rm -rf tmp; \
-- fi
--endif
--
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
- ## libmysqld interface to change without affecting the standard
-@@ -187,7 +145,7 @@ endif
-
- BUILT_SOURCES = link_sources
-
--CLEANFILES = $(BUILT_SOURCES)
-+CLEANFILES = libmysqld.la
-
- link_sources:
- for f in $(sqlsources); do \
-@@ -208,20 +166,6 @@ link_sources:
- @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
- fi ; \
- done; \
-- if test -n "$(sqlstoragesources)" ; \
-- then \
-- for f in "$(sqlstoragesources)"; do \
-- rm -f "$$f"; \
-- @LN_CP_F@ `find $(srcdir)/../sql -name "$$f"` "$$f"; \
-- done; \
-- fi; \
-- if test -n "$(storagesources)" ; \
-- then \
-- rm -f $(storagesources); \
-- for f in $(storagesourceslinks); do \
-- @LN_CP_F@ $(top_srcdir)/$$f . ; \
-- done; \
-- fi; \
- rm -f client_settings.h; \
- @LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h \
- client_settings.h; \
-@@ -229,7 +173,7 @@ link_sources:
-
-
- clean-local:
-- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlstoragesources) $(storagesources) | sed "s;\.lo;.c;g"`; \
-+ rm -f `echo $(sqlsources) $(libmysqlsources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
-
- # Don't update the files from bitkeeper
-Index: libmysqld/examples/Makefile.am
-===================================================================
---- libmysqld/examples/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ libmysqld/examples/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -37,12 +37,16 @@ INCLUDES = -I$(top_builddir)/include -I$
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
-- @NDB_SCI_LIBS@
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
-+ @NDB_SCI_LIBS@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(ZLIB_LIBS)
-
- mysqltest_embedded_LINK = $(CXXLINK)
- nodist_mysqltest_embedded_SOURCES = mysqltest.cc
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la \
- @MYSQLD_EXTRA_LDFLAGS@
-
- nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
-Index: mysys/Makefile.am
-===================================================================
---- mysys/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ mysys/Makefile.am 2010-11-27 19:42:49.000000000 +0100
-@@ -18,10 +18,10 @@ MYSQLSHAREdir = $(pkgdatadir)
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+noinst_LTLIBRARIES = libmysys.la
-+LDADD = libmysys.la $(top_builddir)/strings/libmystrings.la $(top_builddir)/dbug/libdbug.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -57,18 +57,18 @@ if NEED_THREAD
- # mf_keycache is used only in the server, so it is safe to leave the file
- # out of the non-threaded library.
- # In fact, it will currently not compile without thread support.
--libmysys_a_SOURCES += mf_keycache.c
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
-+ my_pthread.c my_thr_init.c mf_keycache.c
- endif
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-@@ -78,8 +78,6 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\"
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -88,47 +86,47 @@ FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-Index: netware/BUILD/compile-linux-tools
-===================================================================
---- netware/BUILD/compile-linux-tools.orig 2010-11-27 15:02:45.000000000 +0100
-+++ netware/BUILD/compile-linux-tools 2010-11-27 15:02:49.000000000 +0100
-@@ -34,14 +34,14 @@ make
- # Create mysql_version.h which was deleted my previous step
- ./config.status include/mysql_version.h
-
--(cd dbug; make libdbug.a)
--(cd strings; make libmystrings.a)
--(cd mysys; make libmysys.a)
--(cd storage/heap; make libheap.a)
--(cd vio; make libvio.a)
--(cd regex; make libregex.a)
--(cd storage/myisam; make libmyisam.a)
--(cd storage/myisammrg; make libmyisammrg.a)
-+(cd dbug; make libdbug.la)
-+(cd strings; make libmystrings.la)
-+(cd mysys; make libmysys.la)
-+(cd storage/heap; make libheap.la)
-+(cd vio; make libvio.la)
-+(cd regex; make libregex.la)
-+(cd storage/myisam; make libmyisam.la)
-+(cd storage/myisammrg; make libmyisammrg.la)
- (cd extra; make comp_err)
- (cd libmysql; make conf_to_src)
- (cd libmysql_r; make conf_to_src)
-Index: netware/Makefile.am
-===================================================================
---- netware/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ netware/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,8 +16,8 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
-Index: regex/Makefile.am
-===================================================================
---- regex/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ regex/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-Index: server-tools/instance-manager/Makefile.am
-===================================================================
---- server-tools/instance-manager/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ server-tools/instance-manager/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -87,10 +87,10 @@ mysqlmanager_SOURCES= command.cc command
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-Index: sql/Makefile.am
-===================================================================
---- sql/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ sql/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,13 +32,13 @@ bin_PROGRAMS = mysql_tzinfo_to_sql
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
--LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@ $(openssl_libs) $(yassl_libs)
- mysqld_LDADD = libndb.la \
- @MYSQLD_EXTRA_LDFLAGS@ \
- @pstack_libs@ \
-Index: storage/archive/Makefile.am
-===================================================================
---- storage/archive/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/archive/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -33,7 +33,7 @@ DEFS = @DEFS@
- noinst_HEADERS = ha_archive.h azlib.h
- noinst_PROGRAMS = archive_test archive_reader
-
--EXTRA_LTLIBRARIES = ha_archive.la
-+EXTRA_LTLIBRARIES = libarchive.la ha_archive.la
- pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
- ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -41,26 +41,25 @@ ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMY
- ha_archive_la_SOURCES = ha_archive.cc azio.c
-
-
--EXTRA_LIBRARIES = libarchive.a
--noinst_LIBRARIES = @plugin_archive_static_target@
--libarchive_a_CXXFLAGS = $(AM_CXXFLAGS)
--libarchive_a_CFLAGS = $(AM_CFLAGS)
--libarchive_a_SOURCES = ha_archive.cc azio.c
-+noinst_LTLIBRARIES = @plugin_archive_static_target@
-+libarchive_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_SOURCES = ha_archive.cc azio.c
-
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-Index: storage/archive/plug.in
-===================================================================
---- storage/archive/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/archive/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,4 +1,4 @@
- MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
- [Archive Storage Engine], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
-+MYSQL_PLUGIN_STATIC(archive, [libarchive.la])
- MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
-Index: storage/blackhole/Makefile.am
-===================================================================
---- storage/blackhole/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/blackhole/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_blackhole.h
-
--EXTRA_LTLIBRARIES = ha_blackhole.la
-+EXTRA_LTLIBRARIES = libblackhole.la ha_blackhole.la
- pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
- ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
- ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@ ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DM
- ha_blackhole_la_SOURCES=ha_blackhole.cc
-
-
--EXTRA_LIBRARIES = libblackhole.a
--noinst_LIBRARIES = @plugin_blackhole_static_target@
--libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS)
--libblackhole_a_CFLAGS = $(AM_CFLAGS)
--libblackhole_a_SOURCES= ha_blackhole.cc
-+noinst_LTLIBRARIES = @plugin_blackhole_static_target@
-+libblackhole_la_CXXFLAGS=$(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_SOURCES= ha_blackhole.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/blackhole/plug.in
-===================================================================
---- storage/blackhole/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/blackhole/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,6 +1,6 @@
- MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
- [Basic Write-only Read-never tables], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
--MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
-+MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.la])
- MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
-
-Index: storage/csv/Makefile.am
-===================================================================
---- storage/csv/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/csv/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -29,16 +29,15 @@ LDADD =
- DEFS = @DEFS@
- noinst_HEADERS = ha_tina.h transparent_file.h
-
--EXTRA_LTLIBRARIES = ha_csv.la
-+EXTRA_LTLIBRARIES = libcsv.la ha_csv.la
- pkglib_LTLIBRARIES = @plugin_csv_shared_target@
- ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
- ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN
- ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc
-
--EXTRA_LIBRARIES = libcsv.a
--noinst_LIBRARIES = @plugin_csv_static_target@
--libcsv_a_CXXFLAGS = $(AM_CXXFLAGS)
--libcsv_a_SOURCES = transparent_file.cc ha_tina.cc
-+noinst_LTLIBRARIES = @plugin_csv_static_target@
-+libcsv_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libcsv_la_SOURCES = transparent_file.cc ha_tina.cc
-
- EXTRA_DIST = CMakeLists.txt plug.in
- # Don't update the files from bitkeeper
-Index: storage/csv/plug.in
-===================================================================
---- storage/csv/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/csv/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
- [Stores tables in text CSV format])
- MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
--MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
-+MYSQL_PLUGIN_STATIC(csv, [libcsv.la])
- MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
-Index: storage/example/Makefile.am
-===================================================================
---- storage/example/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/example/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_example.h
-
--EXTRA_LTLIBRARIES = ha_example.la
-+EXTRA_LTLIBRARIES = libexample.la ha_example.la
- pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
- ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@ ha_example_la_CFLAGS = $(AM_CFLAGS) -DMY
- ha_example_la_SOURCES = ha_example.cc
-
-
--EXTRA_LIBRARIES = libexample.a
--noinst_LIBRARIES = @plugin_example_static_target@
--libexample_a_CXXFLAGS = $(AM_CXXFLAGS)
--libexample_a_CFLAGS = $(AM_CFLAGS)
--libexample_a_SOURCES= ha_example.cc
-+noinst_LTLIBRARIES = @plugin_example_static_target@
-+libexample_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_SOURCES= ha_example.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/federated/Makefile.am
-===================================================================
---- storage/federated/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/federated/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_federated.h
-
--EXTRA_LTLIBRARIES = ha_federated.la
-+EXTRA_LTLIBRARIES = libfederated.la libfederated_embedded.la ha_federated.la
- pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
- ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,14 @@ ha_federated_la_CFLAGS = $(AM_CFLAGS) -D
- ha_federated_la_SOURCES = ha_federated.cc
-
-
--EXTRA_LIBRARIES = libfederated.a
--noinst_LIBRARIES = @plugin_federated_static_target@
--libfederated_a_CXXFLAGS = $(AM_CXXFLAGS)
--libfederated_a_CFLAGS = $(AM_CFLAGS)
--libfederated_a_SOURCES= ha_federated.cc
-+noinst_LTLIBRARIES = @plugin_federated_static_target@ @plugin_federated_embedded_static_target@
-+libfederated_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_SOURCES= ha_federated.cc
-+
-+libfederated_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_SOURCES= ha_federated.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/federated/plug.in
-===================================================================
---- storage/federated/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/federated/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
- [Connects to tables on remote MySQL servers], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(federated, [libfederated.a])
-+MYSQL_PLUGIN_STATIC(federated, [libfederated.la], [libfederated_embedded.la])
- MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federated.cc])
-Index: storage/heap/Makefile.am
-===================================================================
---- storage/heap/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/heap/Makefile.am 2010-11-27 19:44:23.000000000 +0100
-@@ -26,27 +26,40 @@ WRAPLIBS=
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
-+noinst_LTLIBRARIES = libheap.la libheap_s.la libheap_common.la \
-+ @plugin_heap_embedded_static_target@
-+EXTRA_LTLIBRARIES = libheap_embedded.la
-+
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_common_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
- hp_rkey.c hp_block.c \
-- ha_heap.cc \
- hp_hash.c _check.c _rectest.c hp_static.c
-+libheap_common_la_CFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+
-+libheap_s_la_SOURCES = ha_heap.cc
-+libheap_s_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_LIBADD = libheap_common.la
-+libheap_embedded_la_SOURCES = ha_heap.cc
-+libheap_embedded_la_LIBADD = libheap_common.la
-+libheap_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+libheap_la_SOURCES =
-+libheap_la_LIBADD = libheap_s.la
-+libheap_la_LDFLAGS = -static
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/heap/plug.in
-===================================================================
---- storage/heap/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/heap/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,6 @@
- MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
- [Volatile memory based tables])
- MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
--MYSQL_PLUGIN_STATIC(heap, [libheap.a])
-+MYSQL_PLUGIN_STATIC(heap, [libheap_s.la], [libheap_embedded.la])
- MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(heap, [ha_heap.cc])
-
-Index: storage/innobase/Makefile.am
-===================================================================
---- storage/innobase/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innobase/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -15,21 +15,20 @@
-
- # Process this file with automake to create Makefile.in
-
--MYSQLDATAdir= $(localstatedir)
--MYSQLSHAREdir= $(pkgdatadir)
--MYSQLBASEdir= $(prefix)
--MYSQLLIBdir= $(pkglibdir)
--pkgplugindir= $(pkglibdir)/plugin
--INCLUDES= -I$(top_srcdir)/include -I$(top_builddir)/include \
-+MYSQLDATAdir = $(localstatedir)
-+MYSQLSHAREdir = $(pkgdatadir)
-+MYSQLBASEdir = $(prefix)
-+MYSQLLIBdir = $(pkglibdir)
-+pkgplugindir = $(pkglibdir)/plugin
-+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
- -I$(top_srcdir)/regex \
- -I$(top_srcdir)/storage/innobase/include \
- -I$(top_srcdir)/sql \
- -I$(srcdir)
-
--DEFS= @DEFS@
-+DEFS= @DEFS@
-
--
--noinst_HEADERS= include/btr0btr.h include/btr0btr.ic \
-+noinst_HEADERS = include/btr0btr.h include/btr0btr.ic \
- include/btr0cur.h include/btr0cur.ic \
- include/btr0pcur.h include/btr0pcur.ic \
- include/btr0sea.h include/btr0sea.ic \
-@@ -122,9 +121,8 @@ noinst_HEADERS= include/btr0btr.h inclu
- include/ut0list.ic include/ut0wqueue.h \
- include/ha_prototypes.h handler/ha_innodb.h
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innobase_static_target@
--libinnobase_a_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
-+noinst_LTLIBRARIES = @plugin_innobase_static_target@
-+libinnobase_la_SOURCES = btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
- btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
- buf/buf0lru.c buf/buf0rea.c data/data0data.c \
- data/data0type.c dict/dict0boot.c \
-@@ -156,18 +154,18 @@ libinnobase_a_SOURCES= btr/btr0btr.c btr
- ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c \
- handler/ha_innodb.cc
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS = $(AM_CXXFLAGS)
-+libinnobase_la_CFLAGS = $(AM_CFLAGS)
-
--EXTRA_LTLIBRARIES= ha_innodb.la
--pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@
-+EXTRA_LTLIBRARIES = libinnobase.la ha_innodb.la
-+pkgplugin_LTLIBRARIES = @plugin_innobase_shared_target@
-
--ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir)
--ha_innodb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_la_LDFLAGS = -module -rpath $(pkgplugindir)
-+ha_innodb_la_CXXFLAGS = $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
-+ha_innodb_la_CFLAGS = $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
-+ha_innodb_la_SOURCES = $(libinnobase_la_SOURCES)
-
--EXTRA_DIST= CMakeLists.txt plug.in \
-+EXTRA_DIST = CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
- pars/pars0grm.y pars/pars0lex.l
-
-Index: storage/innobase/plug.in
-===================================================================
---- storage/innobase/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innobase/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,7 @@
- MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
- [Transactional Tables using InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
--MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
-+MYSQL_PLUGIN_STATIC(innobase, [libinnobase.la])
- MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
- MYSQL_PLUGIN_ACTIONS(innobase, [
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
-Index: storage/innodb_plugin/Makefile.am
-===================================================================
---- storage/innodb_plugin/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innodb_plugin/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -228,9 +228,8 @@ noinst_HEADERS= \
- include/ut0wqueue.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innodb_plugin_static_target@
--libinnobase_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_innodb_plugin_static_target@
-+libinnobase_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -325,16 +324,16 @@ libinnobase_a_SOURCES= \
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libinnobase_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_innodb_plugin.la
-+EXTRA_LTLIBRARIES= libinnobase.la ha_innodb_plugin.la
- pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@
-
- ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir)
- ha_innodb_plugin_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_innodb_plugin_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_plugin_la_SOURCES= $(libinnobase_la_SOURCES)
-
- EXTRA_DIST= CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
-Index: storage/myisam/Makefile.am
-===================================================================
---- storage/myisam/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisam/Makefile.am 2010-11-27 19:44:01.000000000 +0100
-@@ -30,60 +30,63 @@ DEFS = @DEFS@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--pkglib_LIBRARIES = libmyisam.a
-+noinst_LTLIBRARIES = libmyisam.la libmyisam_common.la libmyisam_s.la \
-+ @plugin_myisam_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisam_embedded.la
-+
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
-+myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+libmyisam_common_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-@@ -98,8 +101,23 @@ libmyisam_a_SOURCES = mi_open.c mi_extra
- mi_keycache.c mi_preload.c \
- ft_parser.c ft_stopwords.c ft_static.c \
- ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c \
-- ha_myisam.cc \
- rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
-+libmyisam_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_SOURCES = ha_myisam.cc
-+libmyisam_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_SOURCES = ha_myisam.cc
-+libmyisam_embedded_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+# libmyisam references symbols inside mysqld.
-+# This means we cannot use it as shared library, as these references causes
-+# undefined symbol errors at load time.
-+# But a static library works (as long as those parts that references
-+# problematic symbols are not linked).
-+libmyisam_la_LDFLAGS = -static
-+libmyisam_la_SOURCES =
-+libmyisam_la_LIBADD = libmyisam_s.la
-+
- CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-
- # Move to automake rules ?
-Index: storage/myisam/plug.in
-===================================================================
---- storage/myisam/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisam/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- [Traditional non-transactional MySQL tables])
- MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
--
-Index: storage/myisammrg/Makefile.am
-===================================================================
---- storage/myisammrg/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisammrg/Makefile.am 2010-11-27 19:43:39.000000000 +0100
-@@ -26,16 +26,28 @@ WRAPLIBS=
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la libmyisammrg_s.la libmyisammrg_common.la \
-+ @plugin_myisammrg_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisammrg_embedded.la
- noinst_HEADERS = myrg_def.h ha_myisammrg.h
--noinst_LIBRARIES = libmyisammrg.a
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_common_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
- myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
-- ha_myisammrg.cc \
- myrg_rnext_same.c myrg_records.c
-+libmyisammrg_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libmyisammrg_embedded_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libmyisammrg_la_SOURCES =
-+libmyisammrg_la_LIBADD = libmyisammrg_s.la
-+libmyisammrg_la_LDFLAGS = -static
-+
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/myisammrg/plug.in
-===================================================================
---- storage/myisammrg/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisammrg/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
- [Merge multiple MySQL tables into one])
- MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
--MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
-+MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg_s.la], [libmyisammrg_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisammrg)
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc])
-Index: storage/ndb/src/common/util/Makefile.am
-===================================================================
---- storage/ndb/src/common/util/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/common/util/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -31,9 +31,9 @@ EXTRA_PROGRAMS = testBitmask
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-Index: storage/ndb/config/type_ndbapitest.mk.am
-===================================================================
---- storage/ndb/config/type_ndbapitest.mk.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/type_ndbapitest.mk.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,19 +13,20 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--LDADD += $(top_builddir)/storage/ndb/test/src/libNDBT.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+LDADD += $(top_builddir)/storage/ndb/test/src/libNDBT.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
--INCLUDES += -I$(top_srcdir) \
-- -I$(top_builddir)/include \
-- -I$(top_builddir)/storage/ndb/include \
-- -I$(top_srcdir)/include \
-- -I$(top_srcdir)/storage/ndb/include \
-- -I$(top_srcdir)/storage/ndb/include/ndbapi \
-- -I$(top_srcdir)/storage/ndb/include/util \
-- -I$(top_srcdir)/storage/ndb/include/portlib \
-- -I$(top_srcdir)/storage/ndb/test/include \
-- -I$(top_srcdir)/storage/ndb/include/mgmapi
-+INCLUDES += -I$(top_srcdir) \
-+ -I$(top_builddir)/include \
-+ -I$(top_builddir)/storage/ndb/include \
-+ -I$(top_srcdir)/include \
-+ -I$(top_srcdir)/storage/ndb/include \
-+ -I$(top_srcdir)/storage/ndb/include/ndbapi \
-+ -I$(top_srcdir)/storage/ndb/include/util \
-+ -I$(top_srcdir)/storage/ndb/include/portlib \
-+ -I$(top_srcdir)/storage/ndb/test/include \
-+ -I$(top_srcdir)/storage/ndb/include/mgmapi
-Index: storage/ndb/config/type_ndbapitools.mk.am
-===================================================================
---- storage/ndb/config/type_ndbapitools.mk.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/type_ndbapitools.mk.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,20 +13,21 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--LDADD += \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ @ZLIB_LIBS@
-+LDADD += \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
--INCLUDES += -I$(srcdir) \
-- -I$(top_builddir)/include \
-- -I$(top_builddir)/storage/ndb/include \
-- -I$(top_srcdir)/include \
-- -I$(top_srcdir)/storage/ndb/include \
-- -I$(top_srcdir)/storage/ndb/include/ndbapi \
-- -I$(top_srcdir)/storage/ndb/include/util \
-- -I$(top_srcdir)/storage/ndb/include/portlib \
-- -I$(top_srcdir)/storage/ndb/test/include \
-- -I$(top_srcdir)/storage/ndb/include/mgmapi \
-- -I$(top_srcdir)/storage/ndb/include/kernel
-+INCLUDES += -I$(srcdir) \
-+ -I$(top_builddir)/include \
-+ -I$(top_builddir)/storage/ndb/include \
-+ -I$(top_srcdir)/include \
-+ -I$(top_srcdir)/storage/ndb/include \
-+ -I$(top_srcdir)/storage/ndb/include/ndbapi \
-+ -I$(top_srcdir)/storage/ndb/include/util \
-+ -I$(top_srcdir)/storage/ndb/include/portlib \
-+ -I$(top_srcdir)/storage/ndb/test/include \
-+ -I$(top_srcdir)/storage/ndb/include/mgmapi \
-+ -I$(top_srcdir)/storage/ndb/include/kernel
-Index: storage/ndb/config/win-libraries
-===================================================================
---- storage/ndb/config/win-libraries.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/win-libraries 2010-11-27 15:02:49.000000000 +0100
-@@ -21,7 +21,7 @@ do
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
-Index: storage/ndb/src/cw/cpcd/Makefile.am
-===================================================================
---- storage/ndb/src/cw/cpcd/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/cw/cpcd/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -19,9 +19,9 @@ ndb_cpcd_SOURCES = main.cpp CPCD.cpp Pro
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-Index: storage/ndb/src/kernel/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -53,9 +53,10 @@ LDADD += \
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
- windoze-dsp: ndbd.dsp
-
-Index: storage/ndb/src/kernel/blocks/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -18,7 +18,7 @@ SUBDIRS = \
- dbdih \
- dblqh \
- dbtup \
-- backup
-+ backup
-
- noinst_LIBRARIES = libblocks.a
-
-@@ -56,10 +56,10 @@ libblocks_a_SOURCES = tsman.cpp lgman.cp
- EXTRA_PROGRAMS = ndb_print_file
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-Index: storage/ndb/src/kernel/blocks/backup/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/backup/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -17,9 +17,9 @@ ndbtools_PROGRAMS = ndb_print_backup_fil
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-Index: storage/ndb/src/kernel/blocks/dbdict/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbdict/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -19,17 +19,17 @@ include $(top_srcdir)/storage/ndb/config
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/blocks/dbdih/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbdih/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -17,9 +17,9 @@ ndbtools_PROGRAMS = ndb_print_sys_file
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-Index: storage/ndb/src/kernel/blocks/dblqh/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dblqh/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -23,9 +23,9 @@ include $(top_srcdir)/storage/ndb/config
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/blocks/dbtup/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbtup/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -20,9 +20,9 @@ EXTRA_PROGRAMS = test_varpage
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/vm/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/vm/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/vm/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -21,22 +21,22 @@
- noinst_LIBRARIES = libkernel.a
-
- libkernel_a_SOURCES = \
-- SimulatedBlock.cpp \
-- FastScheduler.cpp \
-- TimeQueue.cpp \
-- VMSignal.cpp \
-- ThreadConfig.cpp \
-- TransporterCallback.cpp \
-- Emulator.cpp \
-- Configuration.cpp \
-- WatchDog.cpp \
-- SimplePropertiesSection.cpp \
-- SectionReader.cpp \
-- Mutex.cpp SafeCounter.cpp \
-- Rope.cpp \
-- ndbd_malloc.cpp ndbd_malloc_impl.cpp \
-- Pool.cpp WOPool.cpp RWPool.cpp \
-- DynArr256.cpp
-+ SimulatedBlock.cpp \
-+ FastScheduler.cpp \
-+ TimeQueue.cpp \
-+ VMSignal.cpp \
-+ ThreadConfig.cpp \
-+ TransporterCallback.cpp \
-+ Emulator.cpp \
-+ Configuration.cpp \
-+ WatchDog.cpp \
-+ SimplePropertiesSection.cpp \
-+ SectionReader.cpp \
-+ Mutex.cpp SafeCounter.cpp \
-+ Rope.cpp \
-+ ndbd_malloc.cpp ndbd_malloc_impl.cpp \
-+ Pool.cpp WOPool.cpp RWPool.cpp \
-+ DynArr256.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
-
-@@ -49,40 +49,40 @@ include $(top_srcdir)/storage/ndb/config
- windoze-dsp: libkernel.dsp
-
- libkernel.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libkernel_a_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libkernel_a_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-
- EXTRA_PROGRAMS = ndbd_malloc_impl_test bench_pool testDynArr256
- ndbd_malloc_impl_test_CXXFLAGS = -DUNIT_TEST
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
--bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
-- libkernel.a ../error/liberror.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+bench_pool_LDFLAGS = @ndb_bin_am_ldflags@ \
-+ libkernel.a ../error/liberror.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
-- libkernel.a ../error/liberror.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ libkernel.a ../error/liberror.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-Index: storage/ndb/src/mgmclient/Makefile.am
-===================================================================
---- storage/ndb/src/mgmclient/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/mgmclient/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -18,12 +18,11 @@ ndbtools_PROGRAMS = ndb_mgm
-
- libndbmgmclient_la_SOURCES = CommandInterpreter.cpp
- libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \
-- ../common/logger/liblogger.la \
-- ../common/portlib/libportlib.la \
-- ../common/util/libgeneral.la \
-- ../common/portlib/libportlib.la \
-- ../common/debugger/libtrace.la
--
-+ ../common/logger/liblogger.la \
-+ ../common/portlib/libportlib.la \
-+ ../common/util/libgeneral.la \
-+ ../common/portlib/libportlib.la \
-+ ../common/debugger/libtrace.la
-
- ndb_mgm_SOURCES = main.cpp
-
-@@ -34,13 +33,13 @@ INCLUDES += -I$(top_srcdir)/storage/ndb/
- -I$(top_srcdir)/storage/ndb/src/common/mgmcommon
-
- LDADD_LOC = $(noinst_LTLIBRARIES) \
-- ../common/portlib/libportlib.la \
-- @readline_link@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-+ ../common/portlib/libportlib.la \
-+ @readline_link@ \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-
-@@ -50,25 +49,25 @@ ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
- windoze-dsp: ndb_mgm.dsp libndbmgmclient.dsp
-
- ndb_mgm.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-prg.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbtools_PROGRAMS)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgm_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-prg.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbtools_PROGRAMS)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgm_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-
- libndbmgmclient.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB
-Index: storage/ndb/src/mgmsrv/Makefile.am
-===================================================================
---- storage/ndb/src/mgmsrv/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/mgmsrv/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -22,35 +22,35 @@ MYSQLCLUSTERdir= .
- ndbbin_PROGRAMS = ndb_mgmd
-
- ndb_mgmd_SOURCES = \
-- MgmtSrvr.cpp \
-- MgmtSrvrGeneralSignalHandling.cpp \
-- main.cpp \
-- Services.cpp \
-- convertStrToInt.cpp \
-- SignalQueue.cpp \
-- MgmtSrvrConfig.cpp \
-- ConfigInfo.cpp \
-- InitConfigFileParser.cpp \
-- Config.cpp
-+ MgmtSrvr.cpp \
-+ MgmtSrvrGeneralSignalHandling.cpp \
-+ main.cpp \
-+ Services.cpp \
-+ convertStrToInt.cpp \
-+ SignalQueue.cpp \
-+ MgmtSrvrConfig.cpp \
-+ ConfigInfo.cpp \
-+ InitConfigFileParser.cpp \
-+ Config.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/ndbapi \
-- -I$(top_srcdir)/storage/ndb/src/mgmapi \
-- -I$(top_srcdir)/storage/ndb/src/common/mgmcommon \
-- -I$(top_srcdir)/storage/ndb/src/mgmclient
-+ -I$(top_srcdir)/storage/ndb/src/mgmapi \
-+ -I$(top_srcdir)/storage/ndb/src/common/mgmcommon \
-+ -I$(top_srcdir)/storage/ndb/src/mgmclient
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- @readline_link@ \
-- @NDB_SCI_LIBS@ \
-- @TERMCAP_LIB@
--
--DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
-- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-- -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\""
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ @readline_link@ \
-+ @NDB_SCI_LIBS@ \
-+ @TERMCAP_LIB@
-+
-+DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-+ -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
-+ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-+ -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\""
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-@@ -63,13 +63,13 @@ ndb_mgmd_LDFLAGS = @ndb_bin_am_ldflags@
- windoze-dsp: ndb_mgmd.dsp
-
- ndb_mgmd.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-prg.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbbin_PROGRAMS)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgmd_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-prg.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbbin_PROGRAMS)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgmd_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-Index: storage/ndb/src/ndbapi/Makefile.am
-===================================================================
---- storage/ndb/src/ndbapi/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/ndbapi/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -22,41 +22,42 @@ ndberror_check_SOURCES = ndberror_check.
- noinst_LTLIBRARIES = libndbapi.la
-
- libndbapi_la_SOURCES = \
-- TransporterFacade.cpp \
-- ClusterMgr.cpp \
-- Ndb.cpp \
-- NdbPoolImpl.cpp \
-- NdbPool.cpp \
-- Ndblist.cpp \
-- Ndbif.cpp \
-- Ndbinit.cpp \
-- Ndberr.cpp \
-- ndberror.c \
-- NdbErrorOut.cpp \
-- NdbTransaction.cpp \
-- NdbTransactionScan.cpp \
-- NdbOperation.cpp \
-- NdbOperationSearch.cpp \
-- NdbOperationScan.cpp \
-- NdbOperationInt.cpp \
-- NdbOperationDefine.cpp \
-- NdbOperationExec.cpp \
-- NdbScanOperation.cpp NdbScanFilter.cpp \
-- NdbIndexOperation.cpp \
-- NdbEventOperation.cpp \
-- NdbEventOperationImpl.cpp \
-- NdbApiSignal.cpp \
-- NdbRecAttr.cpp \
-- NdbUtil.cpp \
-- NdbReceiver.cpp \
-- NdbDictionary.cpp \
-- NdbDictionaryImpl.cpp \
-- DictCache.cpp \
-- ndb_cluster_connection.cpp \
-- NdbBlob.cpp \
-- NdbIndexStat.cpp \
-- SignalSender.cpp \
-- ObjectMap.cpp
-+ TransporterFacade.cpp \
-+ ClusterMgr.cpp \
-+ Ndb.cpp \
-+ NdbPoolImpl.cpp \
-+ NdbPool.cpp \
-+ Ndblist.cpp \
-+ Ndbif.cpp \
-+ Ndbinit.cpp \
-+ Ndberr.cpp \
-+ ndberror.c \
-+ NdbErrorOut.cpp \
-+ NdbTransaction.cpp \
-+ NdbTransactionScan.cpp \
-+ NdbOperation.cpp \
-+ NdbOperationSearch.cpp \
-+ NdbOperationScan.cpp \
-+ NdbOperationInt.cpp \
-+ NdbOperationDefine.cpp \
-+ NdbOperationExec.cpp \
-+ NdbScanOperation.cpp \
-+ NdbScanFilter.cpp \
-+ NdbIndexOperation.cpp \
-+ NdbEventOperation.cpp \
-+ NdbEventOperationImpl.cpp \
-+ NdbApiSignal.cpp \
-+ NdbRecAttr.cpp \
-+ NdbUtil.cpp \
-+ NdbReceiver.cpp \
-+ NdbDictionary.cpp \
-+ NdbDictionaryImpl.cpp \
-+ DictCache.cpp \
-+ ndb_cluster_connection.cpp \
-+ NdbBlob.cpp \
-+ NdbIndexStat.cpp \
-+ SignalSender.cpp \
-+ ObjectMap.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
-
-@@ -67,9 +68,10 @@ include $(top_srcdir)/storage/ndb/config
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
- ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-@@ -77,13 +79,13 @@ ndberror_check_LDFLAGS = \
- windoze-dsp: libndbapi.dsp
-
- libndbapi.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbapi_la_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbapi_la_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-Index: storage/ndb/test/run-test/Makefile.am
-===================================================================
---- storage/ndb/test/run-test/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/test/run-test/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -34,9 +34,9 @@ atrt_SOURCES = main.cpp setup.cpp files.
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-Index: strings/Makefile.am
-===================================================================
---- strings/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ strings/Makefile.am 2010-11-27 19:42:38.000000000 +0100
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@ CSRCS = strxmov.c bmove_upp.c strappend
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,9 +56,9 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
- conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-@@ -69,15 +69,15 @@ conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
- test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-Index: unittest/unit.pl
-===================================================================
---- unittest/unit.pl.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/unit.pl 2010-11-27 15:02:49.000000000 +0100
-@@ -55,7 +55,7 @@ sub _find_test_files (@) {
- my @dirs = @_;
- my @files;
- find sub {
-- $File::Find::prune = 1 if /^SCCS$/;
-+ $File::Find::prune = 1 if /^(SCCS|\.libs)$/;
- push(@files, $File::Find::name) if -x _ && /-t\z/;
- }, @dirs;
- return @files;
-Index: unittest/mysys/Makefile.am
-===================================================================
---- unittest/mysys/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/mysys/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,15 +13,16 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
--AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-+AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
-+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
--LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
--noinst_PROGRAMS = bitmap-t base64-t
-+noinst_PROGRAMS = bitmap-t base64-t
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: unittest/strings/Makefile.am
-===================================================================
---- unittest/strings/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/strings/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,10 +16,11 @@
- AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
--LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- noinst_PROGRAMS = strings-t
-
-Index: vio/Makefile.am
-===================================================================
---- vio/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ vio/Makefile.am 2010-11-27 19:43:02.000000000 +0100
-@@ -16,11 +16,11 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+noinst_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/02040_all_embedded-library-shared-5.1.60.patch b/02040_all_embedded-library-shared-5.1.60.patch
deleted file mode 100644
index 4bff5b6..0000000
--- a/02040_all_embedded-library-shared-5.1.60.patch
+++ /dev/null
@@ -1,2298 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-Thanks to Maciej Mrozowski <reavertm@gentoo.org> for working in the redo of the
-patch for mysql-5.1.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
-
-=== modified file 'client/Makefile.am'
----
- client/Makefile.am | 11 -
- config/ac-macros/plugins.m4 | 107 ++++++++-----
- configure.in | 8 -
- dbug/Makefile.am | 6
- extra/Makefile.am | 4
- libmysqld/Makefile.am | 184 ++++++++---------------
- libmysqld/examples/Makefile.am | 10 -
- mysys/Makefile.am | 42 ++---
- netware/BUILD/compile-linux-tools | 16 +-
- netware/Makefile.am | 4
- regex/Makefile.am | 6
- server-tools/instance-manager/Makefile.am | 8 -
- sql/Makefile.am | 12 -
- storage/archive/Makefile.am | 23 +-
- storage/archive/plug.in | 2
- storage/blackhole/Makefile.am | 11 -
- storage/blackhole/plug.in | 2
- storage/csv/Makefile.am | 9 -
- storage/csv/plug.in | 2
- storage/example/Makefile.am | 11 -
- storage/federated/Makefile.am | 15 +
- storage/federated/plug.in | 3
- storage/heap/Makefile.am | 37 +++-
- storage/heap/plug.in | 3
- storage/innobase/Makefile.am | 40 ++---
- storage/innobase/plug.in | 2
- storage/innodb_plugin/Makefile.am | 13 -
- storage/myisam/Makefile.am | 118 ++++++++------
- storage/myisam/plug.in | 4
- storage/myisammrg/Makefile.am | 20 ++
- storage/myisammrg/plug.in | 3
- storage/ndb/config/type_ndbapitest.mk.am | 31 ++-
- storage/ndb/config/type_ndbapitools.mk.am | 33 ++--
- storage/ndb/config/win-libraries | 2
- storage/ndb/src/common/util/Makefile.am | 6
- storage/ndb/src/cw/cpcd/Makefile.am | 6
- storage/ndb/src/kernel/Makefile.am | 7
- storage/ndb/src/kernel/blocks/Makefile.am | 10 -
- storage/ndb/src/kernel/blocks/backup/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dbdict/Makefile.am | 12 -
- storage/ndb/src/kernel/blocks/dbdih/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dblqh/Makefile.am | 6
- storage/ndb/src/kernel/blocks/dbtup/Makefile.am | 6
- storage/ndb/src/kernel/vm/Makefile.am | 82 +++++-----
- storage/ndb/src/mgmclient/Makefile.am | 65 ++++----
- storage/ndb/src/mgmsrv/Makefile.am | 70 ++++----
- storage/ndb/src/ndbapi/Makefile.am | 98 ++++++------
- storage/ndb/test/run-test/Makefile.am | 6
- strings/Makefile.am | 16 +-
- unittest/mysys/Makefile.am | 15 +
- unittest/strings/Makefile.am | 9 -
- unittest/unit.pl | 2
- vio/Makefile.am | 4
- 53 files changed, 622 insertions(+), 612 deletions(-)
-
-Index: client/Makefile.am
-===================================================================
---- client/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ client/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -75,7 +75,8 @@ mysqlimport_CFLAGS= -DTHREAD -UUNDEF_TH
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +85,17 @@ mysqlslap_CFLAGS= -DTHREAD -UMYSQL_CLIE
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-Index: config/ac-macros/plugins.m4
-===================================================================
---- config/ac-macros/plugins.m4.orig 2010-11-27 15:02:45.000000000 +0100
-+++ config/ac-macros/plugins.m4 2010-11-27 15:02:49.000000000 +0100
-@@ -115,18 +115,32 @@ dnl ------------------------------------
- dnl Macro: MYSQL_PLUGIN_STATIC
- dnl
- dnl SYNOPSIS
--dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
-+dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a],[libmyplugin_embedded.a])
- dnl
- dnl DESCRIPTION
--dnl Declare the name for the static library
-+dnl Declare the name for the static library
-+dnl
-+dnl Third argument is optional, only needed for special plugins that depend
-+dnl on server internals and have source files that must be compiled specially
-+dnl with -DEMBEDDED_LIBRARY for embedded server. If specified, the third
-+dnl argument is used to link embedded server instead of the second.
- dnl
- dnl ---------------------------------------------------------------------------
-
- AC_DEFUN([MYSQL_PLUGIN_STATIC],[
- MYSQL_REQUIRE_PLUGIN([$1])
- m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
-+ ifelse($#, 3, [
-+ m4_define([MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]), [$3])
-+ ])
- ])
-
-+dnl ---------------------------------------------------------------------------
-+dnl Substitution variable to use to compile source files specially for
-+dnl embedded server.
-+dnl To be used by plugins that have sources that depend on server internals.
-+dnl ---------------------------------------------------------------------------
-+AC_SUBST([plugin_embedded_defs], ["-DEMBEDDED_LIBRARY -DMYSQL_SERVER"])
-
- dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_PLUGIN_DYNAMIC
-@@ -254,29 +268,6 @@ AC_DEFUN([MYSQL_PLUGIN_ACTIONS],[
- ])
-
- dnl ---------------------------------------------------------------------------
--dnl Macro: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS
--dnl
--dnl SYNOPSIS
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS([name],[file name])
--dnl
--dnl DESCRIPTION
--dnl Some modules in plugins keep dependance on structures
--dnl declared in sql/ (THD class usually)
--dnl That has to be fixed in the future, but until then
--dnl we have to recompile these modules when we want to
--dnl to compile server parts with the different #defines
--dnl Normally it happens when we compile the embedded server
--dnl Thus one should mark such files in his handler using this macro
--dnl (currently only one such a file per plugin is supported)
--dnl
--dnl ---------------------------------------------------------------------------
--
--AC_DEFUN([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS],[
-- MYSQL_REQUIRE_PLUGIN([$1])
-- m4_define([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]), [$2])
--])
--
--dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_CONFIGURE_PLUGINS
- dnl
- dnl SYNOPSIS
-@@ -336,11 +327,25 @@ AC_DEFUN([_MYSQL_EMIT_CHECK_PLUGIN],[
- [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
-- [MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]),
-+ [MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
- )
- ])
-
-+# __MYSQL_EMIT_CHECK_PLUGIN arguments:
-+#
-+# 1 - plugin identifying name
-+# 2 - plugin identifying name, with `-' replaced by `_'
-+# 3 - plugin long name
-+# 4 - plugin description
-+# 5 - mysql_plugin_define (eg. WITH_xxx_STORAGE_ENGINE)
-+# 6 - directory
-+# 7 - static target (if supports static build)
-+# 8 - dynamic target (if supports dynamic build)
-+# 9 - mandatory flag
-+# 10 - disabled flag
-+# 11 - static target for libmysqld (if different from mysqld)
-+# 12 - actions
- AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- m4_ifdef([$5],[
- AH_TEMPLATE($5, [Include ]$4[ into mysqld])
-@@ -407,6 +412,7 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- ])
- AC_SUBST([plugin_]$2[_shared_target], "$8")
- AC_SUBST([plugin_]$2[_static_target], [""])
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
- [with_plugin_]$2=yes
- AC_MSG_RESULT([plugin])
- m4_ifdef([$6],[
-@@ -421,32 +427,47 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- ])
- else
- m4_ifdef([$7],[
-- ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
--dnl change above "-2" to "0" to enable this section
--dnl Although this is "pretty", it breaks libmysqld build
-- m4_ifdef([$6],[
-- mysql_use_plugin_dir="$6"
-- mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
-- ])
-- mysql_plugin_libs="$mysql_plugin_libs dnl
--[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
-- ], m4_bregexp($7, [^\\\$]), 0, [
-+ ifelse(m4_bregexp($7, [^\\\$]), 0, [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- ])
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ], [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$7"
-+ ])
- ],[
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ])
- ])
- m4_ifdef([$5],[
- AC_DEFINE($5)
- ])
- AC_SUBST([plugin_]$2[_static_target], "$7")
-+ m4_ifdef([$11], [
-+ if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_]$2[_embedded_static_target], "$11")
-+ else
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ fi
-+ ], [
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ ])
- AC_SUBST([plugin_]$2[_shared_target], [""])
- ],[
- m4_ifdef([$6],[
-@@ -463,12 +484,6 @@ dnl Although this is "pretty", it breaks
- mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
- [with_plugin_]$2=yes
- AC_MSG_RESULT([yes])
-- m4_ifdef([$11],[
-- condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp($11, [[^/]+$], [\&])"
-- condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp($11, [[^/]+\.], [\&o])"
-- condition_dependent_plugin_links="$condition_dependent_plugin_links $6/$11"
-- condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
-- ])
- fi
- fi
-
-@@ -516,6 +531,14 @@ dnl
- ])
- ])
-
-+dnl If not building libmysqld embedded server, then there is no need to build
-+dnl shared object versions of static plugins.
-+if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_static_if_no_embedded], "")
-+else
-+ AC_SUBST([plugin_static_if_no_embedded], "-static")
-+fi
-+
- AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
- ifelse($#, 0, [], $#, 1, [
- _MYSQL_EMIT_PLUGIN_ACTION([$1])
-Index: configure.in
-===================================================================
---- configure.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ configure.in 2010-11-27 19:41:49.000000000 +0100
-@@ -2483,8 +2483,6 @@ MYSQL_STORAGE_ENGINE(partition, partitio
-
- dnl -- ndbcluster requires partition to be enabled
-
--MYSQL_CONFIGURE_PLUGINS([none])
--
- # Only build client code?
- AC_ARG_WITH(server,
- [ --without-server Only build the client.],
-@@ -2498,6 +2496,8 @@ AC_ARG_WITH(embedded-server,
- [with_embedded_server=no]
- )
-
-+MYSQL_CONFIGURE_PLUGINS([none])
-+
- AC_ARG_WITH(query_cache,
- [ --without-query-cache Do not build query cache.],
- [with_query_cache=$withval],
-@@ -2801,9 +2801,6 @@ if test "$with_server" != "no" -o "$THRE
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
- AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
-
-@@ -2831,6 +2828,7 @@ AC_SUBST(server_scripts)
-
- AC_SUBST(mysql_plugin_dirs)
- AC_SUBST(mysql_plugin_libs)
-+AC_SUBST(mysql_embedded_plugin_libs)
- AC_SUBST(mysql_plugin_defs)
-
-
-Index: dbug/Makefile.am
-===================================================================
---- dbug/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ dbug/Makefile.am 2010-11-27 19:42:26.000000000 +0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = libdbug.la ../mysys/libmysys.la ../strings/libmystrings.la $(ZLIB_LIBS)
-+noinst_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-Index: extra/Makefile.am
-===================================================================
---- extra/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ extra/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-Index: libmysqld/Makefile.am
-===================================================================
---- libmysqld/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ libmysqld/Makefile.am 2010-11-27 20:58:00.000000000 +0100
-@@ -17,95 +17,91 @@
- #
- # This file is public domain and comes with NO WARRANTY of any kind
-
--MYSQLDATAdir = $(localstatedir)
--MYSQLSHAREdir = $(pkgdatadir)
--MYSQLBASEdir= $(prefix)
--MYSQLLIBdir= $(libdir)
--pkgplugindir = $(pkglibdir)/plugin
-+MYSQLDATAdir = $(localstatedir)
-+MYSQLSHAREdir = $(pkgdatadir)
-+MYSQLBASEdir = $(prefix)
-+MYSQLLIBdir = $(libdir)
-+pkgplugindir = $(pkglibdir)/plugin
-
--EXTRA_DIST = libmysqld.def CMakeLists.txt
--DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
-+EXTRA_DIST = libmysqld.def CMakeLists.txt
-+DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
- -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- -DPLUGINDIR="\"$(pkgplugindir)\""
--INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include \
-+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_builddir)/sql -I$(top_srcdir)/sql \
- -I$(top_srcdir)/sql/examples \
- -I$(top_srcdir)/regex \
-- $(openssl_includes) @ZLIB_INCLUDES@ \
-- @condition_dependent_plugin_includes@
-+ $(openssl_includes) $(ZLIB_INCLUDES) \
-+ @condition_dependent_plugin_includes@ \
-+ $(ndbcluster_includes)
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
--SUBDIRS = . examples
-+pkglib_LTLIBRARIES = libmysqld.la
-+SUBDIRS = . examples
- libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
-- my_time.c
-+ my_time.c
-
- noinst_HEADERS = embedded_priv.h emb_qcache.h
-
--sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
-- ha_ndbcluster.cc ha_ndbcluster_cond.cc \
-- ha_ndbcluster_binlog.cc ha_partition.cc \
-- handler.cc sql_handler.cc \
-- hostname.cc init.cc password.c \
-- item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
-- item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
-- item_geofunc.cc item_subselect.cc item_row.cc\
-- item_xmlfunc.cc \
-- key.cc lock.cc log.cc sql_state.c \
-- log_event.cc rpl_record.cc \
-- log_event_old.cc rpl_record_old.cc \
-- protocol.cc net_serv.cc opt_range.cc \
-- opt_sum.cc procedure.cc records.cc sql_acl.cc \
-- sql_load.cc discover.cc sql_locale.cc \
-- sql_profile.cc \
-- sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
-- sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
-- sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
-- scheduler.cc sql_connect.cc sql_parse.cc \
-- sql_prepare.cc sql_derived.cc sql_rename.cc \
-- sql_select.cc sql_do.cc sql_show.cc set_var.cc \
-- sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
-- sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
-- unireg.cc uniques.cc sql_union.cc hash_filo.cc \
-- spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
-- sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
-- parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
-- rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
-- debug_sync.cc \
-- sql_tablespace.cc \
-- rpl_injector.cc my_user.c partition_info.cc \
-- sql_servers.cc event_parse_data.cc
--
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
--
--sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
--storagesources = @condition_dependent_plugin_modules@
--storageobjects = @condition_dependent_plugin_objects@
--storagesourceslinks = @condition_dependent_plugin_links@
-+sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
-+ ha_ndbcluster.cc ha_ndbcluster_cond.cc \
-+ ha_ndbcluster_binlog.cc ha_partition.cc \
-+ handler.cc sql_handler.cc \
-+ hostname.cc init.cc password.c \
-+ item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
-+ item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
-+ item_geofunc.cc item_subselect.cc item_row.cc\
-+ item_xmlfunc.cc \
-+ key.cc lock.cc log.cc sql_state.c \
-+ log_event.cc rpl_record.cc \
-+ log_event_old.cc rpl_record_old.cc \
-+ protocol.cc net_serv.cc opt_range.cc \
-+ opt_sum.cc procedure.cc records.cc sql_acl.cc \
-+ sql_load.cc discover.cc sql_locale.cc \
-+ sql_profile.cc \
-+ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
-+ sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
-+ sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \
-+ scheduler.cc sql_connect.cc sql_parse.cc \
-+ sql_prepare.cc sql_derived.cc sql_rename.cc \
-+ sql_select.cc sql_do.cc sql_show.cc set_var.cc \
-+ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
-+ sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
-+ unireg.cc uniques.cc sql_union.cc hash_filo.cc \
-+ spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
-+ sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
-+ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
-+ rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
-+ debug_sync.cc \
-+ sql_tablespace.cc \
-+ rpl_injector.cc my_user.c partition_info.cc \
-+ sql_servers.cc event_parse_data.cc
-
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
- # The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-- @NDB_SCI_LIBS@ \
-- @mysql_plugin_libs@ \
-- $(yassl_inc_libs)
-+INC_LIB= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
-+ @ZLIB_LIBS@ @LIBDL@ \
-+ $(NDB_SCI_LIBS) \
-+ $(mysql_embedded_plugin_libs) \
-+ $(yassl_inc_libs)
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
- endif
-
-+libmysqld_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_LIBADD = $(INC_LIB)
-+
- # Storage engine specific compilation options
- ha_ndbcluster.o:ha_ndbcluster.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-@@ -139,44 +135,6 @@ ha_myisam.o:ha_myisam.cc
- ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
-- else \
-- current_dir=`pwd`; \
-- rm -rf tmp; mkdir tmp; \
-- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
-- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
-- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
-- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
-- mkdir $$artmp; cd $$artmp > /dev/null; \
-- $(AR) x ../../$$arc; \
-- cd $$current_dir > /dev/null; \
-- ls $$artmp/* | grep -v SYMDEF; \
-- continue 2; fi; done; \
-- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(AR) r libmysqld.a $(storageobjects); \
-- $(RANLIB) libmysqld.a ; \
-- rm -rf tmp; \
-- fi
--endif
--
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
- ## libmysqld interface to change without affecting the standard
-@@ -187,7 +145,7 @@ endif
-
- BUILT_SOURCES = link_sources
-
--CLEANFILES = $(BUILT_SOURCES)
-+CLEANFILES = libmysqld.la
-
- link_sources:
- for f in $(sqlsources); do \
-@@ -208,20 +166,6 @@ link_sources:
- @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
- fi ; \
- done; \
-- if test -n "$(sqlstoragesources)" ; \
-- then \
-- for f in "$(sqlstoragesources)"; do \
-- rm -f "$$f"; \
-- @LN_CP_F@ `find $(srcdir)/../sql -name "$$f"` "$$f"; \
-- done; \
-- fi; \
-- if test -n "$(storagesources)" ; \
-- then \
-- rm -f $(storagesources); \
-- for f in $(storagesourceslinks); do \
-- @LN_CP_F@ $(top_srcdir)/$$f . ; \
-- done; \
-- fi; \
- rm -f client_settings.h; \
- @LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h \
- client_settings.h; \
-@@ -229,7 +173,7 @@ link_sources:
-
-
- clean-local:
-- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlstoragesources) $(storagesources) | sed "s;\.lo;.c;g"`; \
-+ rm -f `echo $(sqlsources) $(libmysqlsources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
-
- # Don't update the files from bitkeeper
-Index: libmysqld/examples/Makefile.am
-===================================================================
---- libmysqld/examples/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ libmysqld/examples/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -37,12 +37,16 @@ INCLUDES = -I$(top_builddir)/include -I$
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
-- @NDB_SCI_LIBS@
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
-+ @NDB_SCI_LIBS@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(ZLIB_LIBS)
-
- mysqltest_embedded_LINK = $(CXXLINK)
- nodist_mysqltest_embedded_SOURCES = mysqltest.cc
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la \
- @MYSQLD_EXTRA_LDFLAGS@
-
- nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
-Index: mysys/Makefile.am
-===================================================================
---- mysys/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ mysys/Makefile.am 2010-11-27 19:42:49.000000000 +0100
-@@ -18,10 +18,10 @@ MYSQLSHAREdir = $(pkgdatadir)
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+noinst_LTLIBRARIES = libmysys.la
-+LDADD = libmysys.la $(top_builddir)/strings/libmystrings.la $(top_builddir)/dbug/libdbug.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -57,18 +57,18 @@ if NEED_THREAD
- # mf_keycache is used only in the server, so it is safe to leave the file
- # out of the non-threaded library.
- # In fact, it will currently not compile without thread support.
--libmysys_a_SOURCES += mf_keycache.c
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
-+ my_pthread.c my_thr_init.c mf_keycache.c
- endif
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-@@ -78,8 +78,6 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\"
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -88,47 +86,47 @@ FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-Index: netware/BUILD/compile-linux-tools
-===================================================================
---- netware/BUILD/compile-linux-tools.orig 2010-11-27 15:02:45.000000000 +0100
-+++ netware/BUILD/compile-linux-tools 2010-11-27 15:02:49.000000000 +0100
-@@ -34,14 +34,14 @@ make
- # Create mysql_version.h which was deleted my previous step
- ./config.status include/mysql_version.h
-
--(cd dbug; make libdbug.a)
--(cd strings; make libmystrings.a)
--(cd mysys; make libmysys.a)
--(cd storage/heap; make libheap.a)
--(cd vio; make libvio.a)
--(cd regex; make libregex.a)
--(cd storage/myisam; make libmyisam.a)
--(cd storage/myisammrg; make libmyisammrg.a)
-+(cd dbug; make libdbug.la)
-+(cd strings; make libmystrings.la)
-+(cd mysys; make libmysys.la)
-+(cd storage/heap; make libheap.la)
-+(cd vio; make libvio.la)
-+(cd regex; make libregex.la)
-+(cd storage/myisam; make libmyisam.la)
-+(cd storage/myisammrg; make libmyisammrg.la)
- (cd extra; make comp_err)
- (cd libmysql; make conf_to_src)
- (cd libmysql_r; make conf_to_src)
-Index: netware/Makefile.am
-===================================================================
---- netware/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ netware/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,8 +16,8 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
-Index: regex/Makefile.am
-===================================================================
---- regex/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ regex/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-Index: server-tools/instance-manager/Makefile.am
-===================================================================
---- server-tools/instance-manager/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ server-tools/instance-manager/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -87,10 +87,10 @@ mysqlmanager_SOURCES= command.cc command
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-Index: sql/Makefile.am
-===================================================================
---- sql/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ sql/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,13 +32,13 @@ bin_PROGRAMS = mysql_tzinfo_to_sql
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
--LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@ $(openssl_libs) $(yassl_libs)
- mysqld_LDADD = libndb.la \
- @MYSQLD_EXTRA_LDFLAGS@ \
- @pstack_libs@ \
-Index: storage/archive/Makefile.am
-===================================================================
---- storage/archive/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/archive/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -33,7 +33,7 @@ DEFS = @DEFS@
- noinst_HEADERS = ha_archive.h azlib.h
- noinst_PROGRAMS = archive_test archive_reader
-
--EXTRA_LTLIBRARIES = ha_archive.la
-+EXTRA_LTLIBRARIES = libarchive.la ha_archive.la
- pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
- ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -41,26 +41,25 @@ ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMY
- ha_archive_la_SOURCES = ha_archive.cc azio.c
-
-
--EXTRA_LIBRARIES = libarchive.a
--noinst_LIBRARIES = @plugin_archive_static_target@
--libarchive_a_CXXFLAGS = $(AM_CXXFLAGS)
--libarchive_a_CFLAGS = $(AM_CFLAGS)
--libarchive_a_SOURCES = ha_archive.cc azio.c
-+noinst_LTLIBRARIES = @plugin_archive_static_target@
-+libarchive_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_SOURCES = ha_archive.cc azio.c
-
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-Index: storage/archive/plug.in
-===================================================================
---- storage/archive/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/archive/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,4 +1,4 @@
- MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
- [Archive Storage Engine], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
-+MYSQL_PLUGIN_STATIC(archive, [libarchive.la])
- MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
-Index: storage/blackhole/Makefile.am
-===================================================================
---- storage/blackhole/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/blackhole/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_blackhole.h
-
--EXTRA_LTLIBRARIES = ha_blackhole.la
-+EXTRA_LTLIBRARIES = libblackhole.la ha_blackhole.la
- pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
- ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
- ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@ ha_blackhole_la_CFLAGS= $(AM_CFLAGS) -DM
- ha_blackhole_la_SOURCES=ha_blackhole.cc
-
-
--EXTRA_LIBRARIES = libblackhole.a
--noinst_LIBRARIES = @plugin_blackhole_static_target@
--libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS)
--libblackhole_a_CFLAGS = $(AM_CFLAGS)
--libblackhole_a_SOURCES= ha_blackhole.cc
-+noinst_LTLIBRARIES = @plugin_blackhole_static_target@
-+libblackhole_la_CXXFLAGS=$(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_SOURCES= ha_blackhole.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/blackhole/plug.in
-===================================================================
---- storage/blackhole/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/blackhole/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,6 +1,6 @@
- MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
- [Basic Write-only Read-never tables], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
--MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
-+MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.la])
- MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
-
-Index: storage/csv/Makefile.am
-===================================================================
---- storage/csv/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/csv/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -29,16 +29,15 @@ LDADD =
- DEFS = @DEFS@
- noinst_HEADERS = ha_tina.h transparent_file.h
-
--EXTRA_LTLIBRARIES = ha_csv.la
-+EXTRA_LTLIBRARIES = libcsv.la ha_csv.la
- pkglib_LTLIBRARIES = @plugin_csv_shared_target@
- ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
- ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN
- ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc
-
--EXTRA_LIBRARIES = libcsv.a
--noinst_LIBRARIES = @plugin_csv_static_target@
--libcsv_a_CXXFLAGS = $(AM_CXXFLAGS)
--libcsv_a_SOURCES = transparent_file.cc ha_tina.cc
-+noinst_LTLIBRARIES = @plugin_csv_static_target@
-+libcsv_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libcsv_la_SOURCES = transparent_file.cc ha_tina.cc
-
- EXTRA_DIST = CMakeLists.txt plug.in
- # Don't update the files from bitkeeper
-Index: storage/csv/plug.in
-===================================================================
---- storage/csv/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/csv/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
- [Stores tables in text CSV format])
- MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
--MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
-+MYSQL_PLUGIN_STATIC(csv, [libcsv.la])
- MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
-Index: storage/example/Makefile.am
-===================================================================
---- storage/example/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/example/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_example.h
-
--EXTRA_LTLIBRARIES = ha_example.la
-+EXTRA_LTLIBRARIES = libexample.la ha_example.la
- pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
- ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@ ha_example_la_CFLAGS = $(AM_CFLAGS) -DMY
- ha_example_la_SOURCES = ha_example.cc
-
-
--EXTRA_LIBRARIES = libexample.a
--noinst_LIBRARIES = @plugin_example_static_target@
--libexample_a_CXXFLAGS = $(AM_CXXFLAGS)
--libexample_a_CFLAGS = $(AM_CFLAGS)
--libexample_a_SOURCES= ha_example.cc
-+noinst_LTLIBRARIES = @plugin_example_static_target@
-+libexample_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_SOURCES= ha_example.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/federated/Makefile.am
-===================================================================
---- storage/federated/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/federated/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -32,7 +32,7 @@ DEFS = @DEFS@
-
- noinst_HEADERS = ha_federated.h
-
--EXTRA_LTLIBRARIES = ha_federated.la
-+EXTRA_LTLIBRARIES = libfederated.la libfederated_embedded.la ha_federated.la
- pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
- ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,14 @@ ha_federated_la_CFLAGS = $(AM_CFLAGS) -D
- ha_federated_la_SOURCES = ha_federated.cc $(top_srcdir)/mysys/string.c
-
-
--EXTRA_LIBRARIES = libfederated.a
--noinst_LIBRARIES = @plugin_federated_static_target@
--libfederated_a_CXXFLAGS = $(AM_CXXFLAGS)
--libfederated_a_CFLAGS = $(AM_CFLAGS)
--libfederated_a_SOURCES= ha_federated.cc $(top_srcdir)/mysys/string.c
-+noinst_LTLIBRARIES = @plugin_federated_static_target@ @plugin_federated_embedded_static_target@
-+libfederated_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_SOURCES= ha_federated.cc $(top_srcdir)/mysys/string.c
-+
-+libfederated_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_SOURCES= ha_federated.cc $(top_srcdir)/mysys/string.c
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/federated/plug.in
-===================================================================
---- storage/federated/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/federated/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
- [Connects to tables on remote MySQL servers], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(federated, [libfederated.a])
-+MYSQL_PLUGIN_STATIC(federated, [libfederated.la], [libfederated_embedded.la])
- MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federated.cc])
-Index: storage/heap/Makefile.am
-===================================================================
---- storage/heap/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/heap/Makefile.am 2010-11-27 19:44:23.000000000 +0100
-@@ -26,27 +26,40 @@ WRAPLIBS=
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
-+noinst_LTLIBRARIES = libheap.la libheap_s.la libheap_common.la \
-+ @plugin_heap_embedded_static_target@
-+EXTRA_LTLIBRARIES = libheap_embedded.la
-+
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_common_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
- hp_rkey.c hp_block.c \
-- ha_heap.cc \
- hp_hash.c _check.c _rectest.c hp_static.c
-+libheap_common_la_CFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+
-+libheap_s_la_SOURCES = ha_heap.cc
-+libheap_s_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_LIBADD = libheap_common.la
-+libheap_embedded_la_SOURCES = ha_heap.cc
-+libheap_embedded_la_LIBADD = libheap_common.la
-+libheap_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+libheap_la_SOURCES =
-+libheap_la_LIBADD = libheap_s.la
-+libheap_la_LDFLAGS = -static
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/heap/plug.in
-===================================================================
---- storage/heap/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/heap/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,6 @@
- MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
- [Volatile memory based tables])
- MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
--MYSQL_PLUGIN_STATIC(heap, [libheap.a])
-+MYSQL_PLUGIN_STATIC(heap, [libheap_s.la], [libheap_embedded.la])
- MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(heap, [ha_heap.cc])
-
-Index: storage/innobase/Makefile.am
-===================================================================
---- storage/innobase/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innobase/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -15,21 +15,20 @@
-
- # Process this file with automake to create Makefile.in
-
--MYSQLDATAdir= $(localstatedir)
--MYSQLSHAREdir= $(pkgdatadir)
--MYSQLBASEdir= $(prefix)
--MYSQLLIBdir= $(pkglibdir)
--pkgplugindir= $(pkglibdir)/plugin
--INCLUDES= -I$(top_srcdir)/include -I$(top_builddir)/include \
-+MYSQLDATAdir = $(localstatedir)
-+MYSQLSHAREdir = $(pkgdatadir)
-+MYSQLBASEdir = $(prefix)
-+MYSQLLIBdir = $(pkglibdir)
-+pkgplugindir = $(pkglibdir)/plugin
-+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
- -I$(top_srcdir)/regex \
- -I$(top_srcdir)/storage/innobase/include \
- -I$(top_srcdir)/sql \
- -I$(srcdir)
-
--DEFS= @DEFS@
-+DEFS= @DEFS@
-
--
--noinst_HEADERS= include/btr0btr.h include/btr0btr.ic \
-+noinst_HEADERS = include/btr0btr.h include/btr0btr.ic \
- include/btr0cur.h include/btr0cur.ic \
- include/btr0pcur.h include/btr0pcur.ic \
- include/btr0sea.h include/btr0sea.ic \
-@@ -122,9 +121,8 @@ noinst_HEADERS= include/btr0btr.h inclu
- include/ut0list.ic include/ut0wqueue.h \
- include/ha_prototypes.h handler/ha_innodb.h
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innobase_static_target@
--libinnobase_a_SOURCES= btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
-+noinst_LTLIBRARIES = @plugin_innobase_static_target@
-+libinnobase_la_SOURCES = btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c \
- btr/btr0sea.c buf/buf0buf.c buf/buf0flu.c \
- buf/buf0lru.c buf/buf0rea.c data/data0data.c \
- data/data0type.c dict/dict0boot.c \
-@@ -156,18 +154,18 @@ libinnobase_a_SOURCES= btr/btr0btr.c btr
- ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c \
- handler/ha_innodb.cc
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS = $(AM_CXXFLAGS)
-+libinnobase_la_CFLAGS = $(AM_CFLAGS)
-
--EXTRA_LTLIBRARIES= ha_innodb.la
--pkgplugin_LTLIBRARIES= @plugin_innobase_shared_target@
-+EXTRA_LTLIBRARIES = libinnobase.la ha_innodb.la
-+pkgplugin_LTLIBRARIES = @plugin_innobase_shared_target@
-
--ha_innodb_la_LDFLAGS= -module -rpath $(pkgplugindir)
--ha_innodb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_la_LDFLAGS = -module -rpath $(pkgplugindir)
-+ha_innodb_la_CXXFLAGS = $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
-+ha_innodb_la_CFLAGS = $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
-+ha_innodb_la_SOURCES = $(libinnobase_la_SOURCES)
-
--EXTRA_DIST= CMakeLists.txt plug.in \
-+EXTRA_DIST = CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
- pars/pars0grm.y pars/pars0lex.l
-
-Index: storage/innobase/plug.in
-===================================================================
---- storage/innobase/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innobase/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,7 @@
- MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
- [Transactional Tables using InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
--MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
-+MYSQL_PLUGIN_STATIC(innobase, [libinnobase.la])
- MYSQL_PLUGIN_DYNAMIC(innobase, [ha_innodb.la])
- MYSQL_PLUGIN_ACTIONS(innobase, [
- AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
-Index: storage/innodb_plugin/Makefile.am
-===================================================================
---- storage/innodb_plugin/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/innodb_plugin/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -228,9 +228,8 @@ noinst_HEADERS= \
- include/ut0wqueue.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innodb_plugin_static_target@
--libinnobase_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_innodb_plugin_static_target@
-+libinnobase_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -325,16 +324,16 @@ libinnobase_a_SOURCES= \
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libinnobase_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_innodb_plugin.la
-+EXTRA_LTLIBRARIES= libinnobase.la ha_innodb_plugin.la
- pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@
-
- ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir)
- ha_innodb_plugin_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_innodb_plugin_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_plugin_la_SOURCES= $(libinnobase_la_SOURCES)
-
- EXTRA_DIST= CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
-Index: storage/myisam/Makefile.am
-===================================================================
---- storage/myisam/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisam/Makefile.am 2010-11-27 19:44:01.000000000 +0100
-@@ -30,60 +30,63 @@ DEFS = @DEFS@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA = mi_test_all mi_test_all.res
-
--pkglib_LIBRARIES = libmyisam.a
-+noinst_LTLIBRARIES = libmyisam.la libmyisam_common.la libmyisam_s.la \
-+ @plugin_myisam_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisam_embedded.la
-+
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
-+myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+libmyisam_common_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-@@ -98,8 +101,23 @@ libmyisam_a_SOURCES = mi_open.c mi_extra
- mi_keycache.c mi_preload.c \
- ft_parser.c ft_stopwords.c ft_static.c \
- ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c \
-- ha_myisam.cc \
- rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
-+libmyisam_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_SOURCES = ha_myisam.cc
-+libmyisam_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_SOURCES = ha_myisam.cc
-+libmyisam_embedded_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+# libmyisam references symbols inside mysqld.
-+# This means we cannot use it as shared library, as these references causes
-+# undefined symbol errors at load time.
-+# But a static library works (as long as those parts that references
-+# problematic symbols are not linked).
-+libmyisam_la_LDFLAGS = -static
-+libmyisam_la_SOURCES =
-+libmyisam_la_LIBADD = libmyisam_s.la
-+
- CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-
- # Move to automake rules ?
-Index: storage/myisam/plug.in
-===================================================================
---- storage/myisam/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisam/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,7 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- [Traditional non-transactional MySQL tables])
- MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
--
-Index: storage/myisammrg/Makefile.am
-===================================================================
---- storage/myisammrg/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisammrg/Makefile.am 2010-11-27 19:43:39.000000000 +0100
-@@ -26,16 +26,28 @@ WRAPLIBS=
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libmyisammrg.a
-+noinst_LTLIBRARIES = libmyisammrg.la libmyisammrg_s.la libmyisammrg_common.la \
-+ @plugin_myisammrg_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisammrg_embedded.la
- noinst_HEADERS = myrg_def.h ha_myisammrg.h
--noinst_LIBRARIES = libmyisammrg.a
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_common_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
- myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
-- ha_myisammrg.cc \
- myrg_rnext_same.c myrg_records.c
-+libmyisammrg_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libmyisammrg_embedded_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libmyisammrg_la_SOURCES =
-+libmyisammrg_la_LIBADD = libmyisammrg_s.la
-+libmyisammrg_la_LDFLAGS = -static
-+
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-Index: storage/myisammrg/plug.in
-===================================================================
---- storage/myisammrg/plug.in.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/myisammrg/plug.in 2010-11-27 15:02:49.000000000 +0100
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
- [Merge multiple MySQL tables into one])
- MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
--MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
-+MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg_s.la], [libmyisammrg_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisammrg)
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc])
-Index: storage/ndb/src/common/util/Makefile.am
-===================================================================
---- storage/ndb/src/common/util/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/common/util/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -31,9 +31,9 @@ EXTRA_PROGRAMS = testBitmask
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-Index: storage/ndb/config/type_ndbapitest.mk.am
-===================================================================
---- storage/ndb/config/type_ndbapitest.mk.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/type_ndbapitest.mk.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,19 +13,20 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--LDADD += $(top_builddir)/storage/ndb/test/src/libNDBT.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+LDADD += $(top_builddir)/storage/ndb/test/src/libNDBT.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
--INCLUDES += -I$(top_srcdir) \
-- -I$(top_builddir)/include \
-- -I$(top_builddir)/storage/ndb/include \
-- -I$(top_srcdir)/include \
-- -I$(top_srcdir)/storage/ndb/include \
-- -I$(top_srcdir)/storage/ndb/include/ndbapi \
-- -I$(top_srcdir)/storage/ndb/include/util \
-- -I$(top_srcdir)/storage/ndb/include/portlib \
-- -I$(top_srcdir)/storage/ndb/test/include \
-- -I$(top_srcdir)/storage/ndb/include/mgmapi
-+INCLUDES += -I$(top_srcdir) \
-+ -I$(top_builddir)/include \
-+ -I$(top_builddir)/storage/ndb/include \
-+ -I$(top_srcdir)/include \
-+ -I$(top_srcdir)/storage/ndb/include \
-+ -I$(top_srcdir)/storage/ndb/include/ndbapi \
-+ -I$(top_srcdir)/storage/ndb/include/util \
-+ -I$(top_srcdir)/storage/ndb/include/portlib \
-+ -I$(top_srcdir)/storage/ndb/test/include \
-+ -I$(top_srcdir)/storage/ndb/include/mgmapi
-Index: storage/ndb/config/type_ndbapitools.mk.am
-===================================================================
---- storage/ndb/config/type_ndbapitools.mk.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/type_ndbapitools.mk.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,20 +13,21 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--LDADD += \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ @ZLIB_LIBS@
-+LDADD += \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
--INCLUDES += -I$(srcdir) \
-- -I$(top_builddir)/include \
-- -I$(top_builddir)/storage/ndb/include \
-- -I$(top_srcdir)/include \
-- -I$(top_srcdir)/storage/ndb/include \
-- -I$(top_srcdir)/storage/ndb/include/ndbapi \
-- -I$(top_srcdir)/storage/ndb/include/util \
-- -I$(top_srcdir)/storage/ndb/include/portlib \
-- -I$(top_srcdir)/storage/ndb/test/include \
-- -I$(top_srcdir)/storage/ndb/include/mgmapi \
-- -I$(top_srcdir)/storage/ndb/include/kernel
-+INCLUDES += -I$(srcdir) \
-+ -I$(top_builddir)/include \
-+ -I$(top_builddir)/storage/ndb/include \
-+ -I$(top_srcdir)/include \
-+ -I$(top_srcdir)/storage/ndb/include \
-+ -I$(top_srcdir)/storage/ndb/include/ndbapi \
-+ -I$(top_srcdir)/storage/ndb/include/util \
-+ -I$(top_srcdir)/storage/ndb/include/portlib \
-+ -I$(top_srcdir)/storage/ndb/test/include \
-+ -I$(top_srcdir)/storage/ndb/include/mgmapi \
-+ -I$(top_srcdir)/storage/ndb/include/kernel
-Index: storage/ndb/config/win-libraries
-===================================================================
---- storage/ndb/config/win-libraries.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/config/win-libraries 2010-11-27 15:02:49.000000000 +0100
-@@ -21,7 +21,7 @@ do
- # the same goes for mysys and strings
- lib=$i
- case $i in
-- *libdbug.a | *libmysys.a | *libmystrings.a)
-+ *libdbug.la | *libmysys.la | *libmystrings.la)
- lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'`
- echo "Changing from $i to $lib"
- ;;
-Index: storage/ndb/src/cw/cpcd/Makefile.am
-===================================================================
---- storage/ndb/src/cw/cpcd/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/cw/cpcd/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -19,9 +19,9 @@ ndb_cpcd_SOURCES = main.cpp CPCD.cpp Pro
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-Index: storage/ndb/src/kernel/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -53,9 +53,10 @@ LDADD += \
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ $(ZLIB_LIBS)
-
- windoze-dsp: ndbd.dsp
-
-Index: storage/ndb/src/kernel/blocks/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -18,7 +18,7 @@ SUBDIRS = \
- dbdih \
- dblqh \
- dbtup \
-- backup
-+ backup
-
- noinst_LIBRARIES = libblocks.a
-
-@@ -56,10 +56,10 @@ libblocks_a_SOURCES = tsman.cpp lgman.cp
- EXTRA_PROGRAMS = ndb_print_file
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-Index: storage/ndb/src/kernel/blocks/backup/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/backup/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -17,9 +17,9 @@ ndbtools_PROGRAMS = ndb_print_backup_fil
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-Index: storage/ndb/src/kernel/blocks/dbdict/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbdict/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -19,17 +19,17 @@ include $(top_srcdir)/storage/ndb/config
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/blocks/dbdih/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbdih/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -17,9 +17,9 @@ ndbtools_PROGRAMS = ndb_print_sys_file
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-Index: storage/ndb/src/kernel/blocks/dblqh/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dblqh/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -23,9 +23,9 @@ include $(top_srcdir)/storage/ndb/config
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/blocks/dbtup/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/blocks/dbtup/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -20,9 +20,9 @@ EXTRA_PROGRAMS = test_varpage
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: storage/ndb/src/kernel/vm/Makefile.am
-===================================================================
---- storage/ndb/src/kernel/vm/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/kernel/vm/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -21,22 +21,22 @@
- noinst_LIBRARIES = libkernel.a
-
- libkernel_a_SOURCES = \
-- SimulatedBlock.cpp \
-- FastScheduler.cpp \
-- TimeQueue.cpp \
-- VMSignal.cpp \
-- ThreadConfig.cpp \
-- TransporterCallback.cpp \
-- Emulator.cpp \
-- Configuration.cpp \
-- WatchDog.cpp \
-- SimplePropertiesSection.cpp \
-- SectionReader.cpp \
-- Mutex.cpp SafeCounter.cpp \
-- Rope.cpp \
-- ndbd_malloc.cpp ndbd_malloc_impl.cpp \
-- Pool.cpp WOPool.cpp RWPool.cpp \
-- DynArr256.cpp
-+ SimulatedBlock.cpp \
-+ FastScheduler.cpp \
-+ TimeQueue.cpp \
-+ VMSignal.cpp \
-+ ThreadConfig.cpp \
-+ TransporterCallback.cpp \
-+ Emulator.cpp \
-+ Configuration.cpp \
-+ WatchDog.cpp \
-+ SimplePropertiesSection.cpp \
-+ SectionReader.cpp \
-+ Mutex.cpp SafeCounter.cpp \
-+ Rope.cpp \
-+ ndbd_malloc.cpp ndbd_malloc_impl.cpp \
-+ Pool.cpp WOPool.cpp RWPool.cpp \
-+ DynArr256.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
-
-@@ -49,40 +49,40 @@ include $(top_srcdir)/storage/ndb/config
- windoze-dsp: libkernel.dsp
-
- libkernel.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libkernel_a_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libkernel_a_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-
- EXTRA_PROGRAMS = ndbd_malloc_impl_test bench_pool testDynArr256
- ndbd_malloc_impl_test_CXXFLAGS = -DUNIT_TEST
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
--bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
-- libkernel.a ../error/liberror.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+bench_pool_LDFLAGS = @ndb_bin_am_ldflags@ \
-+ libkernel.a ../error/liberror.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
-- libkernel.a ../error/liberror.a \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ libkernel.a ../error/liberror.a \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-Index: storage/ndb/src/mgmclient/Makefile.am
-===================================================================
---- storage/ndb/src/mgmclient/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/mgmclient/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -18,12 +18,11 @@ ndbtools_PROGRAMS = ndb_mgm
-
- libndbmgmclient_la_SOURCES = CommandInterpreter.cpp
- libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \
-- ../common/logger/liblogger.la \
-- ../common/portlib/libportlib.la \
-- ../common/util/libgeneral.la \
-- ../common/portlib/libportlib.la \
-- ../common/debugger/libtrace.la
--
-+ ../common/logger/liblogger.la \
-+ ../common/portlib/libportlib.la \
-+ ../common/util/libgeneral.la \
-+ ../common/portlib/libportlib.la \
-+ ../common/debugger/libtrace.la
-
- ndb_mgm_SOURCES = main.cpp
-
-@@ -34,13 +33,13 @@ INCLUDES += -I$(top_srcdir)/storage/ndb/
- -I$(top_srcdir)/storage/ndb/src/common/mgmcommon
-
- LDADD_LOC = $(noinst_LTLIBRARIES) \
-- ../common/portlib/libportlib.la \
-- @readline_link@ \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-+ ../common/portlib/libportlib.la \
-+ @readline_link@ \
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-
-@@ -50,25 +49,25 @@ ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
- windoze-dsp: ndb_mgm.dsp libndbmgmclient.dsp
-
- ndb_mgm.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-prg.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbtools_PROGRAMS)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgm_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-prg.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbtools_PROGRAMS)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgm_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-
- libndbmgmclient.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB
-Index: storage/ndb/src/mgmsrv/Makefile.am
-===================================================================
---- storage/ndb/src/mgmsrv/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/mgmsrv/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -22,35 +22,35 @@ MYSQLCLUSTERdir= .
- ndbbin_PROGRAMS = ndb_mgmd
-
- ndb_mgmd_SOURCES = \
-- MgmtSrvr.cpp \
-- MgmtSrvrGeneralSignalHandling.cpp \
-- main.cpp \
-- Services.cpp \
-- convertStrToInt.cpp \
-- SignalQueue.cpp \
-- MgmtSrvrConfig.cpp \
-- ConfigInfo.cpp \
-- InitConfigFileParser.cpp \
-- Config.cpp
-+ MgmtSrvr.cpp \
-+ MgmtSrvrGeneralSignalHandling.cpp \
-+ main.cpp \
-+ Services.cpp \
-+ convertStrToInt.cpp \
-+ SignalQueue.cpp \
-+ MgmtSrvrConfig.cpp \
-+ ConfigInfo.cpp \
-+ InitConfigFileParser.cpp \
-+ Config.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/ndbapi \
-- -I$(top_srcdir)/storage/ndb/src/mgmapi \
-- -I$(top_srcdir)/storage/ndb/src/common/mgmcommon \
-- -I$(top_srcdir)/storage/ndb/src/mgmclient
-+ -I$(top_srcdir)/storage/ndb/src/mgmapi \
-+ -I$(top_srcdir)/storage/ndb/src/common/mgmcommon \
-+ -I$(top_srcdir)/storage/ndb/src/mgmclient
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
-- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- @readline_link@ \
-- @NDB_SCI_LIBS@ \
-- @TERMCAP_LIB@
--
--DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
-- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-- -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\""
-+ $(top_builddir)/storage/ndb/src/libndbclient.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ @readline_link@ \
-+ @NDB_SCI_LIBS@ \
-+ @TERMCAP_LIB@
-+
-+DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-+ -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
-+ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-+ -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\""
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-@@ -63,13 +63,13 @@ ndb_mgmd_LDFLAGS = @ndb_bin_am_ldflags@
- windoze-dsp: ndb_mgmd.dsp
-
- ndb_mgmd.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-prg.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbbin_PROGRAMS)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgmd_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-prg.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-prg.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(ndbbin_PROGRAMS)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(ndb_mgmd_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LINK $(LDADD)
-Index: storage/ndb/src/ndbapi/Makefile.am
-===================================================================
---- storage/ndb/src/ndbapi/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/src/ndbapi/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -22,41 +22,42 @@ ndberror_check_SOURCES = ndberror_check.
- noinst_LTLIBRARIES = libndbapi.la
-
- libndbapi_la_SOURCES = \
-- TransporterFacade.cpp \
-- ClusterMgr.cpp \
-- Ndb.cpp \
-- NdbPoolImpl.cpp \
-- NdbPool.cpp \
-- Ndblist.cpp \
-- Ndbif.cpp \
-- Ndbinit.cpp \
-- Ndberr.cpp \
-- ndberror.c \
-- NdbErrorOut.cpp \
-- NdbTransaction.cpp \
-- NdbTransactionScan.cpp \
-- NdbOperation.cpp \
-- NdbOperationSearch.cpp \
-- NdbOperationScan.cpp \
-- NdbOperationInt.cpp \
-- NdbOperationDefine.cpp \
-- NdbOperationExec.cpp \
-- NdbScanOperation.cpp NdbScanFilter.cpp \
-- NdbIndexOperation.cpp \
-- NdbEventOperation.cpp \
-- NdbEventOperationImpl.cpp \
-- NdbApiSignal.cpp \
-- NdbRecAttr.cpp \
-- NdbUtil.cpp \
-- NdbReceiver.cpp \
-- NdbDictionary.cpp \
-- NdbDictionaryImpl.cpp \
-- DictCache.cpp \
-- ndb_cluster_connection.cpp \
-- NdbBlob.cpp \
-- NdbIndexStat.cpp \
-- SignalSender.cpp \
-- ObjectMap.cpp
-+ TransporterFacade.cpp \
-+ ClusterMgr.cpp \
-+ Ndb.cpp \
-+ NdbPoolImpl.cpp \
-+ NdbPool.cpp \
-+ Ndblist.cpp \
-+ Ndbif.cpp \
-+ Ndbinit.cpp \
-+ Ndberr.cpp \
-+ ndberror.c \
-+ NdbErrorOut.cpp \
-+ NdbTransaction.cpp \
-+ NdbTransactionScan.cpp \
-+ NdbOperation.cpp \
-+ NdbOperationSearch.cpp \
-+ NdbOperationScan.cpp \
-+ NdbOperationInt.cpp \
-+ NdbOperationDefine.cpp \
-+ NdbOperationExec.cpp \
-+ NdbScanOperation.cpp \
-+ NdbScanFilter.cpp \
-+ NdbIndexOperation.cpp \
-+ NdbEventOperation.cpp \
-+ NdbEventOperationImpl.cpp \
-+ NdbApiSignal.cpp \
-+ NdbRecAttr.cpp \
-+ NdbUtil.cpp \
-+ NdbReceiver.cpp \
-+ NdbDictionary.cpp \
-+ NdbDictionaryImpl.cpp \
-+ DictCache.cpp \
-+ ndb_cluster_connection.cpp \
-+ NdbBlob.cpp \
-+ NdbIndexStat.cpp \
-+ SignalSender.cpp \
-+ ObjectMap.cpp
-
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
-
-@@ -67,9 +68,10 @@ include $(top_srcdir)/storage/ndb/config
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
- ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-@@ -77,13 +79,13 @@ ndberror_check_LDFLAGS = \
- windoze-dsp: libndbapi.dsp
-
- libndbapi.dsp: Makefile \
-- $(top_srcdir)/storage/ndb/config/win-lib.am \
-- $(top_srcdir)/storage/ndb/config/win-name \
-- $(top_srcdir)/storage/ndb/config/win-includes \
-- $(top_srcdir)/storage/ndb/config/win-sources \
-- $(top_srcdir)/storage/ndb/config/win-libraries
-- cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-- @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-- @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-- @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbapi_la_SOURCES)
-- @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-+ $(top_srcdir)/storage/ndb/config/win-lib.am \
-+ $(top_srcdir)/storage/ndb/config/win-name \
-+ $(top_srcdir)/storage/ndb/config/win-includes \
-+ $(top_srcdir)/storage/ndb/config/win-sources \
-+ $(top_srcdir)/storage/ndb/config/win-libraries
-+ cat $(top_srcdir)/storage/ndb/config/win-lib.am > $@
-+ @$(top_srcdir)/storage/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
-+ @$(top_srcdir)/storage/ndb/config/win-includes $@ $(INCLUDES)
-+ @$(top_srcdir)/storage/ndb/config/win-sources $@ $(libndbapi_la_SOURCES)
-+ @$(top_srcdir)/storage/ndb/config/win-libraries $@ LIB $(LDADD)
-Index: storage/ndb/test/run-test/Makefile.am
-===================================================================
---- storage/ndb/test/run-test/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ storage/ndb/test/run-test/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -34,9 +34,9 @@ atrt_SOURCES = main.cpp setup.cpp files.
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-Index: strings/Makefile.am
-===================================================================
---- strings/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ strings/Makefile.am 2010-11-27 19:42:38.000000000 +0100
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+noinst_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@ CSRCS = strxmov.c bmove_upp.c strappend
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,9 +56,9 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
- conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-@@ -69,15 +69,15 @@ conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
- test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
- # Don't update the files from bitkeeper
-Index: unittest/unit.pl
-===================================================================
---- unittest/unit.pl.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/unit.pl 2010-11-27 15:02:49.000000000 +0100
-@@ -55,7 +55,7 @@ sub _find_test_files (@) {
- my @dirs = @_;
- my @files;
- find sub {
-- $File::Find::prune = 1 if /^SCCS$/;
-+ $File::Find::prune = 1 if /^(SCCS|\.libs)$/;
- push(@files, $File::Find::name) if -x _ && /-t\z/;
- }, @dirs;
- return @files;
-Index: unittest/mysys/Makefile.am
-===================================================================
---- unittest/mysys/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/mysys/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -13,15 +13,16 @@
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
--AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
--AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-+AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
-+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
--LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
--noinst_PROGRAMS = bitmap-t base64-t
-+noinst_PROGRAMS = bitmap-t base64-t
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-Index: unittest/strings/Makefile.am
-===================================================================
---- unittest/strings/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ unittest/strings/Makefile.am 2010-11-27 15:02:49.000000000 +0100
-@@ -16,10 +16,11 @@
- AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
--LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- noinst_PROGRAMS = strings-t
-
-Index: vio/Makefile.am
-===================================================================
---- vio/Makefile.am.orig 2010-11-27 15:02:45.000000000 +0100
-+++ vio/Makefile.am 2010-11-27 19:43:02.000000000 +0100
-@@ -16,11 +16,11 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+noinst_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/02040_all_embedded-library-shared-maria-5.1.50.patch b/02040_all_embedded-library-shared-maria-5.1.50.patch
deleted file mode 100644
index 9980ef2..0000000
--- a/02040_all_embedded-library-shared-maria-5.1.50.patch
+++ /dev/null
@@ -1,2007 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-Thanks to Maciej Mrozowski <reavertm@gentoo.org> for working in the redo of the
-patch for mysql-5.1.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
-
-=== modified file 'client/Makefile.am'
---- client/Makefile.am 2010-08-27 14:12:44 +0000
-+++ client/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -75,7 +75,8 @@
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +85,17 @@
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-
-=== modified file 'config/ac-macros/plugins.m4'
---- config/ac-macros/plugins.m4 2009-12-22 10:33:20 +0000
-+++ config/ac-macros/plugins.m4 2010-09-16 12:49:35 +0000
-@@ -115,18 +115,32 @@
- dnl Macro: MYSQL_PLUGIN_STATIC
- dnl
- dnl SYNOPSIS
--dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
-+dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a],[libmyplugin_embedded.a])
- dnl
- dnl DESCRIPTION
--dnl Declare the name for the static library
-+dnl Declare the name for the static library
-+dnl
-+dnl Third argument is optional, only needed for special plugins that depend
-+dnl on server internals and have source files that must be compiled specially
-+dnl with -DEMBEDDED_LIBRARY for embedded server. If specified, the third
-+dnl argument is used to link embedded server instead of the second.
- dnl
- dnl ---------------------------------------------------------------------------
-
- AC_DEFUN([MYSQL_PLUGIN_STATIC],[
- MYSQL_REQUIRE_PLUGIN([$1])
- m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
-+ ifelse($#, 3, [
-+ m4_define([MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]), [$3])
-+ ])
- ])
-
-+dnl ---------------------------------------------------------------------------
-+dnl Substitution variable to use to compile source files specially for
-+dnl embedded server.
-+dnl To be used by plugins that have sources that depend on server internals.
-+dnl ---------------------------------------------------------------------------
-+AC_SUBST([plugin_embedded_defs], ["-DEMBEDDED_LIBRARY -DMYSQL_SERVER"])
-
- dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_PLUGIN_DYNAMIC
-@@ -254,28 +268,6 @@
- ])
-
- dnl ---------------------------------------------------------------------------
--dnl Macro: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS
--dnl
--dnl SYNOPSIS
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS([name],[file name])
--dnl
--dnl DESCRIPTION
--dnl Some modules in plugins keep dependance on structures
--dnl declared in sql/ (THD class usually)
--dnl That has to be fixed in the future, but until then
--dnl we have to recompile these modules when we want to
--dnl to compile server parts with the different #defines
--dnl Normally it happens when we compile the embedded server
--dnl Thus one should mark such files in his handler using this macro
--dnl
--dnl ---------------------------------------------------------------------------
--
--AC_DEFUN([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS],[
-- MYSQL_REQUIRE_PLUGIN([$1])
-- m4_define([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]), [$2])
--])
--
--dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_CONFIGURE_PLUGINS
- dnl
- dnl SYNOPSIS
-@@ -335,11 +327,25 @@
- [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
-- [MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]),
-+ [MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
- )
- ])
-
-+# __MYSQL_EMIT_CHECK_PLUGIN arguments:
-+#
-+# 1 - plugin identifying name
-+# 2 - plugin identifying name, with `-' replaced by `_'
-+# 3 - plugin long name
-+# 4 - plugin description
-+# 5 - mysql_plugin_define (eg. WITH_xxx_STORAGE_ENGINE)
-+# 6 - directory
-+# 7 - static target (if supports static build)
-+# 8 - dynamic target (if supports dynamic build)
-+# 9 - mandatory flag
-+# 10 - disabled flag
-+# 11 - static target for libmysqld (if different from mysqld)
-+# 12 - actions
- AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- m4_ifdef([$5],[
- AH_TEMPLATE($5, [Include ]$4[ into mysqld])
-@@ -406,6 +412,7 @@
- ])
- AC_SUBST([plugin_]$2[_shared_target], "$8")
- AC_SUBST([plugin_]$2[_static_target], [""])
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
- [with_plugin_]$2=yes
- AC_MSG_RESULT([plugin])
- m4_ifdef([$6],[
-@@ -420,32 +427,47 @@
- ])
- else
- m4_ifdef([$7],[
-- ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
--dnl change above "-2" to "0" to enable this section
--dnl Although this is "pretty", it breaks libmysqld build
-- m4_ifdef([$6],[
-- mysql_use_plugin_dir="$6"
-- mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
-- ])
-- mysql_plugin_libs="$mysql_plugin_libs dnl
--[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
-- ], m4_bregexp($7, [^\\\$]), 0, [
-+ ifelse(m4_bregexp($7, [^\\\$]), 0, [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- ])
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ], [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$7"
-+ ])
- ],[
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ])
- ])
- m4_ifdef([$5],[
- AC_DEFINE($5)
- ])
- AC_SUBST([plugin_]$2[_static_target], "$7")
-+ m4_ifdef([$11], [
-+ if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_]$2[_embedded_static_target], "$11")
-+ else
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ fi
-+ ], [
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ ])
- AC_SUBST([plugin_]$2[_shared_target], [""])
- ],[
- m4_ifdef([$6],[
-@@ -462,14 +484,6 @@
- mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
- [with_plugin_]$2=yes
- AC_MSG_RESULT([yes])
-- m4_ifdef([$11], [
-- m4_foreach([plugin], [$11], [
-- condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp(plugin, [[^/]+$], [\&])"
-- condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp(plugin, [[^/]+\.], [\&o])"
-- condition_dependent_plugin_links="$condition_dependent_plugin_links $6/plugin"
-- condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp(plugin, [^.+[/$]], [\&])"
-- ])
-- ])
- fi
- fi
-
-@@ -517,6 +531,14 @@
- ])
- ])
-
-+dnl If not building libmysqld embedded server, then there is no need to build
-+dnl shared object versions of static plugins.
-+if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_static_if_no_embedded], "")
-+else
-+ AC_SUBST([plugin_static_if_no_embedded], "-static")
-+fi
-+
- AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
- ifelse($#, 0, [], $#, 1, [
- _MYSQL_EMIT_PLUGIN_ACTION([$1])
-
-=== modified file 'configure.in'
---- configure.in 2010-08-27 14:12:44 +0000
-+++ configure.in 2010-09-16 12:49:35 +0000
-@@ -2521,17 +2521,14 @@
- MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- [Traditional non-transactional MySQL tables])
- MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
-
- MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
- [MySQL Partitioning Support], [max,max-no-ndb])
-
- dnl -- ndbcluster requires partition to be enabled
-
--MYSQL_CONFIGURE_PLUGINS([default])
--
- # Only build client code?
- AC_ARG_WITH(server,
- [ --without-server Only build the client.],
-@@ -2545,6 +2542,8 @@
- [with_embedded_server=no]
- )
-
-+MYSQL_CONFIGURE_PLUGINS([default])
-+
- AC_ARG_WITH(query_cache,
- [ --without-query-cache Do not build query cache.],
- [with_query_cache=$withval],
-@@ -2846,9 +2845,6 @@
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o mf_keycaches.o waiting_threads.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
- AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
-
-@@ -2877,6 +2873,7 @@
-
- AC_SUBST(mysql_plugin_dirs)
- AC_SUBST(mysql_plugin_libs)
-+AC_SUBST(mysql_embedded_plugin_libs)
- AC_SUBST(mysql_plugin_defs)
-
-
-
-=== modified file 'dbug/Makefile.am'
---- dbug/Makefile.am 2010-08-27 14:12:44 +0000
-+++ dbug/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = libdbug.la ../mysys/libmysys.la ../strings/libmystrings.la $(ZLIB_LIBS)
-+pkglib_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-
-=== modified file 'extra/Makefile.am'
---- extra/Makefile.am 2010-08-27 14:12:44 +0000
-+++ extra/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-
-=== modified file 'libmysqld/Makefile.am'
---- libmysqld/Makefile.am 2010-08-27 14:12:44 +0000
-+++ libmysqld/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -36,8 +36,7 @@
- $(openssl_includes) @ZLIB_INCLUDES@ \
- @condition_dependent_plugin_includes@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
- libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
-@@ -79,34 +78,29 @@
- rpl_injector.cc my_user.c partition_info.cc \
- sql_servers.cc event_parse_data.cc opt_table_elimination.cc
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
--
--sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
--storagesources = @condition_dependent_plugin_modules@
--storageobjects = @condition_dependent_plugin_objects@
--storagesourceslinks = @condition_dependent_plugin_links@
--
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
- # The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-+INC_LIB= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
- @NDB_SCI_LIBS@ \
-- @mysql_plugin_libs@ \
-+ @mysql_embedded_plugin_libs@ \
- $(libevent_inc_libs) \
- $(yassl_inc_libs)
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
- endif
-
-+libmysqld_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_LIBADD = $(INC_LIB)
-+
- # Storage engine specific compilation options
- ha_ndbcluster.o:ha_ndbcluster.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-@@ -140,51 +134,13 @@
- ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
-- else \
-- current_dir=`pwd`; \
-- rm -rf tmp; mkdir tmp; \
-- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
-- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
-- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
-- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
-- mkdir $$artmp; cd $$artmp > /dev/null; \
-- $(AR) x ../../$$arc; \
-- cd $$current_dir > /dev/null; \
-- ls $$artmp/* | grep -v SYMDEF; \
-- continue 2; fi; done; \
-- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(AR) r libmysqld.a $(storageobjects); \
-- $(RANLIB) libmysqld.a ; \
-- rm -rf tmp; \
-- fi
--endif
--
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
- ## libmysqld interface to change without affecting the standard
- ## libmysqlclient interface. Should we make a separate version
- ## string for the two?
- #libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
--#CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
-+#CLEANFILES = libmysqld.la
-
- BUILT_SOURCES = link_sources
-
-@@ -209,20 +165,6 @@
- @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
- fi ; \
- done; \
-- if test -n "$(sqlstoragesources)" ; \
-- then \
-- for f in "$(sqlstoragesources)"; do \
-- rm -f "$$f"; \
-- @LN_CP_F@ `find $(srcdir)/../sql -name "$$f"` "$$f"; \
-- done; \
-- fi; \
-- if test -n "$(storagesources)" ; \
-- then \
-- rm -f $(storagesources); \
-- for f in $(storagesourceslinks); do \
-- @LN_CP_F@ $(top_srcdir)/$$f . ; \
-- done; \
-- fi; \
- rm -f client_settings.h; \
- @LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h \
- client_settings.h; \
-@@ -230,5 +172,5 @@
-
-
- clean-local:
-- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlstoragesources) $(storagesources) | sed "s;\.lo;.c;g"`; \
-+ rm -f `echo $(sqlsources) $(libmysqlsources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
-
-=== modified file 'libmysqld/examples/Makefile.am'
---- libmysqld/examples/Makefile.am 2010-07-16 07:15:22 +0000
-+++ libmysqld/examples/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -37,12 +37,16 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
-- @NDB_SCI_LIBS@
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
-+ @NDB_SCI_LIBS@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(ZLIB_LIBS)
-
- mysqltest_embedded_LINK = $(CXXLINK)
- nodist_mysqltest_embedded_SOURCES = mysqltest.cc
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la \
- @MYSQLD_EXTRA_LDFLAGS@
-
- nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
-
-=== modified file 'mysys/Makefile.am'
---- mysys/Makefile.am 2010-08-27 14:12:44 +0000
-+++ mysys/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -18,11 +18,11 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+pkglib_LTLIBRARIES = libmysys.la
-+LDADD = libmysys.la $(top_builddir)/strings/libmystrings.la $(top_builddir)/dbug/libdbug.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h \
- my_safehash.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -62,18 +62,19 @@
- # mf_keycache is used only in the server, so it is safe to leave the file
- # out of the non-threaded library.
- # In fact, it will currently not compile without thread support.
--libmysys_a_SOURCES += mf_keycache.c mf_keycaches.c
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
-+ my_pthread.c my_thr_init.c waiting_threads.c \
-+ mf_keycache.c mf_keycaches.c
- endif
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c waiting_threads.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
- -DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \
- -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-@@ -83,8 +84,6 @@
- -DDEFAULT_SYSCONFDIR="\"$(sysconfdir)\"" \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-@@ -100,50 +99,50 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-
--test_thr_mutex$(EXEEXT): test_thr_mutex.c $(LIBRARIES)
-+test_thr_mutex$(EXEEXT): test_thr_mutex.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) $(srcdir)/test_thr_mutex.c $(LDADD) $(LIBS)
-
-=== modified file 'netware/Makefile.am'
---- netware/Makefile.am 2010-08-27 14:12:44 +0000
-+++ netware/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,8 +16,8 @@
-
- if HAVE_NETWARE
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I..
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la @ZLIB_LIBS@
- bin_PROGRAMS = mysqld_safe mysql_install_db mysql_test_run libmysql
- mysqld_safe_SOURCES= mysqld_safe.c my_manage.c
- mysql_install_db_SOURCES= mysql_install_db.c my_manage.c
-=== modified file 'regex/Makefile.am'
---- regex/Makefile.am 2010-08-27 14:12:44 +0000
-+++ regex/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-
-=== modified file 'server-tools/instance-manager/Makefile.am'
---- server-tools/instance-manager/Makefile.am 2007-02-18 12:45:28 +0000
-+++ server-tools/instance-manager/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -87,10 +87,10 @@
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-
-=== modified file 'sql/Makefile.am'
---- sql/Makefile.am 2010-08-27 14:12:44 +0000
-+++ sql/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,13 +33,13 @@
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
--LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@ $(openssl_libs) $(yassl_libs)
- mysqld_LDADD = libndb.la \
- @MYSQLD_EXTRA_LDFLAGS@ \
- @pstack_libs@ $(libevent_libs) \
-
-=== modified file 'storage/archive/Makefile.am'
---- storage/archive/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/archive/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,7 +33,7 @@
- noinst_HEADERS = ha_archive.h azlib.h
- noinst_PROGRAMS = archive_test archive_reader
-
--EXTRA_LTLIBRARIES = ha_archive.la
-+EXTRA_LTLIBRARIES = libarchive.la ha_archive.la
- pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
- ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_archive_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -41,26 +41,25 @@
- ha_archive_la_SOURCES = ha_archive.cc azio.c
-
-
--EXTRA_LIBRARIES = libarchive.a
--noinst_LIBRARIES = @plugin_archive_static_target@
--libarchive_a_CXXFLAGS = $(AM_CXXFLAGS)
--libarchive_a_CFLAGS = $(AM_CFLAGS)
--libarchive_a_SOURCES = ha_archive.cc azio.c
-+noinst_LTLIBRARIES = @plugin_archive_static_target@
-+libarchive_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_SOURCES = ha_archive.cc azio.c
-
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-
-=== modified file 'storage/archive/plug.in'
---- storage/archive/plug.in 2006-05-06 11:43:18 +0000
-+++ storage/archive/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,4 +1,4 @@
- MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
- [Archive Storage Engine], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
-+MYSQL_PLUGIN_STATIC(archive, [libarchive.la])
- MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
-
-=== modified file 'storage/blackhole/Makefile.am'
---- storage/blackhole/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/blackhole/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -32,7 +32,7 @@
-
- noinst_HEADERS = ha_blackhole.h
-
--EXTRA_LTLIBRARIES = ha_blackhole.la
-+EXTRA_LTLIBRARIES = libblackhole.la ha_blackhole.la
- pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
- ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
- ha_blackhole_la_CXXFLAGS=$(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@
- ha_blackhole_la_SOURCES=ha_blackhole.cc
-
-
--EXTRA_LIBRARIES = libblackhole.a
--noinst_LIBRARIES = @plugin_blackhole_static_target@
--libblackhole_a_CXXFLAGS=$(AM_CXXFLAGS)
--libblackhole_a_CFLAGS = $(AM_CFLAGS)
--libblackhole_a_SOURCES= ha_blackhole.cc
-+noinst_LTLIBRARIES = @plugin_blackhole_static_target@
-+libblackhole_la_CXXFLAGS=$(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libblackhole_la_SOURCES= ha_blackhole.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/blackhole/plug.in'
---- storage/blackhole/plug.in 2006-08-19 04:19:19 +0000
-+++ storage/blackhole/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,6 +1,6 @@
- MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
- [Basic Write-only Read-never tables], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
--MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
-+MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.la])
- MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
-
-
-=== modified file 'storage/csv/Makefile.am'
---- storage/csv/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/csv/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -29,16 +29,15 @@
- DEFS = @DEFS@
- noinst_HEADERS = ha_tina.h transparent_file.h
-
--EXTRA_LTLIBRARIES = ha_csv.la
-+EXTRA_LTLIBRARIES = libcsv.la ha_csv.la
- pkglib_LTLIBRARIES = @plugin_csv_shared_target@
- ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
- ha_csv_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_PLUGIN
- ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc
-
--EXTRA_LIBRARIES = libcsv.a
--noinst_LIBRARIES = @plugin_csv_static_target@
--libcsv_a_CXXFLAGS = $(AM_CXXFLAGS)
--libcsv_a_SOURCES = transparent_file.cc ha_tina.cc
-+noinst_LTLIBRARIES = @plugin_csv_static_target@
-+libcsv_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libcsv_la_SOURCES = transparent_file.cc ha_tina.cc
-
- EXTRA_DIST = CMakeLists.txt plug.in
- # Don't update the files from bitkeeper
-
-=== modified file 'storage/csv/plug.in'
---- storage/csv/plug.in 2006-08-19 04:19:19 +0000
-+++ storage/csv/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
- [Stores tables in text CSV format])
- MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
--MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
-+MYSQL_PLUGIN_STATIC(csv, [libcsv.la])
- MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
-
-=== modified file 'storage/example/Makefile.am'
---- storage/example/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/example/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -32,7 +32,7 @@
-
- noinst_HEADERS = ha_example.h
-
--EXTRA_LTLIBRARIES = ha_example.la
-+EXTRA_LTLIBRARIES = libexample.la ha_example.la
- pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
- ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_example_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -40,11 +40,10 @@
- ha_example_la_SOURCES = ha_example.cc
-
-
--EXTRA_LIBRARIES = libexample.a
--noinst_LIBRARIES = @plugin_example_static_target@
--libexample_a_CXXFLAGS = $(AM_CXXFLAGS)
--libexample_a_CFLAGS = $(AM_CFLAGS)
--libexample_a_SOURCES= ha_example.cc
-+noinst_LTLIBRARIES = @plugin_example_static_target@
-+libexample_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_SOURCES= ha_example.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/federated/Makefile.am'
---- storage/federated/Makefile.am 2010-08-27 14:12:44 +0000
-+++ storage/federated/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -30,7 +30,7 @@
-
- noinst_HEADERS = ha_federated.h
-
--EXTRA_LTLIBRARIES = ha_federated.la
-+EXTRA_LTLIBRARIES = libfederated.la libfederated_embedded.la ha_federated.la
- pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
- ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_federated_la_CXXFLAGS= $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -38,11 +38,14 @@
- ha_federated_la_SOURCES = ha_federated.cc $(top_srcdir)/mysys/string.c
-
-
--EXTRA_LIBRARIES = libfederated.a
--noinst_LIBRARIES = @plugin_federated_static_target@
--libfederated_a_CXXFLAGS = $(AM_CXXFLAGS)
--libfederated_a_CFLAGS = $(AM_CFLAGS)
--libfederated_a_SOURCES= ha_federated.cc
-+noinst_LTLIBRARIES = @plugin_federated_static_target@ @plugin_federated_embedded_static_target@
-+libfederated_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_SOURCES= ha_federated.cc
-+
-+libfederated_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_SOURCES= ha_federated.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/federated/plug.in'
---- storage/federated/plug.in 2010-06-09 21:29:18 +0000
-+++ storage/federated/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
- [Connects to tables on remote MySQL servers], [])
--MYSQL_PLUGIN_STATIC(federated, [libfederated.a])
-+MYSQL_PLUGIN_STATIC(federated, [libfederated.la], [libfederated_embedded.la])
- MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federated.cc])
-
-=== modified file 'storage/federatedx/Makefile.am'
---- storage/federatedx/Makefile.am 2010-06-09 21:29:18 +0000
-+++ storage/federatedx/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,21 +17,31 @@
-
- noinst_HEADERS = ha_federatedx.h federatedx_probes.h
-
--EXTRA_LTLIBRARIES = ha_federatedx.la
-+EXTRA_LTLIBRARIES = libfederatedx.la libfederatedx_common.la libfederatedx_embedded.la ha_federatedx.la
- pkgplugin_LTLIBRARIES = @plugin_federatedx_shared_target@
- ha_federatedx_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_federatedx_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
- ha_federatedx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-
-
--EXTRA_LIBRARIES = libfederatedx.a
--noinst_LIBRARIES = @plugin_federatedx_static_target@
--libfederatedx_a_CXXFLAGS = $(AM_CFLAGS)
--libfederatedx_a_CFLAGS = $(AM_CFLAGS)
--libfederatedx_a_SOURCES= ha_federatedx.cc federatedx_txn.cc \
-+noinst_LTLIBRARIES = @plugin_federatedx_static_target@ @plugin_federatedx_embedded_static_target@
-+libfederatedx_common_la_CXXFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_common_la_SOURCES= federatedx_txn.cc \
- federatedx_io.cc federatedx_io_null.cc \
- federatedx_io_mysql.cc
-
-+libfederatedx_la_CXXFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_la_LIBADD = libfederatedx_common.la
-+libfederatedx_la_SOURCES= ha_federatedx.cc
-+
-+libfederatedx_embedded_la_CXXFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederatedx_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederatedx_embedded_la_LDFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_embedded_la_LIBADD = libfederatedx_common.la
-+libfederatedx_embedded_la_SOURCES= ha_federatedx.cc
-+
- EXTRA_DIST = CMakeLists.txt plug.in ha_federatedx.h \
- federatedx_probes.h
-
-
-=== modified file 'storage/federatedx/plug.in'
---- storage/federatedx/plug.in 2010-06-09 21:29:18 +0000
-+++ storage/federatedx/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federatedx,,[FederatedX Storage Engine],
- [FederatedX Storage Engine], [max,max-no-ndb])
- MYSQL_PLUGIN_DYNAMIC(federatedx, [ha_federatedx.la])
--MYSQL_PLUGIN_STATIC(federatedx, [libfederatedx.a])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federatedx, [ha_federatedx.cc])
-+MYSQL_PLUGIN_STATIC(federatedx, [libfederatedx.la], [libfederatedx_embedded.la])
-
-=== modified file 'storage/heap/Makefile.am'
---- storage/heap/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/heap/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,27 +26,41 @@
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
-+pkglib_LTLIBRARIES = libheap.la
-+noinst_LTLIBRARIES = libheap_s.la libheap_common.la \
-+ @plugin_heap_embedded_static_target@
-+EXTRA_LTLIBRARIES = libheap_embedded.la
-+
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_common_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
- hp_rkey.c hp_block.c \
-- ha_heap.cc \
- hp_hash.c _check.c _rectest.c hp_static.c
-+libheap_common_la_CFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+
-+libheap_s_la_SOURCES = ha_heap.cc
-+libheap_s_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_LIBADD = libheap_common.la
-+libheap_embedded_la_SOURCES = ha_heap.cc
-+libheap_embedded_la_LIBADD = libheap_common.la
-+libheap_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+libheap_la_SOURCES =
-+libheap_la_LIBADD = libheap_s.la
-+libheap_la_LDFLAGS = -static
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/heap/plug.in'
---- storage/heap/plug.in 2006-10-18 12:03:37 +0000
-+++ storage/heap/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,7 +1,6 @@
- MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
- [Volatile memory based tables])
- MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
--MYSQL_PLUGIN_STATIC(heap, [libheap.a])
-+MYSQL_PLUGIN_STATIC(heap, [libheap_s.la], [libheap_embedded.la])
- MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(heap, [ha_heap.cc])
-
-
-=== modified file 'storage/innodb_plugin/Makefile.am'
---- storage/innodb_plugin/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/innodb_plugin/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -228,9 +228,8 @@
- include/ut0wqueue.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innodb_plugin_static_target@
--libinnobase_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_innodb_plugin_static_target@
-+libinnobase_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -325,16 +324,16 @@
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libinnobase_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_innodb_plugin.la
-+EXTRA_LTLIBRARIES= libinnobase.la ha_innodb_plugin.la
- pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@
-
- ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir)
- ha_innodb_plugin_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_innodb_plugin_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_plugin_la_SOURCES= $(libinnobase_la_SOURCES)
-
- EXTRA_DIST= CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
-
-=== modified file 'storage/maria/Makefile.am'
---- storage/maria/Makefile.am 2009-10-23 16:48:54 +0000
-+++ storage/maria/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,36 +33,39 @@
- EXTRA_DIST = ma_test_all.sh ma_test_all.res ma_test_big.sh \
- ma_ft_stem.c CMakeLists.txt plug.in ma_test_recovery
- pkgdata_DATA =
--pkglib_LIBRARIES = libmaria.a
-+pkglib_LTLIBRARIES = libmaria.la
-+noinst_LTLIBRARIES = libmaria_common.la libmaria_s.la \
-+ @plugin_maria_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmaria_embedded.la
- bin_PROGRAMS = maria_chk maria_pack maria_ftdump maria_read_log \
- maria_dump_log
--maria_chk_DEPENDENCIES= $(LIBRARIES)
--# Only reason to link with libmyisam.a here is that it's where some fulltext
-+maria_chk_DEPENDENCIES= $(LTLIBRARIES)
-+# Only reason to link with libmyisam.la here is that it's where some fulltext
- # pieces are (but soon we'll remove fulltext dependencies from Maria).
- # For now, it imposes that storage/myisam be built before storage/maria.
--maria_chk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--maria_pack_DEPENDENCIES=$(LIBRARIES)
--maria_pack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--maria_read_log_DEPENDENCIES=$(LIBRARIES)
--maria_read_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--maria_dump_log_DEPENDENCIES=$(LIBRARIES) ma_loghandler.c
--maria_dump_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+maria_chk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+maria_pack_DEPENDENCIES=$(LTLIBRARIES)
-+maria_pack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+maria_read_log_DEPENDENCIES=$(LTLIBRARIES)
-+maria_read_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+maria_dump_log_DEPENDENCIES=$(LTLIBRARIES) ma_loghandler.c
-+maria_dump_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- maria_dump_log_SOURCES= ma_loghandler.c unittest/ma_loghandler_examples.c
- maria_dump_log_CPPFLAGS= -DMARIA_DUMP_LOG
- noinst_PROGRAMS = ma_test1 ma_test2 ma_test3 ma_rt_test ma_sp_test
-@@ -74,45 +77,45 @@
- ma_checkpoint.h ma_recovery.h ma_commit.h ma_state.h \
- trnman_public.h ma_check_standalone.h \
- ma_key_recover.h ma_recovery_util.h
--ma_test1_DEPENDENCIES= $(LIBRARIES)
--ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_test2_DEPENDENCIES= $(LIBRARIES)
--ma_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_test3_DEPENDENCIES= $(LIBRARIES)
--ma_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ma_ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ma_ft_eval_DEPENDENCIES= $(LIBRARIES)
--maria_ftdump_DEPENDENCIES= $(LIBRARIES)
--maria_ftdump_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_rt_test_DEPENDENCIES= $(LIBRARIES)
--ma_rt_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_sp_test_DEPENDENCIES= $(LIBRARIES)
--ma_sp_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmaria_a_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
-+ma_test1_DEPENDENCIES= $(LTLIBRARIES)
-+ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_test2_DEPENDENCIES= $(LTLIBRARIES)
-+ma_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_test3_DEPENDENCIES= $(LTLIBRARIES)
-+ma_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ma_ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ma_ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+maria_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+maria_ftdump_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+ma_rt_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+ma_sp_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+libmaria_common_la_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
- ma_rnext.c ma_rnext_same.c \
- ma_search.c ma_page.c ma_key_recover.c ma_key.c \
- ma_locking.c ma_state.c \
-@@ -134,8 +137,22 @@
- ma_sp_key.c ma_control_file.c ma_loghandler.c \
- ma_pagecache.c ma_pagecaches.c \
- ma_checkpoint.c ma_recovery.c ma_commit.c \
-- ma_pagecrc.c ma_recovery_util.c \
-- ha_maria.cc
-+ ma_pagecrc.c ma_recovery_util.c
-+libmaria_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+
-+libmaria_s_la_SOURCES = ha_maria.cc
-+libmaria_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmaria_s_la_LIBADD = libmaria_common.la
-+libmaria_embedded_la_SOURCES = ha_maria.cc
-+libmaria_embedded_la_LIBADD = libmaria_common.la
-+libmaria_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+
-+# Static-only library for installation and linking into binaries.
-+# (Dynamic does not work well due to unresolved references into mysqld)
-+libmaria_la_LDFLAGS = -static
-+libmaria_la_SOURCES =
-+libmaria_la_LIBADD = libmaria_s.la
-+
- CLEANFILES = test?.MA? FT?.MA? isam.log ma_test_all ma_rt_test.MA? sp_test.MA? maria_log_control maria_log.0000*
-
- SUFFIXES = .sh
-
-=== modified file 'storage/maria/plug.in'
---- storage/maria/plug.in 2009-05-12 06:44:01 +0000
-+++ storage/maria/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,10 +1,9 @@
- MYSQL_STORAGE_ENGINE(maria,, [Maria Storage Engine],
- [Crash-safe tables with MyISAM heritage], [default,max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(maria, [storage/maria])
--MYSQL_PLUGIN_STATIC(maria, [libmaria.a])
-+MYSQL_PLUGIN_STATIC(maria, [libmaria_s.la], [libmaria_embedded.la])
- # Maria will probably go first into max builds, not all builds,
- # so we don't declare it mandatory.
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(maria, [ha_maria.cc])
-
- MYSQL_PLUGIN_ACTIONS(maria, [
- # AC_CONFIG_FILES(storage/maria/unittest/Makefile)
-
-=== modified file 'storage/maria/unittest/Makefile.am'
---- storage/maria/unittest/Makefile.am 2008-10-16 19:44:12 +0000
-+++ storage/maria/unittest/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,14 +19,14 @@
- -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
- EXTRA_DIST= ma_test_all-t CMakeLists.txt \
- ma_test_recovery.pl ma_test_recovery.expected
--# Only reason to link with libmyisam.a here is that it's where some fulltext
-+# Only reason to link with libmyisam.la here is that it's where some fulltext
- # pieces are (but soon we'll remove fulltext dependencies from Maria).
- LDADD= $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/storage/maria/libmaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+ $(top_builddir)/storage/maria/libmaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = ma_control_file-t trnman-t \
- ma_pagecache_single_1k-t ma_pagecache_single_8k-t \
- ma_pagecache_single_64k-t \
-
-=== modified file 'storage/myisam/Makefile.am'
---- storage/myisam/Makefile.am 2009-10-23 16:48:54 +0000
-+++ storage/myisam/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -30,60 +30,65 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA =
-
--pkglib_LIBRARIES = libmyisam.a
-+pkglib_LTLIBRARIES = libmyisam.la
-+noinst_LTLIBRARIES = libmyisam_common.la libmyisam_s.la \
-+ @plugin_myisam_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisam_embedded.la
-+
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
-+myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+
-+libmyisam_common_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-@@ -98,8 +103,24 @@
- mi_keycache.c mi_preload.c \
- ft_parser.c ft_stopwords.c ft_static.c \
- ft_update.c ft_boolean_search.c ft_nlq_search.c \
-- sort.c ha_myisam.cc ft_myisam.c \
-+ sort.c ft_myisam.c \
- rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
-+libmyisam_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_SOURCES = ha_myisam.cc
-+libmyisam_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_SOURCES = ha_myisam.cc
-+libmyisam_embedded_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+# libmyisam references symbols inside mysqld.
-+# This means we cannot use it as shared library, as these references causes
-+# undefined symbol errors at load time.
-+# But a static library works (as long as those parts that references
-+# problematic symbols are not linked).
-+libmyisam_la_LDFLAGS = -static
-+libmyisam_la_SOURCES =
-+libmyisam_la_LIBADD = libmyisam_s.la
-+
- CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-
- # Move to automake rules ?
-
-=== modified file 'storage/myisam/plug.in'
---- storage/myisam/plug.in 2008-10-10 15:28:41 +0000
-+++ storage/myisam/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,7 +1,6 @@
- dnl MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- dnl [Traditional non-transactional MySQL tables])
- dnl MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- dnl MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
-
-
-=== modified file 'storage/myisammrg/Makefile.am'
---- storage/myisammrg/Makefile.am 2008-04-25 21:45:58 +0000
-+++ storage/myisammrg/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,16 +26,29 @@
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libmyisammrg.a
-+pkglib_LTLIBRARIES = libmyisammrg.la
-+noinst_LTLIBRARIES = libmyisammrg_s.la libmyisammrg_common.la \
-+ @plugin_myisammrg_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisammrg_embedded.la
- noinst_HEADERS = myrg_def.h ha_myisammrg.h
--noinst_LIBRARIES = libmyisammrg.a
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_common_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
- myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
-- ha_myisammrg.cc \
- myrg_rnext_same.c myrg_records.c
-+libmyisammrg_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libmyisammrg_embedded_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libmyisammrg_la_SOURCES =
-+libmyisammrg_la_LIBADD = libmyisammrg_s.la
-+libmyisammrg_la_LDFLAGS = -static
-+
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/myisammrg/plug.in'
---- storage/myisammrg/plug.in 2006-10-18 12:03:37 +0000
-+++ storage/myisammrg/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
- [Merge multiple MySQL tables into one])
- MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
--MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
-+MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg_s.la], [libmyisammrg_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisammrg)
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc])
-
-=== modified file 'storage/ndb/src/common/util/Makefile.am'
---- storage/ndb/src/common/util/Makefile.am 2010-04-01 11:19:15 +0000
-+++ storage/ndb/src/common/util/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-
-=== modified file 'storage/ndb/src/cw/cpcd/Makefile.am'
---- storage/ndb/src/cw/cpcd/Makefile.am 2007-02-13 01:38:54 +0000
-+++ storage/ndb/src/cw/cpcd/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-
-=== modified file 'storage/ndb/src/kernel/Makefile.am'
---- storage/ndb/src/kernel/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -53,9 +53,10 @@
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@ \
-+ @ZLIB_LIBS@
-
- windoze-dsp: ndbd.dsp
-
-
-=== modified file 'storage/ndb/src/kernel/blocks/Makefile.am'
---- storage/ndb/src/kernel/blocks/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -57,9 +57,9 @@
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/backup/Makefile.am'
---- storage/ndb/src/kernel/blocks/backup/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,9 @@
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,17 +19,17 @@
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,9 @@
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Makefile.am'
---- storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2007-05-29 21:39:57 +0000
-+++ storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -23,9 +23,9 @@
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbtup/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -20,9 +20,9 @@
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/vm/Makefile.am'
---- storage/ndb/src/kernel/vm/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/vm/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -65,24 +65,24 @@
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
- bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
-=== modified file 'storage/ndb/src/mgmclient/Makefile.am'
---- storage/ndb/src/mgmclient/Makefile.am 2007-08-01 07:24:01 +0000
-+++ storage/ndb/src/mgmclient/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-
-=== modified file 'storage/ndb/src/mgmsrv/Makefile.am'
---- storage/ndb/src/mgmsrv/Makefile.am 2009-07-31 19:28:15 +0000
-+++ storage/ndb/src/mgmsrv/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-
-=== modified file 'storage/ndb/src/ndbapi/Makefile.am'
---- storage/ndb/src/ndbapi/Makefile.am 2007-04-11 13:51:09 +0000
-+++ storage/ndb/src/ndbapi/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -66,10 +66,11 @@
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
--ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ndberror_check_LDADD = \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ @ZLIB_LIBS@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/test/run-test/Makefile.am'
---- storage/ndb/test/run-test/Makefile.am 2009-10-13 18:21:42 +0000
-+++ storage/ndb/test/run-test/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -34,9 +34,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-
-=== modified file 'storage/ndb/tools/Makefile.am'
---- storage/ndb/tools/Makefile.am 2009-10-13 18:21:42 +0000
-+++ storage/ndb/tools/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -32,6 +32,11 @@
- ../test/src/NDBT_Table.cpp \
- ../test/src/NDBT_Output.cpp
-
-+LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ @ZLIB_LIBS@
-+
- ndb_test_platform_SOURCES = ndb_test_platform.cpp
- ndb_waiter_SOURCES = waiter.cpp $(tools_common_sources)
- ndb_delete_all_SOURCES = delete_all.cpp $(tools_common_sources)
-=== modified file 'storage/pbxt/plug.in'
---- storage/pbxt/plug.in 2009-12-09 21:39:23 +0000
-+++ storage/pbxt/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,8 +1,7 @@
- MYSQL_STORAGE_ENGINE(pbxt,no, [PBXT Storage Engine],
- [MVCC-based transactional engine], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(pbxt, [storage/pbxt])
--MYSQL_PLUGIN_STATIC(pbxt, [src/libpbxt.a])
-+MYSQL_PLUGIN_STATIC(pbxt, [src/libpbxt_s.la], [src/libpbxt_s_embedded.la])
- MYSQL_PLUGIN_ACTIONS(pbxt, [
- # AC_CONFIG_FILES(storage/pbxt/src/Makefile)
- ])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(pbxt, [[src/ha_pbxt.cc],[src/myxt_xt.cc],[src/discover_xt.cc]])
-
-=== modified file 'storage/pbxt/src/Makefile.am'
---- storage/pbxt/src/Makefile.am 2009-12-22 10:33:20 +0000
-+++ storage/pbxt/src/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,25 +26,33 @@
- pbms.h xt_config.h xt_defs.h xt_errno.h locklist_xt.h
- EXTRA_LTLIBRARIES = libpbxt.la
-
--libpbxt_la_SOURCES = bsearch_xt.cc cache_xt.cc ccutils_xt.cc database_xt.cc \
-+non_mysql_internal_sources = bsearch_xt.cc cache_xt.cc ccutils_xt.cc database_xt.cc \
- datadic_xt.cc datalog_xt.cc filesys_xt.cc hashtab_xt.cc \
-- ha_pbxt.cc heap_xt.cc index_xt.cc linklist_xt.cc \
-- memory_xt.cc myxt_xt.cc pthread_xt.cc restart_xt.cc \
-+ heap_xt.cc index_xt.cc linklist_xt.cc \
-+ memory_xt.cc pthread_xt.cc restart_xt.cc \
- sortedlist_xt.cc strutil_xt.cc \
- tabcache_xt.cc table_xt.cc trace_xt.cc thread_xt.cc \
-- systab_xt.cc ha_xtsys.cc discover_xt.cc backup_xt.cc \
-+ systab_xt.cc ha_xtsys.cc backup_xt.cc \
- util_xt.cc xaction_xt.cc xactlog_xt.cc lock_xt.cc locklist_xt.cc
--
--libpbxt_la_LDFLAGS = -module
-+mysql_internal_sources = ha_pbxt.cc myxt_xt.cc discover_xt.cc
-+libpbxt_la_SOURCES = $(non_mysql_internal_sources) $(mysql_internal_sources)
-
- # These are the warning Drizzle uses:
- # DRIZZLE_WARNINGS = -W -Wall -Wextra -pedantic -Wundef -Wredundant-decls -Wno-strict-aliasing -Wno-long-long -Wno-unused-parameter
-
- libpbxt_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
- libpbxt_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99
--
--EXTRA_LIBRARIES = libpbxt.a
--noinst_LIBRARIES = libpbxt.a
--libpbxt_a_SOURCES = $(libpbxt_la_SOURCES)
-+libpbxt_la_LDFLAGS = -module
-+
-+noinst_LTLIBRARIES = libpbxt_s.la libpbxt_s_embedded.la libpbxt_s_common.la
-+
-+libpbxt_s_common_la_SOURCES = $(non_mysql_internal_sources)
-+libpbxt_s_common_la_CXXFLAGS = @plugin_static_if_no_embedded@
-+libpbxt_s_la_SOURCES = $(mysql_internal_sources)
-+libpbxt_s_la_CXXFLAGS = @plugin_static_if_no_embedded@
-+libpbxt_s_la_LIBADD = libpbxt_s_common.la
-+libpbxt_s_embedded_la_SOURCES = $(mysql_internal_sources)
-+libpbxt_s_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libpbxt_s_embedded_la_LIBADD = libpbxt_s_common.la
-
- EXTRA_DIST = pbms_enabled.cc win_inttypes.h
-
-=== modified file 'storage/xtradb/Makefile.am'
---- storage/xtradb/Makefile.am 2010-08-04 08:39:53 +0000
-+++ storage/xtradb/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -229,9 +229,8 @@
- handler/innodb_patch_info.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libxtradb.a
--noinst_LIBRARIES= @plugin_xtradb_static_target@
--libxtradb_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_xtradb_static_target@
-+libxtradb_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -326,14 +325,14 @@
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libxtradb_a_CXXFLAGS= $(AM_CFLAGS)
--libxtradb_a_CFLAGS= $(AM_CFLAGS)
-+libxtradb_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libxtradb_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_xtradb.la
-+EXTRA_LTLIBRARIES= libxtradb.la ha_xtradb.la
- pkgplugin_LTLIBRARIES= @plugin_xtradb_shared_target@
-
- ha_xtradb_la_LDFLAGS= -module -rpath $(pkgplugindir)
--ha_xtradb_la_CXXFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
-+ha_xtradb_la_CXXFLAGS= $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_xtradb_la_CFLAGS= $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_xtradb_la_SOURCES= $(libxtradb_a_SOURCES)
-
-
-=== modified file 'storage/xtradb/plug.in'
---- storage/xtradb/plug.in 2010-08-04 08:39:53 +0000
-+++ storage/xtradb/plug.in 2010-09-16 12:49:35 +0000
-@@ -17,7 +17,7 @@
- MYSQL_STORAGE_ENGINE(xtradb, xtradb, [XtraDB Storage Engine],
- [XtraDB - a drop-in replacement for InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(xtradb, [storage/xtradb])
--MYSQL_PLUGIN_STATIC(xtradb, [libxtradb.a])
-+MYSQL_PLUGIN_STATIC(xtradb, [libxtradb.la])
- MYSQL_PLUGIN_DYNAMIC(xtradb, [ha_xtradb.la])
- MYSQL_PLUGIN_ACTIONS(xtradb, [
- with_plugin_innobase=$with_plugin_xtradb # for legacy code in configure.in
-
-=== modified file 'strings/Makefile.am'
---- strings/Makefile.am 2010-08-27 14:12:44 +0000
-+++ strings/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+pkglib_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,9 +56,10 @@
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt strmov_overlapp.c
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
-+
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
- conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-@@ -69,13 +70,13 @@
-
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
- test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
-=== modified file 'unittest/unit.pl'
---- unittest/unit.pl 2010-09-25 20:28:51.813336741 +0000
-+++ unittest/unit.pl 2010-09-25 20:29:58.156670013 +0000
-@@ -65,7 +65,7 @@
- my @dirs = @_;
- my @files;
- find sub {
-- $File::Find::prune = 1 if /^SCCS$/;
-+ $File::Find::prune = 1 if /^(SCCS|\.libs)$/;
- push(@files, $File::Find::name) if -x _ && (/-t\z/ || /-t\.exe\z/);
- }, @dirs;
- return @files;
-=== modified file 'unittest/mysys/Makefile.am'
---- unittest/mysys/Makefile.am 2010-08-27 14:12:44 +0000
-+++ unittest/mysys/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,9 +19,10 @@
- noinst_HEADERS = thr_template.c
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- EXTRA_DIST = CMakeLists.txt
- noinst_PROGRAMS = bitmap-t base64-t my_atomic-t lf-t waiting_threads-t
-
-=== modified file 'unittest/strings/Makefile.am'
---- unittest/strings/Makefile.am 2010-07-26 05:06:18 +0000
-+++ unittest/strings/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,10 @@
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- noinst_PROGRAMS = strings-t
-
-
-=== modified file 'vio/Makefile.am'
---- vio/Makefile.am 2010-08-27 14:12:44 +0000
-+++ vio/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/02040_all_embedded-library-shared-maria-5.2.03.patch b/02040_all_embedded-library-shared-maria-5.2.03.patch
deleted file mode 100644
index 4089862..0000000
--- a/02040_all_embedded-library-shared-maria-5.2.03.patch
+++ /dev/null
@@ -1,1945 +0,0 @@
-Convert all of the static libraries for the embedded libmysqld to build as
-shared.
-
-This enables amarok's mysql extension to properly build as a shared object,
-without statically including libmysqld or nor forcing libmysqld to be built
-with -fPIC.
-
-Thanks to <pageexec@freemail.hu> for the @plt fixes.
-Thanks to Diego Elio Pettenò <flameeyes@gentoo.org> for all the extensive build
-system help with libtool conversions.
-Thanks to Maciej Mrozowski <reavertm@gentoo.org> for working in the redo of the
-patch for mysql-5.1.
-
-Gentoo-Bug: 238487
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=238487
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=39288
-MySQL-Bug: 39288
-MySQL-Lists-URL: http://lists.mysql.com/internals/35947
-X-Patch-URL: http://bugs.gentoo.org/attachment.cgi?id=188019&action=view
-Signed-off-by: Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
-
-=== modified file 'client/Makefile.am'
---- client/Makefile.am 2010-08-27 14:12:44 +0000
-+++ client/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -75,7 +75,8 @@
- mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqlshow_SOURCES= mysqlshow.c
-
-@@ -84,15 +85,17 @@
- mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- mysqltest_SOURCES= mysqltest.cc
- mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS
- mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
- @CLIENT_EXTRA_LDFLAGS@ \
- $(LIBMYSQLCLIENT_LA) \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/regex/libregex.a \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la \
- $(CLIENT_THREAD_LIBS)
-
- mysql_upgrade_SOURCES= mysql_upgrade.c \
-
-=== modified file 'config/ac-macros/plugins.m4'
---- config/ac-macros/plugins.m4 2009-12-22 10:33:20 +0000
-+++ config/ac-macros/plugins.m4 2010-09-16 12:49:35 +0000
-@@ -116,18 +116,32 @@
- dnl Macro: MYSQL_PLUGIN_STATIC
- dnl
- dnl SYNOPSIS
--dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
-+dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a],[libmyplugin_embedded.a])
- dnl
- dnl DESCRIPTION
--dnl Declare the name for the static library
-+dnl Declare the name for the static library
-+dnl
-+dnl Third argument is optional, only needed for special plugins that depend
-+dnl on server internals and have source files that must be compiled specially
-+dnl with -DEMBEDDED_LIBRARY for embedded server. If specified, the third
-+dnl argument is used to link embedded server instead of the second.
- dnl
- dnl ---------------------------------------------------------------------------
-
- AC_DEFUN([MYSQL_PLUGIN_STATIC],[
- MYSQL_REQUIRE_PLUGIN([$1])
- m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
-+ ifelse($#, 3, [
-+ m4_define([MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]), [$3])
-+ ])
- ])
-
-+dnl ---------------------------------------------------------------------------
-+dnl Substitution variable to use to compile source files specially for
-+dnl embedded server.
-+dnl To be used by plugins that have sources that depend on server internals.
-+dnl ---------------------------------------------------------------------------
-+AC_SUBST([plugin_embedded_defs], ["-DEMBEDDED_LIBRARY -DMYSQL_SERVER"])
-
- dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_PLUGIN_DYNAMIC
-@@ -279,28 +293,6 @@
- ])
-
- dnl ---------------------------------------------------------------------------
--dnl Macro: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS
--dnl
--dnl SYNOPSIS
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS([name],[file name])
--dnl
--dnl DESCRIPTION
--dnl Some modules in plugins keep dependance on structures
--dnl declared in sql/ (THD class usually)
--dnl That has to be fixed in the future, but until then
--dnl we have to recompile these modules when we want to
--dnl to compile server parts with the different #defines
--dnl Normally it happens when we compile the embedded server
--dnl Thus one should mark such files in his handler using this macro
--dnl
--dnl ---------------------------------------------------------------------------
--
--AC_DEFUN([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS],[
-- MYSQL_REQUIRE_PLUGIN([$1])
-- m4_define([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]), [$2])
--])
--
--dnl ---------------------------------------------------------------------------
- dnl Macro: MYSQL_CONFIGURE_PLUGINS
- dnl
- dnl SYNOPSIS
-@@ -360,11 +352,25 @@
- [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
-- [MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]),
-+ [MYSQL_PLUGIN_EMBEDDED_]AS_TR_CPP([$1]),
- [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
- )
- ])
-
-+# __MYSQL_EMIT_CHECK_PLUGIN arguments:
-+#
-+# 1 - plugin identifying name
-+# 2 - plugin identifying name, with `-' replaced by `_'
-+# 3 - plugin long name
-+# 4 - plugin description
-+# 5 - mysql_plugin_define (eg. WITH_xxx_STORAGE_ENGINE)
-+# 6 - directory
-+# 7 - static target (if supports static build)
-+# 8 - dynamic target (if supports dynamic build)
-+# 9 - mandatory flag
-+# 10 - disabled flag
-+# 11 - static target for libmysqld (if different from mysqld)
-+# 12 - actions
- AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
- m4_ifdef([$5],[
- AH_TEMPLATE($5, [Include ]$3[ into mysqld])
-@@ -439,6 +445,7 @@
- ])
- AC_SUBST([plugin_]$2[_shared_target], "$8")
- AC_SUBST([plugin_]$2[_static_target], [""])
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
- [with_plugin_]$2=yes
- __MYSQL_EMIT_CHECK_RESULT($3,[plugin])
- m4_ifdef([$6],[
-@@ -453,32 +460,47 @@
- ])
- else
- m4_ifdef([$7],[
-- ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
--dnl change above "-2" to "0" to enable this section
--dnl Although this is "pretty", it breaks libmysqld build
-- m4_ifdef([$6],[
-- mysql_use_plugin_dir="$6"
-- mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
-- ])
-- mysql_plugin_libs="$mysql_plugin_libs dnl
--[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
-- ], m4_bregexp($7, [^\\\$]), 0, [
-+ ifelse(m4_bregexp($7, [^\\\$]), 0, [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- ])
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ], [
- m4_ifdef([$6],[
- mysql_use_plugin_dir="$6"
- mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs \$(top_builddir)/$6/$7"
-+ ])
- ],[
- mysql_plugin_libs="$mysql_plugin_libs $7"
-+ m4_ifdef([$11],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $11"
-+ ],[
-+ mysql_embedded_plugin_libs="$mysql_embedded_plugin_libs $7"
-+ ])
- ])
- ])
- m4_ifdef([$5],[
- AC_DEFINE($5)
- ])
- AC_SUBST([plugin_]$2[_static_target], "$7")
-+ m4_ifdef([$11], [
-+ if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_]$2[_embedded_static_target], "$11")
-+ else
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ fi
-+ ], [
-+ AC_SUBST([plugin_]$2[_embedded_static_target], [""])
-+ ])
- AC_SUBST([plugin_]$2[_shared_target], [""])
- ],[
- m4_ifdef([$6],[
-@@ -495,14 +484,6 @@
- maria_plugin_defs="$maria_plugin_defs, [builtin_maria_]$2[_plugin]"
- [with_plugin_]$2=yes
- __MYSQL_EMIT_CHECK_RESULT($3,[yes])
-- m4_ifdef([$11], [
-- m4_foreach([plugin], [$11], [
-- condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp(plugin, [[^/]+$], [\&])"
-- condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp(plugin, [[^/]+\.], [\&o])"
-- condition_dependent_plugin_links="$condition_dependent_plugin_links $6/plugin"
-- condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp(plugin, [^.+[/$]], [\&])"
-- ])
-- ])
- fi
- fi
-
-@@ -556,6 +578,14 @@
- m4_format([ * %-32s $2],$1:)"
- ])
-
-+dnl If not building libmysqld embedded server, then there is no need to build
-+dnl shared object versions of static plugins.
-+if test "$with_embedded_server" = "yes"; then
-+ AC_SUBST([plugin_static_if_no_embedded], "")
-+else
-+ AC_SUBST([plugin_static_if_no_embedded], "-static")
-+fi
-+
- AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
- ifelse($#, 0, [], $#, 1, [
- _MYSQL_EMIT_PLUGIN_ACTION([$1])
-
-=== modified file 'configure.in'
---- configure.in 2010-08-27 14:12:44 +0000
-+++ configure.in 2010-09-16 12:49:35 +0000
-@@ -2531,17 +2531,14 @@
- MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- [Traditional non-transactional MySQL tables])
- MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
-
- MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
- [MySQL Partitioning Support], [max,max-no-ndb])
-
- dnl -- ndbcluster requires partition to be enabled
-
--MYSQL_CONFIGURE_PLUGINS([default])
--
- # Only build client code?
- AC_ARG_WITH(server,
- [ --without-server Only build the client.],
-@@ -2555,6 +2552,8 @@
- [with_embedded_server=no]
- )
-
-+MYSQL_CONFIGURE_PLUGINS([default])
-+
- AC_ARG_WITH(query_cache,
- [ --without-query-cache Do not build query cache.],
- [with_query_cache=$withval],
-@@ -2856,9 +2855,6 @@
- then
- AC_DEFINE([THREAD], [1],
- [Define if you want to have threaded code. This may be undef on client code])
-- # Avoid _PROGRAMS names
-- THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o mf_keycaches.o waiting_threads.o"
-- AC_SUBST(THREAD_LOBJECTS)
- fi
- AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
-
-@@ -2887,6 +2873,7 @@
-
- AC_SUBST(mysql_plugin_dirs)
- AC_SUBST(mysql_plugin_libs)
-+AC_SUBST(mysql_embedded_plugin_libs)
- AC_SUBST(maria_plugin_defs)
-
-
-
-=== modified file 'dbug/Makefile.am'
---- dbug/Makefile.am 2010-08-27 14:12:44 +0000
-+++ dbug/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--LDADD = libdbug.a ../mysys/libmysys.a ../strings/libmystrings.a
--pkglib_LIBRARIES = libdbug.a
-+LDADD = libdbug.la ../mysys/libmysys.la ../strings/libmystrings.la $(ZLIB_LIBS)
-+pkglib_LTLIBRARIES = libdbug.la
- noinst_HEADERS = dbug_long.h
--libdbug_a_SOURCES = dbug.c sanity.c
-+libdbug_la_SOURCES = dbug.c sanity.c
- EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
- user.r monty.doc dbug_add_tags.pl \
- my_main.c main.c factorial.c dbug_analyze.c \
-
-=== modified file 'extra/Makefile.am'
---- extra/Makefile.am 2010-08-27 14:12:44 +0000
-+++ extra/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -15,8 +15,8 @@
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
-- ../dbug/libdbug.a ../strings/libmystrings.a \
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.la \
-+ ../dbug/libdbug.la ../strings/libmystrings.la \
- $(ZLIB_LIBS)
- BUILT_SOURCES= $(top_builddir)/include/mysqld_error.h \
- $(top_builddir)/include/sql_state.h \
-
-=== modified file 'libmysqld/Makefile.am'
---- libmysqld/Makefile.am 2010-08-27 14:12:44 +0000
-+++ libmysqld/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -36,8 +36,7 @@
- $(openssl_includes) @ZLIB_INCLUDES@ \
- @condition_dependent_plugin_includes@
-
--noinst_LIBRARIES = libmysqld_int.a
--pkglib_LIBRARIES = libmysqld.a
-+pkglib_LTLIBRARIES = libmysqld.la
- SUBDIRS = . examples
- libmysqld_sources= libmysqld.c lib_sql.cc emb_qcache.cc
- libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
-@@ -79,34 +78,29 @@
- rpl_injector.cc my_user.c partition_info.cc \
- sql_servers.cc event_parse_data.cc opt_table_elimination.cc
-
--libmysqld_int_a_SOURCES= $(libmysqld_sources)
--nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
--libmysqld_a_SOURCES=
--
--sqlstoragesources = $(EXTRA_libmysqld_a_SOURCES)
--storagesources = @condition_dependent_plugin_modules@
--storageobjects = @condition_dependent_plugin_objects@
--storagesourceslinks = @condition_dependent_plugin_links@
--
- # automake misses these
- sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
-
- # The following libraries should be included in libmysqld.a
--INC_LIB= $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/vio/libvio.a \
-+INC_LIB= $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/vio/libvio.la \
- @NDB_SCI_LIBS@ \
-- @mysql_plugin_libs@ \
-+ @mysql_embedded_plugin_libs@ \
- $(libevent_inc_libs) \
- $(yassl_inc_libs)
-
- if HAVE_YASSL
--yassl_inc_libs= $(top_builddir)/extra/yassl/src/.libs/libyassl.a \
-- $(top_builddir)/extra/yassl/taocrypt/src/.libs/libtaocrypt.a
-+yassl_inc_libs= $(top_builddir)/extra/yassl/src/libyassl.la \
-+ $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
- endif
-
-+libmysqld_la_SOURCES= $(libmysqld_sources)
-+nodist_libmysqld_la_SOURCES= $(libmysqlsources) $(sqlsources)
-+libmysqld_la_LIBADD = $(INC_LIB)
-+
- # Storage engine specific compilation options
- ha_ndbcluster.o:ha_ndbcluster.cc
- $(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
-@@ -140,51 +134,13 @@
- ha_myisammrg.o:ha_myisammrg.cc
- $(CXXCOMPILE) $(LM_CFLAGS) -c $<
-
--#
--# To make it easy for the end user to use the embedded library we
--# generate a total libmysqld.a from all library files,
--
--# note - InnoDB libraries have circular dependencies, so in INC_LIB
--# few libraries are present two times. Metrowerks linker doesn't like
--# it at all. Traditional ar has no problems with it, but still there's no
--# need to add the same file twice to the library, so 'sort -u' save us
--# some time and spares unnecessary work.
--
--libmysqld.a: libmysqld_int.a $(INC_LIB) $(libmysqld_a_DEPENDENCIES) $(storageobjects)
--if DARWIN_MWCC
-- mwld -lib -o $@ libmysqld_int.a `echo $(INC_LIB) | sort -u` $(storageobjects)
--else
-- -rm -f libmysqld.a
-- if test "$(host_os)" = "netware" ; \
-- then \
-- $(libmysqld_a_AR) libmysqld.a $(INC_LIB) libmysqld_int.a $(storageobjects); \
-- else \
-- current_dir=`pwd`; \
-- rm -rf tmp; mkdir tmp; \
-- (for arc in $(INC_LIB) ./libmysqld_int.a; do \
-- arpath=`echo $$arc|sed 's|[^/]*$$||'|sed 's|\.libs/$$||'`; \
-- artmp=`echo $$arc|sed 's|^.*/|tmp/lib-|'`; \
-- for F in `$(AR) t $$arc | grep -v SYMDEF`; do \
-- if test -e "$$arpath/$$F" ; then echo "$$arpath/$$F"; else \
-- mkdir $$artmp; cd $$artmp > /dev/null; \
-- $(AR) x ../../$$arc; \
-- cd $$current_dir > /dev/null; \
-- ls $$artmp/* | grep -v SYMDEF; \
-- continue 2; fi; done; \
-- done; echo $(libmysqld_a_DEPENDENCIES) ) | sort -u | xargs $(AR) cq libmysqld.a ; \
-- $(AR) r libmysqld.a $(storageobjects); \
-- $(RANLIB) libmysqld.a ; \
-- rm -rf tmp; \
-- fi
--endif
--
- ## XXX: any time the client interface changes, we'll need to bump
- ## the version info for libmysqld; however, it's possible for the
- ## libmysqld interface to change without affecting the standard
- ## libmysqlclient interface. Should we make a separate version
- ## string for the two?
- #libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
--#CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
-+#CLEANFILES = libmysqld.la
-
- BUILT_SOURCES = link_sources
-
-@@ -209,20 +165,6 @@
- @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
- fi ; \
- done; \
-- if test -n "$(sqlstoragesources)" ; \
-- then \
-- for f in "$(sqlstoragesources)"; do \
-- rm -f "$$f"; \
-- @LN_CP_F@ `find $(srcdir)/../sql -name "$$f"` "$$f"; \
-- done; \
-- fi; \
-- if test -n "$(storagesources)" ; \
-- then \
-- rm -f $(storagesources); \
-- for f in $(storagesourceslinks); do \
-- @LN_CP_F@ $(top_srcdir)/$$f . ; \
-- done; \
-- fi; \
- rm -f client_settings.h; \
- @LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h \
- client_settings.h; \
-@@ -230,5 +172,5 @@
-
-
- clean-local:
-- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlstoragesources) $(storagesources) | sed "s;\.lo;.c;g"`; \
-+ rm -f `echo $(sqlsources) $(libmysqlsources) | sed "s;\.lo;.c;g"`; \
- rm -f client_settings.h
-
-=== modified file 'libmysqld/examples/Makefile.am'
---- libmysqld/examples/Makefile.am 2010-07-16 07:15:22 +0000
-+++ libmysqld/examples/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -37,12 +37,16 @@
- -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
--LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS) \
-- @NDB_SCI_LIBS@
-+LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.la @LIBDL@ $(CXXLDFLAGS) \
-+ @NDB_SCI_LIBS@ \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(ZLIB_LIBS)
-
- mysqltest_embedded_LINK = $(CXXLINK)
- nodist_mysqltest_embedded_SOURCES = mysqltest.cc
--mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a \
-+mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.la \
- @MYSQLD_EXTRA_LDFLAGS@
-
- nodist_mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
-
-=== modified file 'mysys/Makefile.am'
---- mysys/Makefile.am 2010-08-27 14:12:44 +0000
-+++ mysys/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -18,11 +19,11 @@
- MYSQLBASEdir= $(prefix)
- INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
- -I$(top_srcdir)/include -I$(srcdir)
--pkglib_LIBRARIES = libmysys.a
--LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
-+pkglib_LTLIBRARIES = libmysys.la
-+LDADD = libmysys.la $(top_builddir)/strings/libmystrings.la $(top_builddir)/dbug/libdbug.la
- noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h \
- my_safehash.h
--libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
-+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
- mf_path.c mf_loadpath.c my_file.c \
- my_open.c my_create.c my_dup.c my_seek.c my_read.c \
- my_pread.c my_write.c my_getpagesize.c \
-@@ -62,18 +62,19 @@
- # mf_keycache is used only in the server, so it is safe to leave the file
- # out of the non-threaded library.
- # In fact, it will currently not compile without thread support.
--libmysys_a_SOURCES += mf_keycache.c mf_keycaches.c
-+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
-+ my_pthread.c my_thr_init.c waiting_threads.c \
-+ mf_keycache.c mf_keycaches.c
- endif
-
- EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
- thr_mutex.c thr_rwlock.c waiting_threads.c \
- CMakeLists.txt mf_soundex.c \
- my_conio.c my_wincond.c my_winthread.c
--libmysys_a_LIBADD = @THREAD_LOBJECTS@
--# test_dir_DEPENDENCIES= $(LIBRARIES)
--# testhash_DEPENDENCIES= $(LIBRARIES)
--# test_charset_DEPENDENCIES= $(LIBRARIES)
--# charset2html_DEPENDENCIES= $(LIBRARIES)
-+# test_dir_DEPENDENCIES= $(LTLIBRARIES)
-+# testhash_DEPENDENCIES= $(LTLIBRARIES)
-+# test_charset_DEPENDENCIES= $(LTLIBRARIES)
-+# charset2html_DEPENDENCIES= $(LTLIBRARIES)
- DEFS = -DDEFAULT_BASEDIR='"$(prefix)"' \
- -DMYSQL_DATADIR='"$(MYSQLDATAdir)"' \
- -DDEFAULT_CHARSET_HOME='"$(MYSQLBASEdir)"' \
-@@ -83,8 +83,6 @@
- -DDEFAULT_SYSCONFDIR='"$(sysconfdir)"' \
- @DEFS@
-
--libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
--
- # I hope this always does the right thing. Otherwise this is only test programs
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
-
-@@ -100,50 +99,50 @@
- # which automaticly removes the object files you use to compile a final program
- #
-
--test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
-+test_bitmap$(EXEEXT): my_bitmap.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
-
--test_priority_queue$(EXEEXT): queues.c $(LIBRARIES)
-+test_priority_queue$(EXEEXT): queues.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN ./queues.c $(LDADD) $(LIBS)
-
--test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
-+test_thr_alarm$(EXEEXT): thr_alarm.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_alarm.c
-
--test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
-+test_thr_lock$(EXEEXT): thr_lock.c $(LTLIBRARIES)
- $(CP) $(srcdir)/thr_lock.c test_thr_lock.c
- $(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
- $(RM) -f ./test_thr_lock.c
-
--test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
-+test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
- $(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
- $(RM) -f test_vsnprintf.c
-
--test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
-+test_io_cache$(EXEEXT): mf_iocache.c $(LTLIBRARIES)
- $(CP) $(srcdir)/mf_iocache.c test_io_cache.c
- $(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
- $(RM) -f test_io_cache.c
-
--test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
-+test_dir$(EXEEXT): test_dir.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
-
--test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
-+test_charset$(EXEEXT): test_charset.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
-
--testhash$(EXEEXT): testhash.c $(LIBRARIES)
-+testhash$(EXEEXT): testhash.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
-
--test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LIBRARIES)
-+test_gethwaddr$(EXEEXT): my_gethwaddr.c $(LTLIBRARIES)
- $(CP) $(srcdir)/my_gethwaddr.c ./test_gethwaddr.c
- $(LINK) $(FLAGS) -DMAIN ./test_gethwaddr.c $(LDADD) $(LIBS)
- $(RM) -f ./test_gethwaddr.c
-
--test_base64$(EXEEXT): base64.c $(LIBRARIES)
-+test_base64$(EXEEXT): base64.c $(LTLIBRARIES)
- $(CP) $(srcdir)/base64.c ./test_base64.c
- $(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
- $(RM) -f ./test_base64.c
-
--test_thr_mutex$(EXEEXT): test_thr_mutex.c $(LIBRARIES)
-+test_thr_mutex$(EXEEXT): test_thr_mutex.c $(LTLIBRARIES)
- $(LINK) $(FLAGS) $(srcdir)/test_thr_mutex.c $(LDADD) $(LIBS)
-
-=== modified file 'regex/Makefile.am'
---- regex/Makefile.am 2010-08-27 14:12:44 +0000
-+++ regex/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- # MA 02111-1307, USA
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--noinst_LIBRARIES = libregex.a
--LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
-+noinst_LTLIBRARIES = libregex.la
-+LDADD= libregex.la $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
--libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
-+libregex_la_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
- noinst_PROGRAMS = re
- re_SOURCES = split.c debug.c main.c
- re_LDFLAGS= @NOINST_LDFLAGS@
-
-=== modified file 'server-tools/instance-manager/Makefile.am'
---- server-tools/instance-manager/Makefile.am 2007-02-18 12:45:28 +0000
-+++ server-tools/instance-manager/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -88,10 +88,10 @@
- mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \
- liboptions.la \
- libnet.a \
-- $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-- $(top_builddir)/dbug/libdbug.a \
-+ $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(top_builddir)/dbug/libdbug.la \
- @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@ @LIBDL@
-
- EXTRA_DIST = WindowsService.cpp WindowsService.h IMService.cpp \
-
-=== modified file 'sql/Makefile.am'
---- sql/Makefile.am 2010-08-27 14:12:44 +0000
-+++ sql/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,13 +33,13 @@
- noinst_LTLIBRARIES= libndb.la \
- udf_example.la
-
--SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/regex/libregex.a \
-- $(top_builddir)/strings/libmystrings.a
-+SUPPORTING_LIBS = $(top_builddir)/vio/libvio.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/regex/libregex.la \
-+ $(top_builddir)/strings/libmystrings.la
- mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
--LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
-+LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@ $(openssl_libs) $(yassl_libs)
- mysqld_LDADD = libndb.la \
- @MYSQLD_EXTRA_LDFLAGS@ \
- @pstack_libs@ $(libevent_libs) \
-
-=== modified file 'storage/archive/Makefile.am'
---- storage/archive/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/archive/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,7 +33,7 @@
- noinst_HEADERS = ha_archive.h azlib.h
- noinst_PROGRAMS = archive_test archive_reader
-
--EXTRA_LTLIBRARIES = ha_archive.la
-+EXTRA_LTLIBRARIES = libarchive.la ha_archive.la
- pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
- ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
- ha_archive_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-@@ -41,26 +41,25 @@
- ha_archive_la_SOURCES = ha_archive.cc azio.c
-
-
--EXTRA_LIBRARIES = libarchive.a
--noinst_LIBRARIES = @plugin_archive_static_target@
--libarchive_a_CXXFLAGS = $(AM_CXXFLAGS)
--libarchive_a_CFLAGS = $(AM_CFLAGS)
--libarchive_a_SOURCES = ha_archive.cc azio.c
-+noinst_LTLIBRARIES = @plugin_archive_static_target@
-+libarchive_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libarchive_la_SOURCES = ha_archive.cc azio.c
-
-
- archive_test_SOURCES = archive_test.c azio.c
- archive_test_CFLAGS = $(AM_CFLAGS)
--archive_test_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_test_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_test_LDFLAGS = @NOINST_LDFLAGS@
-
- archive_reader_SOURCES = archive_reader.c azio.c
- archive_reader_CFLAGS = $(AM_CFLAGS)
--archive_reader_LDADD = $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a \
-+archive_reader_LDADD = $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @ZLIB_LIBS@
- archive_reader_LDFLAGS = @NOINST_LDFLAGS@
-
-
-=== modified file 'storage/archive/plug.in'
---- storage/archive/plug.in 2006-05-06 11:43:18 +0000
-+++ storage/archive/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,4 +1,4 @@
- MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
- [Archive Storage Engine], [max,max-no-ndb])
--MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
-+MYSQL_PLUGIN_STATIC(archive, [libarchive.la])
- MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
-
-=== modified file 'storage/blackhole/Makefile.am'
---- storage/blackhole/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/blackhole/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -32,7 +32,7 @@
-
- noinst_HEADERS = ha_blackhole.h
-
--EXTRA_LTLIBRARIES = ha_blackhole.la
-+EXTRA_LTLIBRARIES = libblackhole.la ha_blackhole.la
- pkgplugin_LTLIBRARIES = @plugin_blackhole_shared_target@
- ha_blackhole_la_LDFLAGS=-module -rpath $(pkgplugindir)
- ha_blackhole_la_CXXFLAGS=-shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-
-=== modified file 'storage/blackhole/plug.in'
---- storage/blackhole/plug.in 2006-08-19 04:19:19 +0000
-+++ storage/blackhole/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,6 +1,6 @@
- MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
- [Basic Write-only Read-never tables], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
--MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
-+MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.la])
- MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
-
-
-=== modified file 'storage/csv/Makefile.am'
---- storage/csv/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/csv/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -29,16 +29,15 @@
- DEFS = @DEFS@
- noinst_HEADERS = ha_tina.h transparent_file.h
-
--EXTRA_LTLIBRARIES = ha_csv.la
-+EXTRA_LTLIBRARIES = libcsv.la ha_csv.la
- pkglib_LTLIBRARIES = @plugin_csv_shared_target@
- ha_csv_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
- ha_csv_la_CXXFLAGS = -shared $(AM_CXXFLAGS) -DMYSQL_PLUGIN
- ha_csv_la_SOURCES = transparent_file.cc ha_tina.cc
-
--EXTRA_LIBRARIES = libcsv.a
--noinst_LIBRARIES = @plugin_csv_static_target@
--libcsv_a_CXXFLAGS = $(AM_CXXFLAGS)
--libcsv_a_SOURCES = transparent_file.cc ha_tina.cc
-+noinst_LTLIBRARIES = @plugin_csv_static_target@
-+libcsv_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libcsv_la_SOURCES = transparent_file.cc ha_tina.cc
-
- EXTRA_DIST = CMakeLists.txt plug.in
- # Don't update the files from bitkeeper
-
-=== modified file 'storage/csv/plug.in'
---- storage/csv/plug.in 2006-08-19 04:19:19 +0000
-+++ storage/csv/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,5 @@
- MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
- [Stores tables in text CSV format])
- MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
--MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
-+MYSQL_PLUGIN_STATIC(csv, [libcsv.la])
- MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
-
-=== modified file 'storage/example/Makefile.am'
---- storage/example/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/example/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -32,16 +32,15 @@
-
- noinst_HEADERS = ha_example.h
-
--EXTRA_LTLIBRARIES = ha_example.la
-+EXTRA_LTLIBRARIES = libexample.la ha_example.la
- pkgplugin_LTLIBRARIES = @plugin_example_shared_target@
- ha_example_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
- ha_example_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
- ha_example_la_SOURCES = ha_example.cc
-
--EXTRA_LIBRARIES = libexample.a
--noinst_LIBRARIES = @plugin_example_static_target@
--libexample_a_CXXFLAGS = $(AM_CXXFLAGS)
--libexample_a_SOURCES= ha_example.cc
-+noinst_LTLIBRARIES = @plugin_example_static_target@
-+libexample_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libexample_la_SOURCES= ha_example.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/federated/Makefile.am'
---- storage/federated/Makefile.am 2010-08-27 14:12:44 +0000
-+++ storage/federated/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -30,7 +30,7 @@
-
- noinst_HEADERS = ha_federated.h
-
--EXTRA_LTLIBRARIES = ha_federated.la
-+EXTRA_LTLIBRARIES = libfederated.la libfederated_embedded.la ha_federated.la
- pkgplugin_LTLIBRARIES = @plugin_federated_shared_target@
- ha_federated_la_LDFLAGS = -module -rpath $(pkgplugindir) \
- -L$(top_builddir)/libservices -lmysqlservices
-
-@@ -38,11 +38,14 @@
- ha_federated_la_SOURCES = ha_federated.cc $(top_srcdir)/mysys/string.c
-
-
--EXTRA_LIBRARIES = libfederated.a
--noinst_LIBRARIES = @plugin_federated_static_target@
--libfederated_a_CXXFLAGS = $(AM_CXXFLAGS)
--libfederated_a_SOURCES= ha_federated.cc
-+noinst_LTLIBRARIES = @plugin_federated_static_target@ @plugin_federated_embedded_static_target@
-+libfederated_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libfederated_la_SOURCES= ha_federated.cc
-+
-+libfederated_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libfederated_embedded_la_SOURCES= ha_federated.cc
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/federated/plug.in'
---- storage/federated/plug.in 2010-06-09 21:29:18 +0000
-+++ storage/federated/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
- [Connects to tables on remote MySQL servers], [])
--MYSQL_PLUGIN_STATIC(federated, [libfederated.a])
-+MYSQL_PLUGIN_STATIC(federated, [libfederated.la], [libfederated_embedded.la])
- MYSQL_PLUGIN_DYNAMIC(federated, [ha_federated.la])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federated, [ha_federated.cc])
-
-=== modified file 'storage/federatedx/Makefile.am'
---- storage/federatedx/Makefile.am 2010-06-09 21:29:18 +0000
-+++ storage/federatedx/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,7 +17,7 @@
-
- noinst_HEADERS = ha_federatedx.h federatedx_probes.h
-
--EXTRA_LTLIBRARIES = ha_federatedx.la
-+EXTRA_LTLIBRARIES = libfederatedx.la libfederatedx_common.la libfederatedx_embedded.la ha_federatedx.la
- pkgplugin_LTLIBRARIES = @plugin_federatedx_shared_target@
- ha_federatedx_la_LDFLAGS = -module -rpath $(pkgplugindir) \
- -L$(top_builddir)/libservices -lmysqlservices
-
-@@ -25,13 +25,21 @@
- ha_federatedx_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-
-
--EXTRA_LIBRARIES = libfederatedx.a
--noinst_LIBRARIES = @plugin_federatedx_static_target@
--libfederatedx_a_CXXFLAGS = $(AM_CFLAGS)
--libfederatedx_a_SOURCES= ha_federatedx.cc federatedx_txn.cc \
-+noinst_LTLIBRARIES = @plugin_federatedx_static_target@ @plugin_federatedx_embedded_static_target@
-+libfederatedx_common_la_CXXFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_common_la_SOURCES= federatedx_txn.cc \
- federatedx_io.cc federatedx_io_null.cc \
- federatedx_io_mysql.cc
-
-+libfederatedx_la_CXXFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_la_LIBADD = libfederatedx_common.la
-+libfederatedx_la_SOURCES= ha_federatedx.cc
-+
-+libfederatedx_embedded_la_CXXFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libfederatedx_embedded_la_LDFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+libfederatedx_embedded_la_LIBADD = libfederatedx_common.la
-+libfederatedx_embedded_la_SOURCES= ha_federatedx.cc
-+
- EXTRA_DIST = CMakeLists.txt plug.in ha_federatedx.h \
- federatedx_probes.h
-
-
-=== modified file 'storage/federatedx/plug.in'
---- storage/federatedx/plug.in 2010-06-09 21:29:18 +0000
-+++ storage/federatedx/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,5 +1,4 @@
- MYSQL_STORAGE_ENGINE(federatedx,,[FederatedX Storage Engine],
- [FederatedX Storage Engine], [max,max-no-ndb])
- MYSQL_PLUGIN_DYNAMIC(federatedx, [ha_federatedx.la])
--MYSQL_PLUGIN_STATIC(federatedx, [libfederatedx.a])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(federatedx, [ha_federatedx.cc])
-+MYSQL_PLUGIN_STATIC(federatedx, [libfederatedx.la], [libfederatedx_embedded.la])
-
-=== modified file 'storage/heap/Makefile.am'
---- storage/heap/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/heap/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,27 +26,41 @@
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libheap.a
-+pkglib_LTLIBRARIES = libheap.la
-+noinst_LTLIBRARIES = libheap_s.la libheap_common.la \
-+ @plugin_heap_embedded_static_target@
-+EXTRA_LTLIBRARIES = libheap_embedded.la
-+
- noinst_PROGRAMS = hp_test1 hp_test2
--noinst_LIBRARIES = libheap.a
- hp_test1_LDFLAGS = @NOINST_LDFLAGS@
--hp_test1_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test1_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- hp_test2_LDFLAGS = @NOINST_LDFLAGS@
--hp_test2_LDADD = libheap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+hp_test2_LDADD = libheap.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
- noinst_HEADERS = heapdef.h ha_heap.h
--libheap_a_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
-+libheap_common_la_SOURCES = hp_open.c hp_extra.c hp_close.c hp_panic.c hp_info.c \
- hp_rrnd.c hp_scan.c hp_update.c hp_write.c hp_delete.c \
- hp_rsame.c hp_create.c hp_rename.c hp_rfirst.c \
- hp_rnext.c hp_rlast.c hp_rprev.c hp_clear.c \
- hp_rkey.c hp_block.c \
-- ha_heap.cc \
- hp_hash.c _check.c _rectest.c hp_static.c
-+libheap_common_la_CFLAGS = $(AM_LDFLAGS) @plugin_static_if_no_embedded@
-+
-+libheap_s_la_SOURCES = ha_heap.cc
-+libheap_s_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libheap_s_la_LIBADD = libheap_common.la
-+libheap_embedded_la_SOURCES = ha_heap.cc
-+libheap_embedded_la_LIBADD = libheap_common.la
-+libheap_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+libheap_la_SOURCES =
-+libheap_la_LIBADD = libheap_s.la
-+libheap_la_LDFLAGS = -static
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/heap/plug.in'
---- storage/heap/plug.in 2006-10-18 12:03:37 +0000
-+++ storage/heap/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,7 +1,6 @@
- MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
- [Volatile memory based tables])
- MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
--MYSQL_PLUGIN_STATIC(heap, [libheap.a])
-+MYSQL_PLUGIN_STATIC(heap, [libheap_s.la], [libheap_embedded.la])
- MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(heap, [ha_heap.cc])
-
-
-=== modified file 'storage/innodb_plugin/Makefile.am'
---- storage/innodb_plugin/Makefile.am 2010-07-09 11:37:51 +0000
-+++ storage/innodb_plugin/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -228,9 +228,8 @@
- include/ut0wqueue.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libinnobase.a
--noinst_LIBRARIES= @plugin_innodb_plugin_static_target@
--libinnobase_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_innodb_plugin_static_target@
-+libinnobase_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -325,16 +324,16 @@
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libinnobase_a_CXXFLAGS= $(AM_CXXFLAGS)
--libinnobase_a_CFLAGS= $(AM_CFLAGS)
-+libinnobase_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libinnobase_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_innodb_plugin.la
-+EXTRA_LTLIBRARIES= libinnobase.la ha_innodb_plugin.la
- pkgplugin_LTLIBRARIES= @plugin_innodb_plugin_shared_target@
-
- ha_innodb_plugin_la_LDFLAGS= -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
- ha_innodb_plugin_la_CXXFLAGS= -shared $(AM_CXXFLAGS) $(INNODB_DYNAMIC_CFLAGS)
- ha_innodb_plugin_la_CFLAGS= -shared $(AM_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
--ha_innodb_plugin_la_SOURCES= $(libinnobase_a_SOURCES)
-+ha_innodb_plugin_la_SOURCES= $(libinnobase_la_SOURCES)
-
- EXTRA_DIST= CMakeLists.txt plug.in \
- pars/make_bison.sh pars/make_flex.sh \
-
-=== modified file 'storage/maria/Makefile.am'
---- storage/maria/Makefile.am 2009-10-23 16:48:54 +0000
-+++ storage/maria/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -33,39 +33,42 @@
- EXTRA_DIST = ma_test_all.sh ma_test_all.res ma_test_big.sh \
- ma_ft_stem.c CMakeLists.txt plug.in ma_test_recovery
- pkgdata_DATA =
--pkglib_LIBRARIES = libaria.a
-+pkglib_LTLIBRARIES = libaria.la
-+noinst_LTLIBRARIES = libaria_common.la libaria_s.la \
-+ @plugin_maria_embedded_static_target@
-+EXTRA_LTLIBRARIES = libaria_embedded.la
- bin_PROGRAMS = aria_chk aria_pack aria_ftdump aria_read_log \
- aria_dump_log
--aria_chk_DEPENDENCIES= $(LIBRARIES)
--# Only reason to link with libmyisam.a here is that it's where some fulltext
-+aria_chk_DEPENDENCIES= $(LTLIBRARIES)
-+# Only reason to link with libmyisam.la here is that it's where some fulltext
- # pieces are (but soon we'll remove fulltext dependencies from Aria).
- # For now, it imposes that storage/myisam be built before storage/maria.
- aria_chk_SOURCES= maria_chk.c
--aria_chk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+aria_chk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- aria_pack_SOURCES= maria_pack.c
--aria_pack_DEPENDENCIES=$(LIBRARIES)
--aria_pack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+aria_pack_DEPENDENCIES=$(LTLIBRARIES)
-+aria_pack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- aria_read_log_SOURCES= maria_read_log.c
--aria_read_log_DEPENDENCIES=$(LIBRARIES)
--aria_read_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--aria_dump_log_DEPENDENCIES=$(LIBRARIES) ma_loghandler.c
--aria_dump_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+aria_read_log_DEPENDENCIES=$(LTLIBRARIES)
-+aria_read_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+aria_dump_log_DEPENDENCIES=$(LTLIBRARIES) ma_loghandler.c
-+aria_dump_log_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- aria_dump_log_SOURCES= ma_loghandler.c unittest/ma_loghandler_examples.c
- aria_dump_log_CPPFLAGS= -DMARIA_DUMP_LOG
- noinst_PROGRAMS = ma_test1 ma_test2 ma_test3 ma_rt_test ma_sp_test
-
-@@ -78,46 +81,46 @@
- trnman_public.h ma_check_standalone.h \
- ma_key_recover.h ma_recovery_util.h \
- ma_servicethread.h compat_aliases.h
--ma_test1_DEPENDENCIES= $(LIBRARIES)
--ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_test2_DEPENDENCIES= $(LIBRARIES)
--ma_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_test3_DEPENDENCIES= $(LIBRARIES)
-+ma_test1_DEPENDENCIES= $(LTLIBRARIES)
-+ma_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_test2_DEPENDENCIES= $(LTLIBRARIES)
-+ma_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_test3_DEPENDENCIES= $(LTLIBRARIES)
- ma_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ma_ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ma_ft_eval_DEPENDENCIES= $(LIBRARIES)
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ma_ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ma_ft_eval_DEPENDENCIES= $(LTLIBRARIES)
- aria_ftdump_SOURCES= maria_ftdump.c
--aria_ftdump_DEPENDENCIES= $(LIBRARIES)
--aria_ftdump_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_rt_test_DEPENDENCIES= $(LIBRARIES)
--ma_rt_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--ma_sp_test_DEPENDENCIES= $(LIBRARIES)
--ma_sp_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libaria_a_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
-+aria_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+aria_ftdump_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+ma_rt_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+ma_sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+ma_sp_test_LDADD= @CLIENT_EXTRA_LDFLAGS@ libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+libaria_common_la_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
- ma_rnext.c ma_rnext_same.c \
- ma_search.c ma_page.c ma_key_recover.c ma_key.c \
- ma_locking.c ma_state.c \
-
-@@ -141,6 +144,21 @@
- ma_checkpoint.c ma_recovery.c ma_commit.c \
- ma_pagecrc.c ma_recovery_util.c \
- ha_maria.cc compat_aliases.cc ma_servicethread.c
-+libaria_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+
-+libaria_s_la_SOURCES = ha_maria.cc
-+libaria_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libaria_s_la_LIBADD = libmaria_common.la
-+libaria_embedded_la_SOURCES = ha_maria.cc compat_aliases.cc ma_servicethread.c
-+libaria_embedded_la_LIBADD = libmaria_common.la
-+libaria_embedded_la_CXXFLAGS = @plugin_embedded_defs@
-+
-+# Static-only library for installation and linking into binaries.
-+# (Dynamic does not work well due to unresolved references into mysqld)
-+libaria_la_LDFLAGS = -static
-+libaria_la_SOURCES =
-+libaria_la_LIBADD = libaria_s.la
-+
- CLEANFILES = test?.MA? FT?.MA? isam.log ma_test_all ma_rt_test.MA? sp_test.MA? aria_log_control aria_log.0000*
-
- SUFFIXES = .sh
-
-=== modified file 'storage/maria/plug.in'
---- storage/maria/plug.in 2009-05-12 06:44:01 +0000
-+++ storage/maria/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,8 +1,7 @@
- MYSQL_STORAGE_ENGINE(aria,, [Aria Storage Engine],
- [Crash-safe tables with MyISAM heritage], [default,max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(aria, [storage/maria])
--MYSQL_PLUGIN_STATIC(aria, [libaria.a])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(aria, [ha_maria.cc])
-+MYSQL_PLUGIN_STATIC(aria, [libaria_s.la], [libaria_embedded.la]
-
- MYSQL_PLUGIN_ACTIONS(aria, [
- # AC_CONFIG_FILES(storage/maria/unittest/Makefile)
-
-=== modified file 'storage/maria/unittest/Makefile.am'
---- storage/maria/unittest/Makefile.am 2008-10-16 19:44:12 +0000
-+++ storage/maria/unittest/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,14 +19,14 @@
- -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
- EXTRA_DIST= ma_test_all-t CMakeLists.txt \
- ma_test_recovery.pl ma_test_recovery.expected
--# Only reason to link with libmyisam.a here is that it's where some fulltext
-+# Only reason to link with libmyisam.la here is that it's where some fulltext
- # pieces are (but soon we'll remove fulltext dependencies from Aria).
- LDADD= $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/storage/maria/libaria.a \
-- $(top_builddir)/storage/myisam/libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+ $(top_builddir)/storage/maria/libaria.la \
-+ $(top_builddir)/storage/myisam/libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = ma_control_file-t trnman-t \
- ma_pagecache_single_1k-t ma_pagecache_single_8k-t \
- ma_pagecache_single_64k-t \
-
-=== modified file 'storage/myisam/Makefile.am'
---- storage/myisam/Makefile.am 2009-10-23 16:48:54 +0000
-+++ storage/myisam/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -30,60 +30,65 @@
- EXTRA_DIST = mi_test_all.sh mi_test_all.res ft_stem.c CMakeLists.txt plug.in
- pkgdata_DATA =
-
--pkglib_LIBRARIES = libmyisam.a
-+pkglib_LTLIBRARIES = libmyisam.la
-+noinst_LTLIBRARIES = libmyisam_common.la libmyisam_s.la \
-+ @plugin_myisam_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisam_embedded.la
-+
- bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump
--myisamchk_DEPENDENCIES= $(LIBRARIES)
--myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisamlog_DEPENDENCIES= $(LIBRARIES)
--myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--myisampack_DEPENDENCIES=$(LIBRARIES)
--myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-+myisamchk_DEPENDENCIES= $(LTLIBRARIES)
-+myisamchk_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisamlog_DEPENDENCIES= $(LTLIBRARIES)
-+myisamlog_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+myisampack_DEPENDENCIES=$(LTLIBRARIES)
-+myisampack_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
- noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 rt_test sp_test #ft_test1 ft_eval
- noinst_HEADERS = myisamdef.h rt_index.h rt_key.h rt_mbr.h sp_defs.h \
- fulltext.h ftdefs.h ft_test1.h ft_eval.h \
- ha_myisam.h
--mi_test1_DEPENDENCIES= $(LIBRARIES)
--mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test2_DEPENDENCIES= $(LIBRARIES)
--mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--mi_test3_DEPENDENCIES= $(LIBRARIES)
--mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--#ft_test1_DEPENDENCIES= $(LIBRARIES)
--#ft_eval_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_DEPENDENCIES= $(LIBRARIES)
--myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--rt_test_DEPENDENCIES= $(LIBRARIES)
--rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--sp_test_DEPENDENCIES= $(LIBRARIES)
--sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
--libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
-+mi_test1_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test1_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test2_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test2_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+mi_test3_DEPENDENCIES= $(LTLIBRARIES)
-+mi_test3_LDADD= @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+#ft_test1_DEPENDENCIES= $(LTLIBRARIES)
-+#ft_eval_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_DEPENDENCIES= $(LTLIBRARIES)
-+myisam_ftdump_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+rt_test_DEPENDENCIES= $(LTLIBRARIES)
-+rt_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+sp_test_DEPENDENCIES= $(LTLIBRARIES)
-+sp_test_LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la @ZLIB_LIBS@
-+
-+libmyisam_common_la_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
- mi_rnext.c mi_rnext_same.c \
- mi_search.c mi_page.c mi_key.c mi_locking.c \
- mi_rrnd.c mi_scan.c mi_cache.c \
-@@ -98,8 +103,24 @@
- mi_keycache.c mi_preload.c \
- ft_parser.c ft_stopwords.c ft_static.c \
- ft_update.c ft_boolean_search.c ft_nlq_search.c \
-- sort.c ha_myisam.cc ft_myisam.c \
-+ sort.c ft_myisam.c \
- rt_index.c rt_key.c rt_mbr.c rt_split.c sp_key.c
-+libmyisam_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_SOURCES = ha_myisam.cc
-+libmyisam_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisam_s_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_SOURCES = ha_myisam.cc
-+libmyisam_embedded_la_LIBADD = libmyisam_common.la
-+libmyisam_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+# libmyisam references symbols inside mysqld.
-+# This means we cannot use it as shared library, as these references causes
-+# undefined symbol errors at load time.
-+# But a static library works (as long as those parts that references
-+# problematic symbols are not linked).
-+libmyisam_la_LDFLAGS = -static
-+libmyisam_la_SOURCES =
-+libmyisam_la_LIBADD = libmyisam_s.la
-+
- CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all rt_test.MY? sp_test.MY?
-
- # Move to automake rules ?
-
-=== modified file 'storage/myisam/plug.in'
---- storage/myisam/plug.in 2008-10-10 15:28:41 +0000
-+++ storage/myisam/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,7 +1,6 @@
- dnl MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
- dnl [Traditional non-transactional MySQL tables])
- dnl MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
--dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
-+dnl MYSQL_PLUGIN_STATIC(myisam, [libmyisam_s.la], [libmyisam_embedded.la])
- dnl MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
--dnl MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisam, [ha_myisam.cc])
-
-
-=== modified file 'storage/myisammrg/Makefile.am'
---- storage/myisammrg/Makefile.am 2008-04-25 21:45:58 +0000
-+++ storage/myisammrg/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,16 +26,29 @@
- LDADD =
-
- DEFS = @DEFS@
--pkglib_LIBRARIES = libmyisammrg.a
-+pkglib_LTLIBRARIES = libmyisammrg.la
-+noinst_LTLIBRARIES = libmyisammrg_s.la libmyisammrg_common.la \
-+ @plugin_myisammrg_embedded_static_target@
-+EXTRA_LTLIBRARIES = libmyisammrg_embedded.la
- noinst_HEADERS = myrg_def.h ha_myisammrg.h
--noinst_LIBRARIES = libmyisammrg.a
--libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
-+libmyisammrg_common_la_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
- myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
- myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
- myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
- myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
-- ha_myisammrg.cc \
- myrg_rnext_same.c myrg_records.c
-+libmyisammrg_common_la_CFLAGS = $(AM_CFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_s_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libmyisammrg_s_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_SOURCES = ha_myisammrg.cc
-+libmyisammrg_embedded_la_CFLAGS = $(AM_CFLAGS) @plugin_embedded_defs@
-+libmyisammrg_embedded_la_LIBADD = libmyisammrg_common.la
-+libmyisammrg_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libmyisammrg_la_SOURCES =
-+libmyisammrg_la_LIBADD = libmyisammrg_s.la
-+libmyisammrg_la_LDFLAGS = -static
-+
-
-
- EXTRA_DIST = CMakeLists.txt plug.in
-
-=== modified file 'storage/myisammrg/plug.in'
---- storage/myisammrg/plug.in 2006-10-18 12:03:37 +0000
-+++ storage/myisammrg/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,6 +1,5 @@
- MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
- [Merge multiple MySQL tables into one])
- MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
--MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
-+MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg_s.la], [libmyisammrg_embedded.la])
- MYSQL_PLUGIN_MANDATORY(myisammrg)
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(myisammrg, [ha_myisammrg.cc])
-
-=== modified file 'storage/ndb/src/common/util/Makefile.am'
---- storage/ndb/src/common/util/Makefile.am 2010-04-01 11:19:15 +0000
-+++ storage/ndb/src/common/util/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -31,9 +31,9 @@
- testBitmask_SOURCES = testBitmask.cpp
- testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testBitmask.cpp : Bitmask.cpp
- rm -f testBitmask.cpp
-
-=== modified file 'storage/ndb/src/cw/cpcd/Makefile.am'
---- storage/ndb/src/cw/cpcd/Makefile.am 2007-02-13 01:38:54 +0000
-+++ storage/ndb/src/cw/cpcd/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,9 +19,9 @@
-
- LDADD_LOC = \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_util.mk.am
-
-=== modified file 'storage/ndb/src/kernel/Makefile.am'
---- storage/ndb/src/kernel/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -53,9 +53,9 @@
- $(top_builddir)/storage/ndb/src/mgmapi/libmgmapi.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- windoze-dsp: ndbd.dsp
-
-
-=== modified file 'storage/ndb/src/kernel/blocks/Makefile.am'
---- storage/ndb/src/kernel/blocks/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -57,9 +57,9 @@
- ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp
- ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/backup/Makefile.am'
---- storage/ndb/src/kernel/blocks/backup/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/backup/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,9 @@
- ndb_print_backup_file_SOURCES = read.cpp
- ndb_print_backup_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
- include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbdict/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,17 +19,17 @@
- LDADD += \
- $(top_builddir)/storage/ndb/src/common/util/libgeneral.la \
- $(top_builddir)/storage/ndb/src/common/portlib/libportlib.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- ndbtools_PROGRAMS = ndb_print_schema_file
- ndb_print_schema_file_SOURCES = printSchemaFile.cpp
- ndb_print_schema_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbdih/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,9 @@
- ndb_print_sys_file_SOURCES = printSysfile.cpp
- ndb_print_sys_file_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
- include $(top_srcdir)/storage/ndb/config/common.mk.am
-
-=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Makefile.am'
---- storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2007-05-29 21:39:57 +0000
-+++ storage/ndb/src/kernel/blocks/dblqh/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -23,9 +23,9 @@
-
- ndbd_redo_log_reader_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/blocks/dbtup/Makefile.am'
---- storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/blocks/dbtup/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -20,9 +20,9 @@
- test_varpage_SOURCES = test_varpage.cpp tuppage.cpp
- test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/src/kernel/vm/Makefile.am'
---- storage/ndb/src/kernel/vm/Makefile.am 2006-12-31 00:32:21 +0000
-+++ storage/ndb/src/kernel/vm/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -65,24 +65,24 @@
- ndbd_malloc_impl_test_SOURCES = ndbd_malloc_impl.cpp
- ndbd_malloc_impl_test_LDFLAGS = @ndb_bin_am_ldflags@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- bench_pool_SOURCES = bench_pool.cpp
- bench_pool_LDFLAGS = @ndb_bin_am_ldflags@\
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- testDynArr256_CXXFLAGS = -DUNIT_TEST
- testDynArr256_SOURCES = DynArr256.cpp
- testDynArr256_LDFLAGS = @ndb_bin_am_ldflags@ \
- libkernel.a ../error/liberror.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la
-
-
-=== modified file 'storage/ndb/src/mgmclient/Makefile.am'
---- storage/ndb/src/mgmclient/Makefile.am 2007-08-01 07:24:01 +0000
-+++ storage/ndb/src/mgmclient/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -37,9 +37,9 @@
- ../common/portlib/libportlib.la \
- @readline_link@ \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @TERMCAP_LIB@ @NDB_SCI_LIBS@
-
- ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
-
-=== modified file 'storage/ndb/src/mgmsrv/Makefile.am'
---- storage/ndb/src/mgmsrv/Makefile.am 2009-07-31 19:28:15 +0000
-+++ storage/ndb/src/mgmsrv/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -40,9 +40,9 @@
-
- LDADD_LOC = $(top_builddir)/storage/ndb/src/mgmclient/CommandInterpreter.lo \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la \
- @readline_link@ \
- @NDB_SCI_LIBS@ \
- @TERMCAP_LIB@
-
-=== modified file 'storage/ndb/src/ndbapi/Makefile.am'
---- storage/ndb/src/ndbapi/Makefile.am 2007-04-11 13:51:09 +0000
-+++ storage/ndb/src/ndbapi/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -67,9 +67,9 @@
- include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
-
- ndberror_check_LDFLAGS = \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-
-=== modified file 'storage/ndb/test/run-test/Makefile.am'
---- storage/ndb/test/run-test/Makefile.am 2009-10-13 18:21:42 +0000
-+++ storage/ndb/test/run-test/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -34,9 +34,9 @@
- INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/test/include
- LDADD_LOC = $(top_builddir)/storage/ndb/test/src/libNDBT.a \
- $(top_builddir)/storage/ndb/src/libndbclient.la \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/strings/libmystrings.la @NDB_SCI_LIBS@
-
- atrt_CXXFLAGS = -I$(top_srcdir)/ndb/src/mgmapi \
- -I$(top_srcdir)/ndb/src/mgmsrv \
-
-=== modified file 'storage/pbxt/plug.in'
---- storage/pbxt/plug.in 2009-12-09 21:39:23 +0000
-+++ storage/pbxt/plug.in 2010-09-16 12:49:35 +0000
-@@ -1,8 +1,7 @@
- MYSQL_STORAGE_ENGINE(pbxt,no, [PBXT Storage Engine],
- [MVCC-based transactional engine], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(pbxt, [storage/pbxt])
--MYSQL_PLUGIN_STATIC(pbxt, [src/libpbxt.a])
-+MYSQL_PLUGIN_STATIC(pbxt, [src/libpbxt_s.la], [src/libpbxt_s_embedded.la])
- MYSQL_PLUGIN_ACTIONS(pbxt, [
- # AC_CONFIG_FILES(storage/pbxt/src/Makefile)
- ])
--MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(pbxt, [[src/ha_pbxt.cc],[src/myxt_xt.cc],[src/discover_xt.cc]])
-
-=== modified file 'storage/pbxt/src/Makefile.am'
---- storage/pbxt/src/Makefile.am 2009-12-22 10:33:20 +0000
-+++ storage/pbxt/src/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -26,25 +26,33 @@
- pbms.h xt_config.h xt_defs.h xt_errno.h locklist_xt.h
- EXTRA_LTLIBRARIES = libpbxt.la
-
--libpbxt_la_SOURCES = bsearch_xt.cc cache_xt.cc ccutils_xt.cc database_xt.cc \
-+non_mysql_internal_sources = bsearch_xt.cc cache_xt.cc ccutils_xt.cc database_xt.cc \
- datadic_xt.cc datalog_xt.cc filesys_xt.cc hashtab_xt.cc \
-- ha_pbxt.cc heap_xt.cc index_xt.cc linklist_xt.cc \
-- memory_xt.cc myxt_xt.cc pthread_xt.cc restart_xt.cc \
-+ heap_xt.cc index_xt.cc linklist_xt.cc \
-+ memory_xt.cc pthread_xt.cc restart_xt.cc \
- sortedlist_xt.cc strutil_xt.cc \
- tabcache_xt.cc table_xt.cc trace_xt.cc thread_xt.cc \
-- systab_xt.cc ha_xtsys.cc discover_xt.cc backup_xt.cc \
-+ systab_xt.cc ha_xtsys.cc backup_xt.cc \
- util_xt.cc xaction_xt.cc xactlog_xt.cc lock_xt.cc locklist_xt.cc
--
--libpbxt_la_LDFLAGS = -module
-+mysql_internal_sources = ha_pbxt.cc myxt_xt.cc discover_xt.cc
-+libpbxt_la_SOURCES = $(non_mysql_internal_sources) $(mysql_internal_sources)
-
- # These are the warning Drizzle uses:
- # DRIZZLE_WARNINGS = -W -Wall -Wextra -pedantic -Wundef -Wredundant-decls -Wno-strict-aliasing -Wno-long-long -Wno-unused-parameter
-
- libpbxt_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
- libpbxt_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN -std=c99
--
--EXTRA_LIBRARIES = libpbxt.a
--noinst_LIBRARIES = libpbxt.a
--libpbxt_a_SOURCES = $(libpbxt_la_SOURCES)
-+libpbxt_la_LDFLAGS = -module
-+
-+noinst_LTLIBRARIES = libpbxt_s.la libpbxt_s_embedded.la libpbxt_s_common.la
-+
-+libpbxt_s_common_la_SOURCES = $(non_mysql_internal_sources)
-+libpbxt_s_common_la_CXXFLAGS = @plugin_static_if_no_embedded@
-+libpbxt_s_la_SOURCES = $(mysql_internal_sources)
-+libpbxt_s_la_CXXFLAGS = @plugin_static_if_no_embedded@
-+libpbxt_s_la_LIBADD = libpbxt_s_common.la
-+libpbxt_s_embedded_la_SOURCES = $(mysql_internal_sources)
-+libpbxt_s_embedded_la_CXXFLAGS = $(AM_CXXFLAGS) @plugin_embedded_defs@
-+libpbxt_s_embedded_la_LIBADD = libpbxt_s_common.la
-
- EXTRA_DIST = pbms_enabled.cc win_inttypes.h
-
-=== modified file 'storage/xtradb/Makefile.am'
---- storage/xtradb/Makefile.am 2010-08-04 08:39:53 +0000
-+++ storage/xtradb/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -229,9 +229,8 @@
- handler/innodb_patch_info.h \
- mem/mem0dbg.c
-
--EXTRA_LIBRARIES= libxtradb.a
--noinst_LIBRARIES= @plugin_xtradb_static_target@
--libxtradb_a_SOURCES= \
-+noinst_LTLIBRARIES= @plugin_xtradb_static_target@
-+libxtradb_la_SOURCES= \
- btr/btr0btr.c \
- btr/btr0cur.c \
- btr/btr0pcur.c \
-@@ -326,10 +325,10 @@
- ut/ut0vec.c \
- ut/ut0wqueue.c
-
--libxtradb_a_CXXFLAGS= $(AM_CXXFLAGS)
--libxtradb_a_CFLAGS= $(AM_CFLAGS)
-+libxtradb_la_CXXFLAGS= $(AM_CXXFLAGS) @plugin_static_if_no_embedded@
-+libxtradb_la_CFLAGS= $(AM_CFLAGS) @plugin_static_if_no_embedded@
-
--EXTRA_LTLIBRARIES= ha_xtradb.la
-+EXTRA_LTLIBRARIES= libxtradb.la ha_xtradb.la
- pkgplugin_LTLIBRARIES= @plugin_xtradb_shared_target@
-
- ha_xtradb_la_LDFLAGS= -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices
-=== modified file 'storage/xtradb/plug.in'
---- storage/xtradb/plug.in 2010-08-04 08:39:53 +0000
-+++ storage/xtradb/plug.in 2010-09-16 12:49:35 +0000
-@@ -17,7 +17,7 @@
- MYSQL_STORAGE_ENGINE(xtradb, xtradb, [XtraDB Storage Engine],
- [XtraDB - a drop-in replacement for InnoDB], [max,max-no-ndb])
- MYSQL_PLUGIN_DIRECTORY(xtradb, [storage/xtradb])
--MYSQL_PLUGIN_STATIC(xtradb, [libxtradb.a])
-+MYSQL_PLUGIN_STATIC(xtradb, [libxtradb.la])
- MYSQL_PLUGIN_DYNAMIC(xtradb, [ha_xtradb.la])
- MYSQL_PLUGIN_ACTIONS(xtradb, [
- with_plugin_innobase=$with_plugin_xtradb # for legacy code in configure.in
-
-=== modified file 'strings/Makefile.am'
---- strings/Makefile.am 2010-08-27 14:12:44 +0000
-+++ strings/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,7 +16,7 @@
- # This file is public domain and comes with NO WARRANTY of any kind
-
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
--pkglib_LIBRARIES = libmystrings.a
-+pkglib_LTLIBRARIES = libmystrings.la
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
-@@ -37,7 +37,7 @@
- endif
- endif
-
--libmystrings_a_SOURCES = $(ASRCS) $(CSRCS)
-+libmystrings_la_SOURCES = $(ASRCS) $(CSRCS)
- noinst_PROGRAMS = conf_to_src
- CLEANFILES = str_test uctypedump test_decimal
- # Default charset definitions
-@@ -56,9 +56,10 @@
- t_ctype.h my_strchr.c CMakeLists.txt \
- CHARSET_INFO.txt strmov_overlapp.c
-
--libmystrings_a_LIBADD=
--conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
--conf_to_src_LDADD=
-+libmystrings_la_LIBADD=
-+conf_to_src_SOURCES = conf_to_src.c
-+conf_to_src_LDADD = libmystrings.la
-+
- #force static linking of conf_to_src - essential when linking against
- #custom installation of libc
- conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
-@@ -69,13 +70,13 @@
-
- FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
-
--str_test: str_test.c $(pkglib_LIBRARIES)
-- $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LIBRARIES)
-+str_test: str_test.c $(pkglib_LTLIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN $(INCLUDES) $(srcdir)/str_test.c $(LDADD) $(pkglib_LTLIBRARIES)
-
- uctypedump: uctypedump.c
- $(LINK) $(INCLUDES) $(srcdir)/uctypedump.c
-
- test_decimal$(EXEEXT): decimal.c $(pkglib_LIBRARIES)
- $(CP) $(srcdir)/decimal.c ./test_decimal.c
-- $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LIBRARIES)
-+ $(LINK) $(FLAGS) -DMAIN ./test_decimal.c $(LDADD) $(pkglib_LTLIBRARIES)
- $(RM) -f ./test_decimal.c
-
-=== modified file 'unittest/unit.pl'
---- unittest/unit.pl 2010-09-25 20:28:51.813336741 +0000
-+++ unittest/unit.pl 2010-09-25 20:29:58.156670013 +0000
-@@ -65,7 +65,7 @@
- my @dirs = @_;
- my @files;
- find sub {
-- $File::Find::prune = 1 if /^SCCS$/;
-+ $File::Find::prune = 1 if /^(SCCS|\.libs)$/;
- push(@files, $File::Find::name) if -x _ && (/-t\z/ || /-t\.exe\z/);
- }, @dirs;
- return @files;
-=== modified file 'unittest/mysys/Makefile.am'
---- unittest/mysys/Makefile.am 2010-08-27 14:12:44 +0000
-+++ unittest/mysys/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -19,9 +19,10 @@
- noinst_HEADERS = thr_template.c
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- EXTRA_DIST = CMakeLists.txt
- noinst_PROGRAMS = bitmap-t base64-t my_atomic-t lf-t waiting_threads-t \
-
-=== modified file 'unittest/strings/Makefile.am'
---- unittest/strings/Makefile.am 2010-07-26 05:06:18 +0000
-+++ unittest/strings/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -17,9 +17,10 @@
- AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
-
- LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
-- $(top_builddir)/mysys/libmysys.a \
-- $(top_builddir)/dbug/libdbug.a \
-- $(top_builddir)/strings/libmystrings.a
-+ $(top_builddir)/mysys/libmysys.la \
-+ $(top_builddir)/dbug/libdbug.la \
-+ $(top_builddir)/strings/libmystrings.la \
-+ $(ZLIB_LIBS)
-
- noinst_PROGRAMS = strings-t
-
-
-=== modified file 'vio/Makefile.am'
---- vio/Makefile.am 2010-08-27 14:12:44 +0000
-+++ vio/Makefile.am 2010-09-16 12:49:35 +0000
-@@ -16,10 +16,10 @@
- INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(openssl_includes)
- LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
--pkglib_LIBRARIES = libvio.a
-+pkglib_LTLIBRARIES = libvio.la
-
- noinst_HEADERS = vio_priv.h
-
--libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
-
- EXTRA_DIST= CMakeLists.txt
-
diff --git a/07010_all_rpl000015-portsobst-fix-4.1.23.patch b/07010_all_rpl000015-portsobst-fix-4.1.23.patch
deleted file mode 100644
index 38321ab..0000000
--- a/07010_all_rpl000015-portsobst-fix-4.1.23.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql/mysql-test/t/rpl000015.test 2007-01-01 20:44:14.000000000 +0100
-+++ mysql.new/mysql-test/t/rpl000015.test 2007-01-02 10:58:38.000000000 +0100
-@@ -12,7 +12,7 @@
-
- change master to master_host='127.0.0.1';
- # The following needs to be cleaned up when change master is fixed
----replace_result $MASTER_MYPORT MASTER_PORT $MYSQL_TCP_PORT MASTER_PORT
-+--replace_result $MASTER_MYPORT MASTER_PORT $MYSQL_TCP_PORT MASTER_PORT 3306 MASTER_PORT
- --replace_column 1 # 8 # 9 # 23 # 33 #
- show slave status;
- --replace_result $MASTER_MYPORT MASTER_PORT
diff --git a/07010_all_rpl000015-portsobst-fix-5.0.26.patch b/07010_all_rpl000015-portsobst-fix-5.0.26.patch
deleted file mode 100644
index fc19897..0000000
--- a/07010_all_rpl000015-portsobst-fix-5.0.26.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- mysql-old/mysql-test/t/rpl000015.test 2006-04-18 23:11:26.000000000 +0200
-+++ mysql-new/mysql-test/t/rpl000015.test 2006-04-18 23:11:44.000000000 +0200
-@@ -12,7 +12,7 @@
-
- change master to master_host='127.0.0.1';
- # The following needs to be cleaned up when change master is fixed
----replace_result $MYSQL_TCP_PORT MASTER_PORT
-+--replace_result $MYSQL_TCP_PORT MASTER_PORT 3306 MASTER_PORT
- --replace_column 1 # 8 # 9 # 23 # 33 #
- show slave status;
- --replace_result $MASTER_MYPORT MASTER_PORT
diff --git a/07020_all_trigger-rename-fail-as-root-5.0.26.patch b/07020_all_trigger-rename-fail-as-root-5.0.26.patch
deleted file mode 100644
index 10fce8b..0000000
--- a/07020_all_trigger-rename-fail-as-root-5.0.26.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff -ur mysql-5.0.orig/mysql-test/r/trigger.result mysql-5.0/mysql-test/r/trigger.result
---- mysql-5.0.orig/mysql-test/r/trigger.result Mon Oct 9 15:22:07 2006
-+++ mysql-5.0/mysql-test/r/trigger.result Tue Oct 10 11:59:22 2006
-@@ -969,7 +969,7 @@
- test t1_bi test t1 set @a:=new.id
- test t1_ai test t1 set @b:=new.id
- rename table t1 to t2;
--ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 13)
-+ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 21)
- insert into t1 values (102);
- select @a, @b;
- @a @b
-diff -ur mysql-5.0.orig/mysql-test/t/trigger.test mysql-5.0/mysql-test/t/trigger.test
---- mysql-5.0.orig/mysql-test/t/trigger.test Mon Oct 9 15:22:07 2006
-+++ mysql-5.0/mysql-test/t/trigger.test Tue Oct 10 11:58:55 2006
-@@ -1138,8 +1138,7 @@
- event_object_table, action_statement from information_schema.triggers
- where event_object_schema = 'test';
- # Trick which makes update of second .TRN file impossible
--system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
--system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-+system mkdir $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
- --error 1
- rename table t1 to t2;
- # 't1' should be still there and triggers should work correctly
-@@ -1148,8 +1147,7 @@
- select trigger_schema, trigger_name, event_object_schema,
- event_object_table, action_statement from information_schema.triggers
- where event_object_schema = 'test';
--system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
--system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-+system rmdir $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
- # Let us check that updates to .TRN files were rolled back too
- drop trigger t1_bi;
- drop trigger t1_ai;
diff --git a/07020_all_trigger-rename-fail-as-root-5.0.34.patch b/07020_all_trigger-rename-fail-as-root-5.0.34.patch
deleted file mode 100644
index e7d7832..0000000
--- a/07020_all_trigger-rename-fail-as-root-5.0.34.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff -ur mysql-5.0.orig/mysql-test/r/trigger.result mysql-5.0/mysql-test/r/trigger.result
---- mysql-5.0.orig/mysql-test/r/trigger.result Mon Oct 9 15:22:07 2006
-+++ mysql-5.0/mysql-test/r/trigger.result Tue Oct 10 11:59:22 2006
-@@ -969,7 +969,7 @@
- test t1_bi test t1 set @a:=new.id
- test t1_ai test t1 set @b:=new.id
- rename table t1 to t2;
--ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 13)
-+ERROR HY000: Can't create/write to file './test/t1_ai.TRN~' (Errcode: 21)
- insert into t1 values (102);
- select @a, @b;
- @a @b
-diff -ur mysql-5.0.orig/mysql-test/t/trigger.test mysql-5.0/mysql-test/t/trigger.test
---- mysql-5.0.orig/mysql-test/t/trigger.test Mon Oct 9 15:22:07 2006
-+++ mysql-5.0/mysql-test/t/trigger.test Tue Oct 10 11:58:55 2006
-@@ -1138,8 +1138,7 @@
- event_object_table, action_statement from information_schema.triggers
- where event_object_schema = 'test';
- # Trick which makes update of second .TRN file impossible
--system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
--system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-+system mkdir $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
- --replace_result $MYSQLTEST_VARDIR . master-data/ ''
- --error 1
- rename table t1 to t2;
-@@ -1148,8 +1147,7 @@
- select trigger_schema, trigger_name, event_object_schema,
- event_object_table, action_statement from information_schema.triggers
- where event_object_schema = 'test';
--system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
--system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-+system rmdir $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
- # Let us check that updates to .TRN files were rolled back too
- drop trigger t1_bi;
- drop trigger t1_ai;
diff --git a/07040_all_disable_mybug_9735_test.patch b/07040_all_disable_mybug_9735_test.patch
deleted file mode 100644
index b195e16..0000000
--- a/07040_all_disable_mybug_9735_test.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- mysql-5.0.30/tests/mysql_client_test.c 2006-11-23 21:13:06.000000000 +0100
-+++ mysql/tests/mysql_client_test.c 2006-12-28 18:57:40.000000000 +0100
-@@ -737,8 +737,8 @@
- fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)",
- field->org_table, org_table);
- fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db);
-- fprintf(stdout, "\n length :`%lu`\t(expected: `%lu`)",
-- field->length, length * cs->mbmaxlen);
-+ fprintf(stdout, "\n length :`%lu`\t(expected: `%lu * %lu = %lu`)",
-+ field->length, length, cs->mbmaxlen, length * cs->mbmaxlen);
- fprintf(stdout, "\n maxlength:`%ld`", field->max_length);
- fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr);
- fprintf(stdout, "\n default :`%s`\t(expected: `%s`)",
-@@ -13798,7 +13798,7 @@
- }
-
- /* Test correct max length for MEDIUMTEXT and LONGTEXT columns */
--
-+/* TODO: re-enable me */
- static void test_bug9735()
- {
- MYSQL_RES *res;
-@@ -15554,7 +15554,6 @@
- { "test_bug11172", test_bug11172 },
- { "test_bug11656", test_bug11656 },
- { "test_bug10214", test_bug10214 },
-- { "test_bug9735", test_bug9735 },
- { "test_bug11183", test_bug11183 },
- { "test_bug11037", test_bug11037 },
- { "test_bug10760", test_bug10760 },
diff --git a/07050_all_we-are-in-2007-now.patch b/07050_all_we-are-in-2007-now.patch
deleted file mode 100644
index 129ef12..0000000
--- a/07050_all_we-are-in-2007-now.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- mysql.old/mysql-test/r/view.result 2007-01-02 23:27:19.000000000 +0100
-+++ mysql/mysql-test/r/view.result 2007-01-02 23:27:58.000000000 +0100
-@@ -2686,12 +2686,12 @@
- v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75)
- SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
- Age
--42
--38
-+43
-+39
- SELECT * FROM v1;
- Age
--42
--38
-+43
-+39
- DROP VIEW v1;
- DROP TABLE t1;
- CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx');
diff --git a/07060_all_fix-nullpointer-dos.patch b/07060_all_fix-nullpointer-dos.patch
deleted file mode 100644
index 1511768..0000000
--- a/07060_all_fix-nullpointer-dos.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-Gentoo bug #171934
-MySQL bug #27513
-
-diff -Naur mysql-5.0.38/libmysqld/item_cmpfunc.cc mysql-5.0.38-patched/libmysqld/item_cmpfunc.cc
---- mysql-5.0.38/libmysqld/item_cmpfunc.cc 2007-03-20 20:12:46.000000000 +0100
-+++ mysql-5.0.38-patched/libmysqld/item_cmpfunc.cc 2007-04-12 20:41:32.000000000 +0200
-@@ -2423,7 +2423,7 @@
- dec->len= DECIMAL_BUFF_LENGTH;
- dec->fix_buffer_pointer();
- my_decimal *res= item->val_decimal(dec);
-- if (res != dec)
-+ if (!item->null_value && res != dec)
- my_decimal2decimal(res, dec);
- }
-
-diff -Naur mysql-5.0.38/sql/item_cmpfunc.cc mysql-5.0.38-patched/sql/item_cmpfunc.cc
---- mysql-5.0.38/sql/item_cmpfunc.cc 2007-03-20 20:12:46.000000000 +0100
-+++ mysql-5.0.38-patched/sql/item_cmpfunc.cc 2007-04-12 20:41:36.000000000 +0200
-@@ -2423,7 +2423,7 @@
- dec->len= DECIMAL_BUFF_LENGTH;
- dec->fix_buffer_pointer();
- my_decimal *res= item->val_decimal(dec);
-- if (res != dec)
-+ if (!item->null_value && res != dec)
- my_decimal2decimal(res, dec);
- }
-
diff --git a/07070_all_fix-nullpointer-dos-testcase.patch b/07070_all_fix-nullpointer-dos-testcase.patch
deleted file mode 100644
index fd5f374..0000000
--- a/07070_all_fix-nullpointer-dos-testcase.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From: kgeorge
-Date: April 3 2007 5:01pm
-Subject: bk commit into 5.0 tree (gkodinov:1.2432) BUG#27513
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of kgeorge. When kgeorge does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-04-03 18:00:57+03:00, gkodinov@stripped +2 -0
- Bug #27513: test case added to make sure this
- crash bug doesn't reappear.
-
- mysql-test/r/errors.result@stripped, 2007-04-03 18:00:55+03:00, gkodinov@stripped +18 -0
- Bug #27513: test case
-
- mysql-test/t/errors.test@stripped, 2007-04-03 18:00:55+03:00, gkodinov@stripped +11 -0
- Bug #27513: test case
-
-# This is a BitKeeper patch. What follows are the unified diffs for the
-# set of deltas contained in the patch. The rest of the patch, the part
-# that BitKeeper cares about, is below these diffs.
-# User: gkodinov
-# Host: magare.gmz
-# Root: /home/kgeorge/mysql/work/B27513-5.0-opt
-
---- 1.9/mysql-test/r/errors.result 2005-08-12 18:04:47 +03:00
-+++ 1.10/mysql-test/r/errors.result 2007-04-03 18:00:55 +03:00
-@@ -28,3 +28,21 @@ ERROR 42000: Display width out of range
- set sql_mode='traditional';
- create table t1 (a varchar(66000));
- ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
-+CREATE TABLE t1 (a INT);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+a
-+Warnings:
-+Error 1365 Division by 0
-+INSERT INTO t1 VALUES(1);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+a
-+1
-+Warnings:
-+Error 1365 Division by 0
-+INSERT INTO t1 VALUES(2),(3);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+a
-+1
-+Warnings:
-+Error 1365 Division by 0
-+DROP TABLE t1;
-
---- 1.15/mysql-test/t/errors.test 2005-08-12 18:04:48 +03:00
-+++ 1.16/mysql-test/t/errors.test 2007-04-03 18:00:55 +03:00
-@@ -41,4 +41,15 @@ set sql_mode='traditional';
- --error 1074
- create table t1 (a varchar(66000));
-
-+#
-+# Bug #27513: mysql 5.0.x + NULL pointer DoS
-+#
-+CREATE TABLE t1 (a INT);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+INSERT INTO t1 VALUES(1);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+INSERT INTO t1 VALUES(2),(3);
-+SELECT a FROM t1 WHERE a IN(1, (SELECT IF(1=0,1,2/0)));
-+DROP TABLE t1;
-+
- # End of 5.0 tests
diff --git a/07080_all_mysql_client_test-fix-pointer-aliasing-mysqlbug27383.patch b/07080_all_mysql_client_test-fix-pointer-aliasing-mysqlbug27383.patch
deleted file mode 100644
index e17d113..0000000
--- a/07080_all_mysql_client_test-fix-pointer-aliasing-mysqlbug27383.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-Gentoo-Bug: 160284
-MySQL-Bug: 27383
-Upstream-fix: http://lists.mysql.com/commits/29168
-
---- libmysql/libmysql-old.c 2007-06-21 11:59:51.000000000 +0000
-+++ libmysql/libmysql.c 2007-06-21 11:54:31.000000000 +0000
-@@ -3670,28 +3670,28 @@
- (See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 for details)
- AFAIU it does not guarantee to work.
- */
-- float data;
-+ volatile float data;
- if (is_unsigned)
- data= (float) ulonglong2double(value);
- else
- data= (float) value;
- floatstore(buffer, data);
- *param->error= is_unsigned ?
-- ((ulonglong) value) != ((ulonglong) (*(float*) buffer)) :
-- ((longlong) value) != ((longlong) (*(float*) buffer));
-+ ((ulonglong) value) != ((ulonglong) data) :
-+ ((longlong) value) != ((longlong) data);
- break;
- }
- case MYSQL_TYPE_DOUBLE:
- {
-- double data;
-+ volatile double data;
- if (is_unsigned)
- data= ulonglong2double(value);
- else
- data= (double)value;
- doublestore(buffer, data);
- *param->error= is_unsigned ?
-- ((ulonglong) value) != ((ulonglong) (*(double*) buffer)) :
-- ((longlong) value) != ((longlong) (*(double*) buffer));
-+ ((ulonglong) value) != ((ulonglong) data) :
-+ ((longlong) value) != ((longlong) data);
- break;
- }
- case MYSQL_TYPE_TIME:
-@@ -3754,60 +3754,65 @@
- Sic: AFAIU it does not guarantee to work.
- */
- if (param->is_unsigned)
-- *buffer= (uint8) value;
-+ {
-+ volatile uint8 data= (uint8) value;
-+ *buffer= data;
-+ *param->error= val64 != data;
-+ }
- else
-- *buffer= (int8) value;
-- *param->error= val64 != (param->is_unsigned ? (double)((uint8) *buffer) :
-- (double)((int8) *buffer));
-+ {
-+ volatile int8 data= (int8) value;
-+ *buffer= data;
-+ *param->error= val64 != data;
-+ }
- break;
- case MYSQL_TYPE_SHORT:
- if (param->is_unsigned)
- {
-- ushort data= (ushort) value;
-+ volatile ushort data= (ushort) value;
- shortstore(buffer, data);
-+ *param->error= val64 != (double) data;
- }
- else
- {
-- short data= (short) value;
-+ volatile short data= (short) value;
- shortstore(buffer, data);
-+ *param->error= val64 != (double) data;
- }
-- *param->error= val64 != (param->is_unsigned ? (double) (*(ushort*) buffer):
-- (double) (*(short*) buffer));
- break;
- case MYSQL_TYPE_LONG:
- if (param->is_unsigned)
- {
-- uint32 data= (uint32) value;
-+ volatile uint32 data= (uint32) value;
- longstore(buffer, data);
-+ *param->error= val64 != (double) data;
- }
- else
- {
-- int32 data= (int32) value;
-+ volatile int32 data= (int32) value;
- longstore(buffer, data);
-+ *param->error= val64 != (double) data;
- }
-- *param->error= val64 != (param->is_unsigned ? (double) (*(uint32*) buffer):
-- (double) (*(int32*) buffer));
-- break;
-+ break;
- case MYSQL_TYPE_LONGLONG:
- if (param->is_unsigned)
- {
-- ulonglong data= (ulonglong) value;
-+ volatile ulonglong data= (ulonglong) value;
- longlongstore(buffer, data);
-+ *param->error= val64 != ulonglong2double(data);
- }
- else
- {
-- longlong data= (longlong) value;
-+ volatile longlong data= (longlong) value;
- longlongstore(buffer, data);
-+ *param->error= val64 != (double) data;
- }
-- *param->error= val64 != (param->is_unsigned ?
-- ulonglong2double(*(ulonglong*) buffer) :
-- (double) (*(longlong*) buffer));
- break;
- case MYSQL_TYPE_FLOAT:
- {
-- float data= (float) value;
-+ volatile float data= (float) value;
- floatstore(buffer, data);
-- *param->error= (*(float*) buffer) != value;
-+ *param->error= data != value;
- break;
- }
- case MYSQL_TYPE_DOUBLE:
diff --git a/07090_all_innodb_spatial_crash_mybug_32125_5.0.patch b/07090_all_innodb_spatial_crash_mybug_32125_5.0.patch
deleted file mode 100644
index 7897039..0000000
--- a/07090_all_innodb_spatial_crash_mybug_32125_5.0.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-diff -ru innobase/include/db0err.h.orig innobase/include/db0err.h
---- innobase/include/db0err.h.orig 2007-07-04 16:06:59.000000000 +0300
-+++ innobase/include/db0err.h 2007-11-15 10:23:51.000000000 +0200
-@@ -57,6 +57,18 @@
- buffer pool (for big transactions,
- InnoDB stores the lock structs in the
- buffer pool) */
-+#define DB_FOREIGN_DUPLICATE_KEY 46 /* foreign key constraints
-+ activated by the operation would
-+ lead to a duplicate key in some
-+ table */
-+#define DB_TOO_MANY_CONCURRENT_TRXS 47 /* when InnoDB runs out of the
-+ preconfigured undo slots, this can
-+ only happen when there are too many
-+ concurrent transactions */
-+#define DB_UNSUPPORTED 48 /* when InnoDB sees any artefact or
-+ a feature that it can't recoginize or
-+ work with e.g., FT indexes created by
-+ a later version of the engine. */
-
- /* The following are partial failure codes */
- #define DB_FAIL 1000
-diff -ru innobase/include/page0cur.h.orig innobase/include/page0cur.h
---- innobase/include/page0cur.h.orig 2007-07-04 16:06:10.000000000 +0300
-+++ innobase/include/page0cur.h 2007-11-15 10:23:51.000000000 +0200
-@@ -22,6 +22,7 @@
-
- /* Page cursor search modes; the values must be in this order! */
-
-+#define PAGE_CUR_UNSUPP 0
- #define PAGE_CUR_G 1
- #define PAGE_CUR_GE 2
- #define PAGE_CUR_L 3
-diff -ru sql/ha_innodb.cc.orig sql/ha_innodb.cc
---- sql/ha_innodb.cc.orig 2007-07-04 16:06:48.000000000 +0300
-+++ sql/ha_innodb.cc 2007-11-15 10:25:55.000000000 +0200
-@@ -526,6 +526,9 @@
- }
-
- return(HA_ERR_LOCK_TABLE_FULL);
-+ } else if (error == DB_UNSUPPORTED) {
-+
-+ return(HA_ERR_UNSUPPORTED);
- } else {
- return(-1); // Unknown error
- }
-@@ -3689,11 +3692,21 @@
- and comparison of non-latin1 char type fields in
- innobase_mysql_cmp() to get PAGE_CUR_LE_OR_EXTENDS to
- work correctly. */
--
-- default: assert(0);
-+ case HA_READ_MBR_CONTAIN:
-+ case HA_READ_MBR_INTERSECT:
-+ case HA_READ_MBR_WITHIN:
-+ case HA_READ_MBR_DISJOINT:
-+ my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0));
-+ return(PAGE_CUR_UNSUPP);
-+ /* do not use "default:" in order to produce a gcc warning:
-+ enumeration value '...' not handled in switch
-+ (if -Wswitch or -Wall is used)
-+ */
- }
-
-- return(0);
-+ my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "this functionality");
-+
-+ return(PAGE_CUR_UNSUPP);
- }
-
- /*
-@@ -3831,11 +3844,18 @@
-
- last_match_mode = (uint) match_mode;
-
-- innodb_srv_conc_enter_innodb(prebuilt->trx);
-+ if (mode != PAGE_CUR_UNSUPP) {
-
-- ret = row_search_for_mysql((byte*) buf, mode, prebuilt, match_mode, 0);
-+ innodb_srv_conc_enter_innodb(prebuilt->trx);
-
-- innodb_srv_conc_exit_innodb(prebuilt->trx);
-+ ret = row_search_for_mysql((byte*) buf, mode, prebuilt,
-+ match_mode, 0);
-+
-+ innodb_srv_conc_exit_innodb(prebuilt->trx);
-+ } else {
-+
-+ ret = DB_UNSUPPORTED;
-+ }
-
- if (ret == DB_SUCCESS) {
- error = 0;
-@@ -5150,8 +5170,16 @@
- mode2 = convert_search_mode_to_innobase(max_key ? max_key->flag :
- HA_READ_KEY_EXACT);
-
-- n_rows = btr_estimate_n_rows_in_range(index, range_start,
-- mode1, range_end, mode2);
-+ if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) {
-+
-+ n_rows = btr_estimate_n_rows_in_range(index, range_start,
-+ mode1, range_end,
-+ mode2);
-+ } else {
-+
-+ n_rows = 0;
-+ }
-+
- dtuple_free_for_mysql(heap1);
- dtuple_free_for_mysql(heap2);
-
diff --git a/07090_all_innodb_spatial_crash_mybug_32125_5.1.patch b/07090_all_innodb_spatial_crash_mybug_32125_5.1.patch
deleted file mode 100644
index e8df593..0000000
--- a/07090_all_innodb_spatial_crash_mybug_32125_5.1.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-diff -ur storage/innobase.orig/handler/ha_innodb.cc storage/innobase/handler/ha_innodb.cc
---- storage/innobase.orig/handler/ha_innodb.cc 2007-10-11 14:41:50.000000000 +0300
-+++ storage/innobase/handler/ha_innodb.cc 2007-11-14 14:43:52.000000000 +0200
-@@ -678,6 +678,9 @@
- return(HA_ERR_RECORD_FILE_FULL);
- #endif
-
-+ } else if (error == DB_UNSUPPORTED) {
-+
-+ return(HA_ERR_UNSUPPORTED);
- } else {
- return(-1); // Unknown error
- }
-@@ -3974,11 +3977,21 @@
- and comparison of non-latin1 char type fields in
- innobase_mysql_cmp() to get PAGE_CUR_LE_OR_EXTENDS to
- work correctly. */
--
-- default: assert(0);
-+ case HA_READ_MBR_CONTAIN:
-+ case HA_READ_MBR_INTERSECT:
-+ case HA_READ_MBR_WITHIN:
-+ case HA_READ_MBR_DISJOINT:
-+ my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0));
-+ return(PAGE_CUR_UNSUPP);
-+ /* do not use "default:" in order to produce a gcc warning:
-+ enumeration value '...' not handled in switch
-+ (if -Wswitch or -Wall is used)
-+ */
- }
-
-- return(0);
-+ my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "this functionality");
-+
-+ return(PAGE_CUR_UNSUPP);
- }
-
- /*
-@@ -4106,11 +4119,18 @@
-
- last_match_mode = (uint) match_mode;
-
-- innodb_srv_conc_enter_innodb(prebuilt->trx);
-+ if (mode != PAGE_CUR_UNSUPP) {
-
-- ret = row_search_for_mysql((byte*) buf, mode, prebuilt, match_mode, 0);
-+ innodb_srv_conc_enter_innodb(prebuilt->trx);
-
-- innodb_srv_conc_exit_innodb(prebuilt->trx);
-+ ret = row_search_for_mysql((byte*) buf, mode, prebuilt,
-+ match_mode, 0);
-+
-+ innodb_srv_conc_exit_innodb(prebuilt->trx);
-+ } else {
-+
-+ ret = DB_UNSUPPORTED;
-+ }
-
- if (ret == DB_SUCCESS) {
- error = 0;
-@@ -5460,8 +5480,16 @@
- mode2 = convert_search_mode_to_innobase(max_key ? max_key->flag :
- HA_READ_KEY_EXACT);
-
-- n_rows = btr_estimate_n_rows_in_range(index, range_start,
-- mode1, range_end, mode2);
-+ if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) {
-+
-+ n_rows = btr_estimate_n_rows_in_range(index, range_start,
-+ mode1, range_end,
-+ mode2);
-+ } else {
-+
-+ n_rows = 0;
-+ }
-+
- dtuple_free_for_mysql(heap1);
- dtuple_free_for_mysql(heap2);
-
-diff -ur storage/innobase.orig/include/page0cur.h storage/innobase/include/page0cur.h
---- storage/innobase.orig/include/page0cur.h 2007-06-22 10:31:32.000000000 +0300
-+++ storage/innobase/include/page0cur.h 2007-11-14 14:43:52.000000000 +0200
-@@ -22,6 +22,7 @@
-
- /* Page cursor search modes; the values must be in this order! */
-
-+#define PAGE_CUR_UNSUPP 0
- #define PAGE_CUR_G 1
- #define PAGE_CUR_GE 2
- #define PAGE_CUR_L 3
diff --git a/07100_all_respect_tmpdir_filesort_mybug_30287_5.0.patch b/07100_all_respect_tmpdir_filesort_mybug_30287_5.0.patch
deleted file mode 100644
index 154d22f..0000000
--- a/07100_all_respect_tmpdir_filesort_mybug_30287_5.0.patch
+++ /dev/null
@@ -1,128 +0,0 @@
-From: &lt;gshchepaDate: August 20 2007 10:39pm
-Subject: bk commit into 5.0 tree (gshchepa:1.2496) BUG#30287
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of uchum. When uchum does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-08-21 01:39:39+05:00, gshchepa@stripped +3 -0
- Fixed bug #30287.
- The server created temporary tables for filesort in the working directory
- instead of the specified tmpdir directory.
-
- sql/item.cc@stripped, 2007-08-21 01:09:20+05:00, gshchepa@stripped +2 -0
- Fixed bug #30287.
- The Item_field::set_field method has been modified to reset the any_privileges
- flag to false in case of system temporary table. This modification prevents the
- server from unnecessary checking of user privileges to access system temporary
- tables.
-
- sql/sql_select.cc@stripped, 2007-08-21 01:09:43+05:00, gshchepa@stripped +8 -11
- Fixed bug #30287.
- Bugfix for #29015 has been removed: TABLE_SHARE::table_name of system
- temporary tables contains full path to table file basename again.
-
- sql/sql_view.cc@stripped, 2007-08-21 01:09:50+05:00, gshchepa@stripped +6 -0
- Fixed bug #30287.
- Commentary has been added.
-
-diff -Nrup a/sql/item.cc b/sql/item.cc
---- a/sql/item.cc 2007-08-08 12:34:31 +05:00
-+++ b/sql/item.cc 2007-08-21 01:09:20 +05:00
-@@ -1765,6 +1765,8 @@ void Item_field::set_field(Field *field_
- unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
- collation.set(field_par->charset(), field_par->derivation());
- fixed= 1;
-+ if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
-+ any_privileges= 0;
- }
-
-
-diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
---- a/sql/sql_select.cc 2007-07-31 16:24:13 +05:00
-+++ b/sql/sql_select.cc 2007-08-21 01:09:43 +05:00
-@@ -9169,7 +9169,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- bool using_unique_constraint= 0;
- bool use_packed_rows= 0;
- bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
-- char *tmpname, *tmppath, path[FN_REFLEN], table_name[NAME_LEN+1];
-+ char *tmpname,path[FN_REFLEN];
- byte *pos,*group_buff;
- uchar *null_flags;
- Field **reg_field, **from_field, **default_field;
-@@ -9192,12 +9192,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- temp_pool_slot = bitmap_set_next(&temp_pool);
-
- if (temp_pool_slot != MY_BIT_NONE) // we got a slot
-- sprintf(table_name, "%s_%lx_%i", tmp_file_prefix,
-+ sprintf(path, "%s_%lx_%i", tmp_file_prefix,
- current_pid, temp_pool_slot);
- else
- {
- /* if we run out of slots or we are not using tempool */
-- sprintf(table_name, "%s%lx_%lx_%x", tmp_file_prefix,current_pid,
-+ sprintf(path,"%s%lx_%lx_%x", tmp_file_prefix,current_pid,
- thd->thread_id, thd->tmp_table++);
- }
-
-@@ -9205,8 +9205,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- No need to change table name to lower case as we are only creating
- MyISAM or HEAP tables here
- */
-- fn_format(path, table_name, mysql_tmpdir, "",
-- MY_REPLACE_EXT|MY_UNPACK_FILENAME);
-+ fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
-+
-
- if (group)
- {
-@@ -9251,8 +9251,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- sizeof(*key_part_info)*(param->group_parts+1),
- &param->start_recinfo,
- sizeof(*param->recinfo)*(field_count*2+4),
-- &tmppath, (uint) strlen(path)+1,
-- &tmpname, (uint) strlen(table_name)+1,
-+ &tmpname, (uint) strlen(path)+1,
- &group_buff, group && ! using_unique_constraint ?
- param->group_length : 0,
- NullS))
-@@ -9270,8 +9269,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- DBUG_RETURN(NULL); /* purecov: inspected */
- }
- param->items_to_copy= copy_func;
-- strmov(tmppath, path);
-- strmov(tmpname, table_name);
-+ strmov(tmpname,path);
- /* make table according to fields */
-
- bzero((char*) table,sizeof(*table));
-@@ -9297,8 +9295,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
-
- table->s= &table->share_not_to_be_used;
- table->s->blob_field= blob_field;
-- table->s->table_name= tmpname;
-- table->s->path= tmppath;
-+ table->s->table_name= table->s->path= tmpname;
- table->s->db= "";
- table->s->blob_ptr_size= mi_portable_sizeof_char_ptr;
- table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
-diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
---- a/sql/sql_view.cc 2007-07-12 23:26:39 +05:00
-+++ b/sql/sql_view.cc 2007-08-21 01:09:50 +05:00
-@@ -397,7 +397,13 @@ bool mysql_create_view(THD *thd, TABLE_L
- {
- Item_field *field;
- if ((field= item->filed_for_view_update()))
-+ {
-+ /*
-+ any_privileges may be reset later by the Item_field::set_field
-+ method in case of a system temporary table.
-+ */
- field->any_privileges= 1;
-+ }
- }
- }
- #endif
diff --git a/07100_all_respect_tmpdir_filesort_mybug_30287_5.1.patch b/07100_all_respect_tmpdir_filesort_mybug_30287_5.1.patch
deleted file mode 100644
index bcfc17d..0000000
--- a/07100_all_respect_tmpdir_filesort_mybug_30287_5.1.patch
+++ /dev/null
@@ -1,131 +0,0 @@
-From: &lt;gshchepaDate: August 23 2007 10:54pm
-Subject: bk commit into 5.1 tree (gshchepa:1.2569) BUG#30287
-
-Below is the list of changes that have just been committed into a local
-5.1 repository of uchum. When uchum does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-08-24 01:54:18+05:00, gshchepa@stripped +3 -0
- Fixed bug #30287.
- Recommit to 5.1.22.
- The server created temporary tables for filesort in the working directory
- instead of the specified tmpdir directory.
-
- sql/item.cc@stripped, 2007-08-24 01:52:11+05:00, gshchepa@stripped +2 -0
- Fixed bug #30287.
- Recommit to 5.1.22.
- The Item_field::set_field method has been modified to reset the any_privileges
- flag to false in case of system temporary table. This modification prevents the
- server from unnecessary checking of user privileges to access system temporary
- tables.
-
- sql/sql_select.cc@stripped, 2007-08-24 01:52:15+05:00, gshchepa@stripped +8 -10
- Fixed bug #30287.
- Recommit to 5.1.22.
- Bugfix for #29015 has been removed: TABLE_SHARE::table_name of system
- temporary tables contains full path to table file basename again.
-
- sql/sql_view.cc@stripped, 2007-08-24 01:52:16+05:00, gshchepa@stripped +6 -0
- Fixed bug #30287.
- Recommit to 5.1.22.
- Commentary has been added.
-
-diff -Nrup a/sql/item.cc b/sql/item.cc
---- a/sql/item.cc 2007-08-14 00:39:23 +05:00
-+++ b/sql/item.cc 2007-08-24 01:52:11 +05:00
-@@ -1801,6 +1801,8 @@ void Item_field::set_field(Field *field_
- unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
- collation.set(field_par->charset(), field_par->derivation());
- fixed= 1;
-+ if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
-+ any_privileges= 0;
- }
-
-
-diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
---- a/sql/sql_select.cc 2007-08-14 00:39:25 +05:00
-+++ b/sql/sql_select.cc 2007-08-24 01:52:15 +05:00
-@@ -9417,7 +9417,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- bool using_unique_constraint= 0;
- bool use_packed_rows= 0;
- bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
-- char *tmpname, *tmppath, path[FN_REFLEN], table_name[NAME_LEN+1];
-+ char *tmpname,path[FN_REFLEN];
- uchar *pos, *group_buff, *bitmaps;
- uchar *null_flags;
- Field **reg_field, **from_field, **default_field;
-@@ -9441,12 +9441,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- temp_pool_slot = bitmap_lock_set_next(&temp_pool);
-
- if (temp_pool_slot != MY_BIT_NONE) // we got a slot
-- sprintf(table_name, "%s_%lx_%i", tmp_file_prefix,
-+ sprintf(path, "%s_%lx_%i", tmp_file_prefix,
- current_pid, temp_pool_slot);
- else
- {
- /* if we run out of slots or we are not using tempool */
-- sprintf(table_name, "%s%lx_%lx_%x", tmp_file_prefix,current_pid,
-+ sprintf(path,"%s%lx_%lx_%x", tmp_file_prefix,current_pid,
- thd->thread_id, thd->tmp_table++);
- }
-
-@@ -9454,8 +9454,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- No need to change table name to lower case as we are only creating
- MyISAM or HEAP tables here
- */
-- fn_format(path, table_name, mysql_tmpdir, "",
-- MY_REPLACE_EXT|MY_UNPACK_FILENAME);
-+ fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
-+
-
- if (group)
- {
-@@ -9501,8 +9501,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- sizeof(*key_part_info)*(param->group_parts+1),
- &param->start_recinfo,
- sizeof(*param->recinfo)*(field_count*2+4),
-- &tmppath, (uint) strlen(path)+1,
-- &tmpname, (uint) strlen(table_name)+1,
-+ &tmpname, (uint) strlen(path)+1,
- &group_buff, (group && ! using_unique_constraint ?
- param->group_length : 0),
- &bitmaps, bitmap_buffer_size(field_count)*2,
-@@ -9521,8 +9520,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- DBUG_RETURN(NULL); /* purecov: inspected */
- }
- param->items_to_copy= copy_func;
-- strmov(tmppath, path);
-- strmov(tmpname, table_name);
-+ strmov(tmpname,path);
- /* make table according to fields */
-
- bzero((char*) table,sizeof(*table));
-@@ -9547,7 +9545,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- table->keys_in_use_for_query.init();
-
- table->s= share;
-- init_tmp_table_share(share, "", 0, tmpname, tmppath);
-+ init_tmp_table_share(share, "", 0, tmpname, tmpname);
- share->blob_field= blob_field;
- share->blob_ptr_size= mi_portable_sizeof_char_ptr;
- share->db_low_byte_first=1; // True for HEAP and MyISAM
-diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
---- a/sql/sql_view.cc 2007-07-17 00:02:46 +05:00
-+++ b/sql/sql_view.cc 2007-08-24 01:52:16 +05:00
-@@ -397,7 +397,13 @@ bool mysql_create_view(THD *thd, TABLE_L
- {
- Item_field *field;
- if ((field= item->filed_for_view_update()))
-+ {
-+ /*
-+ any_privileges may be reset later by the Item_field::set_field
-+ method in case of a system temporary table.
-+ */
- field->any_privileges= 1;
-+ }
- }
- }
- #endif
diff --git a/07110_all_mysql_gcc-4.2.patch b/07110_all_mysql_gcc-4.2.patch
deleted file mode 100644
index c5e2771..0000000
--- a/07110_all_mysql_gcc-4.2.patch
+++ /dev/null
@@ -1,3483 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqlbinlog.cc ./client/mysqlbinlog.cc
---- ../mysql-5.1.22-beta.orig/client/mysqlbinlog.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqlbinlog.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1465,7 +1465,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error= 1;
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysql.cc ./client/mysql.cc
---- ../mysql-5.1.22-beta.orig/client/mysql.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysql.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2398,9 +2398,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -2420,7 +2420,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqldump.c ./client/mysqldump.c
---- ../mysql-5.1.22-beta.orig/client/mysqldump.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqldump.c 2007-10-04 21:43:01.000000000 +0200
-@@ -790,7 +790,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff), err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4389,7 +4389,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff), var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff), var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqltest.c ./client/mysqltest.c
---- ../mysql-5.1.22-beta.orig/client/mysqltest.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqltest.c 2007-10-04 21:43:01.000000000 +0200
-@@ -4099,9 +4099,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysql_upgrade.c ./client/mysql_upgrade.c
---- ../mysql-5.1.22-beta.orig/client/mysql_upgrade.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysql_upgrade.c 2007-10-04 21:43:01.000000000 +0200
-@@ -401,7 +401,7 @@
- DBUG_PRINT("enter", ("path: %s", path));
-
- /* Chop off last char(since it might be a /) */
-- path[max((strlen(path)-1), 0)]= 0;
-+ path[MYSQL_MAX((strlen(path)-1), 0)]= 0;
-
- /* Chop off last dir part */
- dirname_part(path, path, &path_len);
-@@ -492,7 +492,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -uNr ../mysql-5.1.22-beta.orig/client/sql_string.cc ./client/sql_string.cc
---- ../mysql-5.1.22-beta.orig/client/sql_string.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/sql_string.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -uNr ../mysql-5.1.22-beta.orig/dbug/dbug.c ./dbug/dbug.c
---- ../mysql-5.1.22-beta.orig/dbug/dbug.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./dbug/dbug.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1177,7 +1177,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1662,7 +1662,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -uNr ../mysql-5.1.22-beta.orig/extra/yassl/src/ssl.cpp ./extra/yassl/src/ssl.cpp
---- ../mysql-5.1.22-beta.orig/extra/yassl/src/ssl.cpp 2007-10-04 21:42:21.000000000 +0200
-+++ ./extra/yassl/src/ssl.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +113,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -uNr ../mysql-5.1.22-beta.orig/extra/yassl/taocrypt/src/dh.cpp ./extra/yassl/taocrypt/src/dh.cpp
---- ../mysql-5.1.22-beta.orig/extra/yassl/taocrypt/src/dh.cpp 2007-10-04 21:42:21.000000000 +0200
-+++ ./extra/yassl/taocrypt/src/dh.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +54,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -uNr ../mysql-5.1.22-beta.orig/include/my_global.h ./include/my_global.h
---- ../mysql-5.1.22-beta.orig/include/my_global.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./include/my_global.h 2007-10-04 21:43:01.000000000 +0200
-@@ -563,10 +563,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -uNr ../mysql-5.1.22-beta.orig/libmysql/libmysql.c ./libmysql/libmysql.c
---- ../mysql-5.1.22-beta.orig/libmysql/libmysql.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./libmysql/libmysql.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1541,7 +1541,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3616,7 +3616,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3849,9 +3849,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(14,width), value);
-+ MYSQL_MIN(14,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4156,7 +4156,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4168,7 +4168,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -uNr ../mysql-5.1.22-beta.orig/libmysqld/lib_sql.cc ./libmysqld/lib_sql.cc
---- ../mysql-5.1.22-beta.orig/libmysqld/lib_sql.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./libmysqld/lib_sql.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -798,7 +798,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(thd->total_warn_count, 65535));
- }
-
-
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/array.c ./mysys/array.c
---- ../mysql-5.1.22-beta.orig/mysys/array.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/array.c 2007-10-04 21:43:01.000000000 +0200
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -313,7 +313,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/default.c ./mysys/default.c
---- ../mysql-5.1.22-beta.orig/mysys/default.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/default.c 2007-10-04 21:43:01.000000000 +0200
-@@ -722,7 +722,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/mf_format.c ./mysys/mf_format.c
---- ../mysql-5.1.22-beta.orig/mysys/mf_format.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/mf_format.c 2007-10-04 21:43:01.000000000 +0200
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/mf_iocache.c ./mysys/mf_iocache.c
---- ../mysql-5.1.22-beta.orig/mysys/mf_iocache.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/mf_iocache.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1091,7 +1091,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1250,7 +1250,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1359,7 +1359,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1393,7 +1393,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_alloc.c ./mysys/my_alloc.c
---- ../mysql-5.1.22-beta.orig/mysys/my_alloc.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_alloc.c 2007-10-04 21:43:01.000000000 +0200
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_bitmap.c ./mysys/my_bitmap.c
---- ../mysql-5.1.22-beta.orig/mysys/my_bitmap.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_bitmap.c 2007-10-04 21:43:01.000000000 +0200
-@@ -364,7 +364,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_compress.c ./mysys/my_compress.c
---- ../mysql-5.1.22-beta.orig/mysys/my_compress.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_compress.c 2007-10-04 21:43:01.000000000 +0200
-@@ -243,7 +243,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_conio.c ./mysys/my_conio.c
---- ../mysql-5.1.22-beta.orig/mysys/my_conio.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_conio.c 2007-10-04 21:43:01.000000000 +0200
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res,
- NULL))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_file.c ./mysys/my_file.c
---- ../mysql-5.1.22-beta.orig/mysys/my_file.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_file.c 2007-10-04 21:43:01.000000000 +0200
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_getopt.c ./mysys/my_getopt.c
---- ../mysql-5.1.22-beta.orig/mysys/my_getopt.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_getopt.c 2007-10-04 21:43:01.000000000 +0200
-@@ -770,7 +770,7 @@
- num= (ulonglong) optp->max_value;
- num= ((num - optp->sub_size) / block_size);
- num= (longlong) (num * block_size);
-- return max(num, optp->min_value);
-+ return MYSQL_MAX(num, optp->min_value);
- }
-
- /*
-@@ -833,7 +833,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_handler.c ./mysys/my_handler.c
---- ../mysql-5.1.22-beta.orig/mysys/my_handler.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_handler.c 2007-10-04 21:43:01.000000000 +0200
-@@ -33,7 +33,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -161,7 +161,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/safemalloc.c ./mysys/safemalloc.c
---- ../mysql-5.1.22-beta.orig/mysys/safemalloc.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/safemalloc.c 2007-10-04 21:43:01.000000000 +0200
-@@ -237,7 +237,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -uNr ../mysql-5.1.22-beta.orig/server-tools/instance-manager/buffer.cc ./server-tools/instance-manager/buffer.cc
---- ../mysql-5.1.22-beta.orig/server-tools/instance-manager/buffer.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./server-tools/instance-manager/buffer.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -uNr ../mysql-5.1.22-beta.orig/server-tools/instance-manager/listener.cc ./server-tools/instance-manager/listener.cc
---- ../mysql-5.1.22-beta.orig/server-tools/instance-manager/listener.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./server-tools/instance-manager/listener.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/client.c ./sql/client.c
---- ../mysql-5.1.22-beta.orig/sql/client.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/client.c 2007-10-04 21:43:01.000000000 +0200
-@@ -625,7 +625,7 @@
- pos+= SQLSTATE_LENGTH+1;
- }
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2021,7 +2021,7 @@
- goto error;
- }
- memcpy(&sock_addr.sin_addr, hp->h_addr,
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- }
- sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/field.cc ./sql/field.cc
---- ../mysql-5.1.22-beta.orig/sql/field.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/field.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -49,7 +49,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -1980,7 +1980,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -1988,7 +1988,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2876,7 +2876,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3088,7 +3088,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3305,7 +3305,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3524,7 +3524,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3765,7 +3765,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -3947,7 +3947,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4289,7 +4289,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6142,13 +6142,13 @@
- double anr= fabs(nr);
- int neg= (nr < 0.0) ? 1 : 0;
- if (local_char_length > 4 && local_char_length < 32 &&
-- (anr < 1.0 ? anr > 1/(log_10[max(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
-+ (anr < 1.0 ? anr > 1/(log_10[MYSQL_MAX(0,(int) local_char_length-neg-2)]) /* -2 for "0." */
- : anr < log_10[local_char_length-neg]-1))
- use_scientific_notation= FALSE;
-
- length= (uint) my_sprintf(buff, (buff, "%-.*g",
- (use_scientific_notation ?
-- max(0, (int)local_char_length-neg-5) :
-+ MYSQL_MAX(0, (int)local_char_length-neg-5) :
- local_char_length),
- nr));
- /*
-@@ -6357,7 +6357,7 @@
-
- uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7292,7 +7292,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7447,7 +7447,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8569,7 +8569,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -8655,7 +8655,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -8698,7 +8698,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9146,7 +9146,7 @@
- and 19 as length of 4.1 compatible representation.
- */
- length= ((length+1)/2)*2; /* purecov: inspected */
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (fld_default_value)
-diff -uNr ../mysql-5.1.22-beta.orig/sql/filesort.cc ./sql/filesort.cc
---- ../mysql-5.1.22-beta.orig/sql/filesort.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/filesort.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -181,7 +181,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -203,12 +203,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1049,7 +1049,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1312,7 +1312,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/ha_ndbcluster.cc ./sql/ha_ndbcluster.cc
---- ../mysql-5.1.22-beta.orig/sql/ha_ndbcluster.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/ha_ndbcluster.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -804,7 +804,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/handler.h ./sql/handler.h
---- ../mysql-5.1.22-beta.orig/sql/handler.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/handler.h 2007-10-04 21:43:01.000000000 +0200
-@@ -1565,15 +1565,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_buff.cc ./sql/item_buff.cc
---- ../mysql-5.1.22-beta.orig/sql/item_buff.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_buff.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -51,7 +51,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -60,7 +60,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item.cc ./sql/item.cc
---- ../mysql-5.1.22-beta.orig/sql/item.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -73,7 +73,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -426,9 +426,9 @@
- Item_result restype= result_type();
-
- if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
-- return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
-+ return MYSQL_MIN(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
- DECIMAL_MAX_PRECISION);
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -728,7 +728,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -4805,7 +4805,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -6697,12 +6697,12 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-- int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(MYSQL_MAX(prev_decimal_int_part, item->decimal_int_part())
- + decimals, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length(precision, decimals,
-@@ -6733,7 +6733,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -6748,7 +6748,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= FLT_DIG + 6;
-@@ -6765,7 +6765,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_cmpfunc.cc ./sql/item_cmpfunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_cmpfunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_cmpfunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -560,7 +560,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1032,7 +1032,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2045,11 +2045,11 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- max_length= (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) ?
-- (max(args[0]->max_length - args[0]->decimals,
-+ (MYSQL_MAX(args[0]->max_length - args[0]->decimals,
- args[1]->max_length - args[1]->decimals) + decimals) :
-- max(args[0]->max_length, args[1]->max_length);
-+ MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2073,8 +2073,8 @@
-
- uint Item_func_ifnull::decimal_precision() const
- {
-- int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int max_int_part=MYSQL_MAX(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2203,7 +2203,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2244,18 +2244,18 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
- uint Item_func_if::decimal_precision() const
- {
-- int precision=(max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
-+ int precision=(MYSQL_MAX(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
- decimals);
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2641,7 +2641,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4489,7 +4489,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4508,7 +4508,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -4629,14 +4629,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -4660,14 +4660,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_func.cc ./sql/item_func.cc
---- ../mysql-5.1.22-beta.orig/sql/item_func.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_func.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -542,7 +542,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1152,10 +1152,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- int max_int_part= max(args[0]->decimal_precision() - args[0]->decimals,
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ int max_int_part= MYSQL_MAX(args[0]->decimal_precision() - args[0]->decimals,
- args[1]->decimal_precision() - args[1]->decimals);
-- int precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1263,8 +1263,8 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-- int precision= min(args[0]->decimal_precision() + args[1]->decimal_precision(),
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(args[0]->decimal_precision() + args[1]->decimal_precision(),
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
- }
-@@ -1312,14 +1312,14 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() + prec_increment,
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() + prec_increment,
- DECIMAL_MAX_PRECISION);
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1333,7 +1333,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1451,8 +1451,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1970,7 +1970,7 @@
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
- max_length= args[0]->max_length;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- hybrid_type= REAL_RESULT;
- return;
- }
-@@ -1979,7 +1979,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2102,7 +2102,7 @@
- longlong dec= args[1]->val_int();
- if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
- {
-- dec= min((ulonglong) dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN((ulonglong) dec, DECIMAL_MAX_SCALE);
- decimals= (uint8) dec; // to get correct output
- }
- else if (dec < INT_MIN)
-@@ -2950,10 +2950,10 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_strfunc.cc ./sql/item_strfunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_strfunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_strfunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1183,7 +1183,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1203,7 +1203,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1888,7 +1888,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3009,11 +3009,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_sum.cc ./sql/item_sum.cc
---- ../mysql-5.1.22-beta.orig/sql/item_sum.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_sum.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1071,7 +1071,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1134,15 +1134,15 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1326,13 +1326,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-
-@@ -3362,7 +3362,7 @@
- duplicate values (according to the syntax of this function). If there
- is no DISTINCT or ORDER BY clauses, we don't create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length, compare_key, 0, NULL, (void*) this);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_timefunc.cc ./sql/item_timefunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_timefunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_timefunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -306,14 +306,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -322,7 +322,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -339,15 +339,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -358,14 +358,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -373,7 +373,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -425,7 +425,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -437,7 +437,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- strict_week_number && !week_number ||
- week_number > 53)
-@@ -449,7 +449,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -594,7 +594,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_time");
-@@ -1711,7 +1711,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/key.cc ./sql/key.cc
---- ../mysql-5.1.22-beta.orig/sql/key.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/key.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -144,13 +144,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -237,7 +237,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -246,7 +246,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- memcpy(to_record + key_part->offset, from_key, (size_t) length);
- }
- from_key+= length;
-@@ -306,7 +306,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -372,7 +372,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -uNr ../mysql-5.1.22-beta.orig/sql/log.cc ./sql/log.cc
---- ../mysql-5.1.22-beta.orig/sql/log.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/log.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -537,11 +537,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2173,7 +2173,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -4285,7 +4285,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/log_event.cc ./sql/log_event.cc
---- ../mysql-5.1.22-beta.orig/sql/log_event.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/log_event.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -828,7 +828,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -4172,7 +4172,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -5853,7 +5853,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/mysqld.cc ./sql/mysqld.cc
---- ../mysql-5.1.22-beta.orig/sql/mysqld.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/mysqld.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2817,7 +2817,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -2829,15 +2829,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4401,7 +4401,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/my_time.c ./sql/my_time.c
---- ../mysql-5.1.22-beta.orig/sql/my_time.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/my_time.c 2007-10-04 21:43:01.000000000 +0200
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/net_serv.cc ./sql/net_serv.cc
---- ../mysql-5.1.22-beta.orig/sql/net_serv.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/net_serv.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -762,7 +762,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -936,7 +936,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql/opt_range.cc ./sql/opt_range.cc
---- ../mysql-5.1.22-beta.orig/sql/opt_range.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/opt_range.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2272,7 +2272,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3737,7 +3737,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7201,7 +7201,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7270,7 +7270,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8170,13 +8170,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8195,7 +8195,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- (QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8278,7 +8278,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8391,13 +8391,13 @@
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -8695,7 +8695,7 @@
- KEY_PART *key_part = key_parts,
- *key_part_end= key_part+used_key_parts;
-
-- for (offset= 0, end = min(range_arg->min_length, range_arg->max_length) ;
-+ for (offset= 0, end = MYSQL_MIN(range_arg->min_length, range_arg->max_length) ;
- offset < end && key_part != key_part_end ;
- offset+= key_part++->store_length)
- {
-@@ -9041,7 +9041,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9262,7 +9262,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- cur_used_key_parts.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -9869,9 +9869,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -uNr ../mysql-5.1.22-beta.orig/sql/protocol.cc ./sql/protocol.cc
---- ../mysql-5.1.22-beta.orig/sql/protocol.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/protocol.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -190,7 +190,7 @@
- length=sizeof(text_pos)-1;
- #endif
- length=my_vsnprintf(my_const_cast(char*) (text_pos),
-- min(length, sizeof(net->last_error)),
-+ MYSQL_MIN(length, sizeof(net->last_error)),
- format,args);
- va_end(args);
-
-@@ -296,7 +296,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(thd->total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(thd->total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -371,7 +371,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+ uint tmp= (thd->spcont ? 0 : MYSQL_MIN(thd->total_warn_count, 65535));
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/rpl_rli.cc ./sql/rpl_rli.cc
---- ../mysql-5.1.22-beta.orig/sql/rpl_rli.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/rpl_rli.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -645,7 +645,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -655,7 +655,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
---- ../mysql.orig/sql/rpl_record.cc 2007-10-04 22:44:29.000000000 +0200
-+++ sql/rpl_record.cc 2007-10-04 23:36:10.000000000 +0200
-@@ -264,7 +264,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/rpl_utility.cc ./sql/rpl_utility.cc
---- ../mysql-5.1.22-beta.orig/sql/rpl_utility.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/rpl_utility.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -170,7 +170,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- RELAY_LOG_INFO const *rli= const_cast<RELAY_LOG_INFO*>(rli_arg);
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/set_var.cc ./sql/set_var.cc
---- ../mysql-5.1.22-beta.orig/sql/set_var.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/set_var.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1405,7 +1405,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff), error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff), error_len));
- goto err;
- }
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/slave.cc ./sql/slave.cc
---- ../mysql-5.1.22-beta.orig/sql/slave.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/slave.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1406,7 +1406,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -1937,7 +1937,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -3444,7 +3444,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/spatial.h ./sql/spatial.h
---- ../mysql-5.1.22-beta.orig/sql/spatial.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/spatial.h 2007-10-04 21:43:01.000000000 +0200
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sp_head.cc ./sql/sp_head.cc
---- ../mysql-5.1.22-beta.orig/sql/sp_head.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sp_head.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2276,7 +2276,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2478,7 +2478,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_acl.cc ./sql/sql_acl.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_acl.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_acl.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -808,7 +808,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_analyse.cc ./sql/sql_analyse.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_analyse.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_analyse.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_cache.cc ./sql/sql_cache.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_cache.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_cache.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -802,7 +802,7 @@
-
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2177,7 +2177,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2240,7 +2240,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2272,7 +2272,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2360,8 +2360,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2393,7 +2393,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2402,7 +2402,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -2838,7 +2838,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_class.cc ./sql/sql_class.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_class.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_class.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -342,7 +342,7 @@
- if (max_query_len < 1)
- len= thd->query_length;
- else
-- len= min(thd->query_length, max_query_len);
-+ len= MYSQL_MIN(thd->query_length, max_query_len);
- str.append('\n');
- str.append(thd->query, len);
- }
-@@ -1625,7 +1625,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_client.cc ./sql/sql_client.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_client.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_client.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_connect.cc ./sql/sql_connect.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_connect.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_connect.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -680,7 +680,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_load.cc ./sql/sql_load.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_load.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_load.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -907,7 +907,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_parse.cc ./sql/sql_parse.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_parse.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_parse.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -5119,7 +5119,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -6554,7 +6554,7 @@
- char command[80];
- Lex_input_stream *lip= thd->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_partition.cc ./sql/sql_partition.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_partition.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_partition.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -4429,7 +4429,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_plugin.cc ./sql/sql_plugin.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_plugin.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_plugin.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -471,7 +471,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -1995,7 +1995,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff), error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff), error_len));
- strvalue= buff;
- goto err;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_prepare.cc ./sql/sql_prepare.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_prepare.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_prepare.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -238,7 +238,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_repl.cc ./sql/sql_repl.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_repl.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_repl.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1191,12 +1191,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1341,7 +1341,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_select.cc ./sql/sql_select.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_select.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_select.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2696,7 +2696,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3562,7 +3562,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3585,7 +3585,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3738,7 +3738,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4063,7 +4063,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4230,7 +4230,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5133,7 +5133,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -9877,7 +9877,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13283,7 +13283,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -13401,7 +13401,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_string.cc ./sql/sql_string.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_string.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_string.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -654,7 +654,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -740,7 +740,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -757,7 +757,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -896,7 +896,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_table.cc ./sql/sql_table.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_table.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_table.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2794,7 +2794,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_yacc.cc ./sql/sql_yacc.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_yacc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_yacc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -14925,7 +14925,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -14941,7 +14941,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[0].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_yacc.yy ./sql/sql_yacc.yy
---- ../mysql-5.1.22-beta.orig/sql/sql_yacc.yy 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_yacc.yy 2007-10-04 21:43:01.000000000 +0200
-@@ -1546,7 +1546,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1556,7 +1556,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/stacktrace.c ./sql/stacktrace.c
---- ../mysql-5.1.22-beta.orig/sql/stacktrace.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/stacktrace.c 2007-10-04 21:43:01.000000000 +0200
-@@ -131,7 +131,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/thr_malloc.cc ./sql/thr_malloc.cc
---- ../mysql-5.1.22-beta.orig/sql/thr_malloc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/thr_malloc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -102,7 +102,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -uNr ../mysql-5.1.22-beta.orig/sql/tztime.cc ./sql/tztime.cc
---- ../mysql-5.1.22-beta.orig/sql/tztime.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/tztime.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1819,7 +1819,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- DBUG_ENTER("tz_load_from_open_tables");
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/unireg.cc ./sql/unireg.cc
---- ../mysql-5.1.22-beta.orig/sql/unireg.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/unireg.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -435,7 +435,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -655,7 +655,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql-common/client.c ./sql-common/client.c
---- ../mysql-5.1.22-beta.orig/sql-common/client.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql-common/client.c 2007-10-04 21:43:01.000000000 +0200
-@@ -625,7 +625,7 @@
- pos+= SQLSTATE_LENGTH+1;
- }
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2021,7 +2021,7 @@
- goto error;
- }
- memcpy(&sock_addr.sin_addr, hp->h_addr,
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- }
- sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -uNr ../mysql-5.1.22-beta.orig/sql-common/my_time.c ./sql-common/my_time.c
---- ../mysql-5.1.22-beta.orig/sql-common/my_time.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql-common/my_time.c 2007-10-04 21:43:01.000000000 +0200
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/csv/ha_tina.cc ./storage/csv/ha_tina.cc
---- ../mysql-5.1.22-beta.orig/storage/csv/ha_tina.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/csv/ha_tina.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1161,7 +1161,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1390,7 +1390,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- write_end - write_begin, MYF_RW)))
-diff -uNr ../mysql-5.1.22-beta.orig/storage/federated/ha_federated.cc ./storage/federated/ha_federated.cc
---- ../mysql-5.1.22-beta.orig/storage/federated/ha_federated.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/federated/ha_federated.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -546,7 +546,7 @@
- int buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1284,7 +1284,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -uNr ../mysql-5.1.22-beta.orig/storage/heap/hp_create.c ./storage/heap/hp_create.c
---- ../mysql-5.1.22-beta.orig/storage/heap/hp_create.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/heap/hp_create.c 2007-10-04 21:43:01.000000000 +0200
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/heap/hp_test2.c ./storage/heap/hp_test2.c
---- ../mysql-5.1.22-beta.orig/storage/heap/hp_test2.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/heap/hp_test2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -137,7 +137,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -218,7 +218,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/ha_myisam.cc ./storage/myisam/ha_myisam.cc
---- ../mysql-5.1.22-beta.orig/storage/myisam/ha_myisam.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/ha_myisam.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1460,7 +1460,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- table->s->avg_row_length*rows);
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_cache.c ./storage/myisam/mi_cache.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_cache.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_cache.c 2007-10-04 21:43:01.000000000 +0200
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_create.c ./storage/myisam/mi_create.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_create.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_create.c 2007-10-04 21:43:01.000000000 +0200
-@@ -438,8 +438,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -528,7 +528,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -566,7 +566,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_dynrec.c ./storage/myisam/mi_dynrec.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_dynrec.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_dynrec.c 2007-10-04 21:43:01.000000000 +0200
-@@ -782,7 +782,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_extra.c ./storage/myisam/mi_extra.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_extra.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_extra.c 2007-10-04 21:43:01.000000000 +0200
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_check.c ./storage/myisam/mi_check.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_check.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_check.c 2007-10-04 21:43:01.000000000 +0200
-@@ -2047,7 +2047,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2215,7 +2215,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2666,7 +2666,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4198,7 +4198,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_open.c ./storage/myisam/mi_open.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_open.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_open.c 2007-10-04 21:43:01.000000000 +0200
-@@ -318,7 +318,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- for (i=0 ; i < keys ; i++)
-@@ -488,7 +488,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -697,7 +697,7 @@
- /* to simplify initial init of info->rec_buf in mi_open and mi_extra */
- if (length == (ulong) -1)
- {
-- length= max(info->s->base.pack_reclength,
-+ length= MYSQL_MAX(info->s->base.pack_reclength,
- info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_packrec.c ./storage/myisam/mi_packrec.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_packrec.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_packrec.c 2007-10-04 21:43:01.000000000 +0200
-@@ -678,7 +678,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1393,7 +1393,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_test1.c ./storage/myisam/mi_test1.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_test1.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_test1.c 2007-10-04 21:43:01.000000000 +0200
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_test2.c ./storage/myisam/mi_test2.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_test2.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_test2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -600,7 +600,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/myisamlog.c ./storage/myisam/myisamlog.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/myisamlog.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/myisamlog.c 2007-10-04 21:43:01.000000000 +0200
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/myisampack.c ./storage/myisam/myisampack.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/myisampack.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/myisampack.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/rt_mbr.c ./storage/myisam/rt_mbr.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/rt_mbr.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/rt_mbr.c 2007-10-04 21:43:01.000000000 +0200
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -601,7 +601,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -612,7 +612,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/sort.c ./storage/myisam/sort.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/sort.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/sort.c 2007-10-04 21:43:01.000000000 +0200
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -812,7 +812,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -833,7 +833,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisammrg/ha_myisammrg.cc ./storage/myisammrg/ha_myisammrg.cc
---- ../mysql-5.1.22-beta.orig/storage/myisammrg/ha_myisammrg.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisammrg/ha_myisammrg.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -378,7 +378,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- return 0;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/common/portlib/NdbTCP.cpp ./storage/ndb/src/common/portlib/NdbTCP.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/common/portlib/NdbTCP.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp ./storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/ndbapi/NdbBlob.cpp ./storage/ndb/src/ndbapi/NdbBlob.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/ndbapi/NdbBlob.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -1518,7 +1518,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/test/ndbapi/testIndexStat.cpp ./storage/ndb/test/ndbapi/testIndexStat.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/test/ndbapi/testIndexStat.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/test/src/getarg.c ./storage/ndb/test/src/getarg.c
---- ../mysql-5.1.22-beta.orig/storage/ndb/test/src/getarg.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/test/src/getarg.c 2007-10-04 21:43:01.000000000 +0200
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-big5.c ./strings/ctype-big5.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-big5.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-big5.c 2007-10-04 21:43:01.000000000 +0200
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-bin.c ./strings/ctype-bin.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-bin.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-bin.c 2007-10-04 21:43:01.000000000 +0200
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-gbk.c ./strings/ctype-gbk.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-gbk.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-gbk.c 2007-10-04 21:43:01.000000000 +0200
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-mb.c ./strings/ctype-mb.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-mb.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-mb.c 2007-10-04 21:43:01.000000000 +0200
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-simple.c ./strings/ctype-simple.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-simple.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-simple.c 2007-10-04 21:43:01.000000000 +0200
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -871,7 +871,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -923,7 +923,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1154,7 +1154,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-tis620.c ./strings/ctype-tis620.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-tis620.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-tis620.c 2007-10-04 21:43:01.000000000 +0200
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-uca.c ./strings/ctype-uca.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-uca.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-uca.c 2007-10-04 21:43:01.000000000 +0200
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-ucs2.c ./strings/ctype-ucs2.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-ucs2.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-ucs2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -280,7 +280,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1330,7 +1330,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1426,7 +1426,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1473,7 +1473,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-utf8.c ./strings/ctype-utf8.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-utf8.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-utf8.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/strings/decimal.c ./strings/decimal.c
---- ../mysql-5.1.22-beta.orig/strings/decimal.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/decimal.c 2007-10-04 21:43:01.000000000 +0200
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1520,8 +1520,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1532,7 +1532,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1622,7 +1622,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1641,7 +1641,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1690,11 +1690,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1709,7 +1709,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1734,7 +1734,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1763,14 +1763,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1791,7 +1791,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1866,7 +1866,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1901,7 +1901,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2159,11 +2159,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2287,7 +2287,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2325,7 +2325,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/strings/my_vsnprintf.c ./strings/my_vsnprintf.c
---- ../mysql-5.1.22-beta.orig/strings/my_vsnprintf.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/my_vsnprintf.c 2007-10-04 21:43:01.000000000 +0200
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -uNr ../mysql-5.1.22-beta.orig/strings/str2int.c ./strings/str2int.c
---- ../mysql-5.1.22-beta.orig/strings/str2int.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/str2int.c 2007-10-04 21:43:01.000000000 +0200
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -uNr ../mysql-5.1.22-beta.orig/tests/mysql_client_test.c ./tests/mysql_client_test.c
---- ../mysql-5.1.22-beta.orig/tests/mysql_client_test.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./tests/mysql_client_test.c 2007-10-04 21:43:01.000000000 +0200
-@@ -567,7 +567,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -uNr ../mysql-5.1.22-beta.orig/vio/viosocket.c ./vio/viosocket.c
---- ../mysql-5.1.22-beta.orig/vio/viosocket.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./vio/viosocket.c 2007-10-04 21:43:01.000000000 +0200
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_show.cc ./sql/sql_show.cc
---- ../mysql.orig/sql/sql_show.cc 2007-10-05 08:53:24.000000000 +0200
-+++ sql/sql_show.cc 2007-10-05 08:53:54.000000000 +0200
-@@ -617,7 +617,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -628,7 +628,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1686,7 +1686,7 @@
- the comment in sql_class.h why this prevents crashes in possible
- races with query_length
- */
-- uint length= min(max_query_length, tmp->query_length);
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length);
- thd_info->query=(char*) thd->strmake(tmp->query,length);
- }
- thread_infos.append(thd_info);
-@@ -1814,7 +1814,7 @@
- if (tmp->query)
- {
- table->field[7]->store(tmp->query,
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length), cs);
- table->field[7]->set_notnull();
- }
-@@ -6662,7 +6662,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
diff --git a/07110_all_mysql_gcc-4.2_5.0.54.patch b/07110_all_mysql_gcc-4.2_5.0.54.patch
deleted file mode 100644
index e977bc6..0000000
--- a/07110_all_mysql_gcc-4.2_5.0.54.patch
+++ /dev/null
@@ -1,5360 +0,0 @@
-This patch was made against mysql-5.0.54
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/client/mysqlbinlog.cc 2008-01-15 02:53:13.369209185 -0800
-@@ -1374,7 +1374,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error= 1;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/client/mysql.cc 2008-01-15 02:53:13.373375497 -0800
-@@ -2501,9 +2501,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -2523,7 +2523,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/client/mysqldump.c 2008-01-15 02:53:13.376714393 -0800
-@@ -780,7 +780,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff), err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -3408,7 +3408,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff), var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff), var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/mysqltest.c mysql/client/mysqltest.c
---- mysql.orig/client/mysqltest.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/client/mysqltest.c 2008-01-15 02:53:13.380049101 -0800
-@@ -4548,9 +4548,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/client/mysql_upgrade.c 2008-01-15 03:02:22.301332298 -0800
-@@ -398,7 +398,7 @@
- mysqlcheck). Thus if path ends in .libs/, step up one directory
- and execute the tools from there
- */
-- path[max((strlen(path)-1), 0)]= 0; /* Chop off last / */
-+ path[MYSQL_MAX((strlen(path)-1), 0)]= 0; /* Chop off last / */
- if (strncmp(path + dirname_length(path), ".libs", 5) == 0)
- {
- DBUG_PRINT("info", ("Chopping off .libs from '%s'", path));
-@@ -501,7 +501,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/client/sql_string.cc 2008-01-15 02:53:13.383382959 -0800
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/dbug/dbug.c 2008-01-15 03:18:56.346233975 -0800
-@@ -959,7 +959,7 @@
- if (TRACING)
- {
- Indent (state->level + 1);
-- pos= min(max(state->level-stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(state->level-stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1381,7 +1381,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-stack->sub_level,0)*INDENT;
- for (count = 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/extra/yassl/src/ssl.cpp 2008-01-15 02:53:13.386708995 -0800
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2008-01-15 02:53:13.386708995 -0800
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/include/my_global.h 2008-01-15 02:53:13.386708995 -0800
-@@ -462,10 +462,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if defined(__EMX__) || !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysql/libmysql.c 2008-01-15 02:53:13.390042231 -0800
-@@ -1558,7 +1558,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3562,7 +3562,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3794,9 +3794,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(14,width), value);
-+ MYSQL_MIN(14,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4113,7 +4113,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4125,7 +4125,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/lib_sql.cc 2008-01-15 02:53:13.393375384 -0800
-@@ -792,7 +792,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(thd->total_warn_count, 65535));
- }
-
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/mysys/array.c 2008-01-15 02:53:13.393375384 -0800
-@@ -45,7 +45,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -263,7 +263,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- if (array->buffer && array->max_element != elements)
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/mysys/default.c 2008-01-15 03:21:47.211529003 -0800
-@@ -732,7 +732,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;/* Remove end space */
- end[0]=0;
-
-- strnmov(curr_gr, ptr, min((uint) (end-ptr)+1, 4096));
-+ strnmov(curr_gr, ptr, MYSQL_MIN((uint) (end-ptr)+1, 4096));
- continue;
- }
- if (!found_group)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/mysys/mf_format.c 2008-01-15 03:21:32.169043847 -0800
-@@ -80,7 +80,7 @@
- return NullS;
- tmp_length=strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/mysys/mf_iocache.c 2008-01-15 03:21:21.279059069 -0800
-@@ -1090,7 +1090,7 @@
- */
- while (write_length)
- {
-- uint copy_length= min(write_length, write_cache->buffer_length);
-+ uint copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1250,7 +1250,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1358,7 +1358,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1392,7 +1392,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (uint) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/mysys/my_alloc.c 2008-01-15 03:21:10.692646904 -0800
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= Size+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/mysys/my_bitmap.c 2008-01-15 03:20:51.573526320 -0800
-@@ -321,7 +321,7 @@
- bitmap_lock(map);
- bitmap_lock((MY_BITMAP *)map2);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
-
- while (to < end)
- *to++ &= *from++;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2007-12-14 12:43:41.000000000 -0800
-+++ mysql/mysys/my_file.c 2008-01-15 02:53:13.400041859 -0800
-@@ -94,7 +94,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -116,7 +116,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/mysys/my_handler.c 2008-01-15 02:53:13.403375075 -0800
-@@ -33,7 +33,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -161,7 +161,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/mysys/safemalloc.c 2008-01-15 03:19:08.615759551 -0800
-@@ -237,7 +237,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((byte*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/server-tools/instance-manager/buffer.cc 2008-01-15 03:01:47.733444331 -0800
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (char*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2007-12-14 12:42:50.000000000 -0800
-+++ mysql/server-tools/instance-manager/listener.cc 2008-01-15 02:53:13.406708559 -0800
-@@ -140,7 +140,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/client.c mysql/sql/client.c
---- mysql.orig/sql/client.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/client.c 2008-01-15 02:53:13.406708559 -0800
-@@ -630,7 +630,7 @@
- pos+= SQLSTATE_LENGTH+1;
- }
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2026,7 +2026,7 @@
- goto error;
- }
- memcpy(&sock_addr.sin_addr, hp->h_addr,
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- }
- sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2007-12-14 12:42:41.000000000 -0800
-+++ mysql/sql/field.cc 2008-01-15 03:18:10.419060594 -0800
-@@ -49,7 +49,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- /*
- Rules for merging different types of fields in UNION
-@@ -1889,7 +1889,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -1897,7 +1897,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2708,7 +2708,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -2914,7 +2914,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3125,7 +3125,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3338,7 +3338,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3573,7 +3573,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -3750,7 +3750,7 @@
- #endif
- memcpy_fixed((byte*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4085,7 +4085,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -5968,13 +5968,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(0, (int) max_length - fractional);
-+ digits= MYSQL_MAX(0, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(0, (int) digits + exp);
-+ digits= MYSQL_MAX(0, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -5982,7 +5982,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6171,7 +6171,7 @@
-
- char *Field_string::pack(char *to, const char *from, uint max_length)
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -6997,7 +6997,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7142,7 +7142,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8148,7 +8148,7 @@
- String *val_ptr __attribute__((unused)))
- {
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -8204,7 +8204,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -8228,7 +8228,7 @@
- uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -8606,7 +8606,7 @@
- and 19 as length of 4.1 compatible representation.
- */
- length= ((length+1)/2)*2; /* purecov: inspected */
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (fld_default_value)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql/filesort.cc 2008-01-15 03:17:40.017664193 -0800
-@@ -175,7 +175,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -197,12 +197,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -976,7 +976,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(byte*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1239,7 +1239,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/sql/ha_ndbcluster.cc 2008-01-15 03:17:27.770220746 -0800
-@@ -741,7 +741,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: %p len: %u",
- blob_ptr, blob_len));
-- DBUG_DUMP("value", (char*)blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", (char*)blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/handler.h 2008-01-15 02:53:13.426708779 -0800
-@@ -863,15 +863,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/sql/item_buff.cc 2008-01-15 02:53:13.426708779 -0800
-@@ -51,7 +51,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -60,7 +60,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2007-12-14 12:42:41.000000000 -0800
-+++ mysql/sql/item.cc 2008-01-15 02:53:13.430041699 -0800
-@@ -73,7 +73,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -429,9 +429,9 @@
- Item_result restype= result_type();
-
- if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
-- return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
-+ return MYSQL_MIN(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
- DECIMAL_MAX_PRECISION);
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -720,7 +720,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -4774,7 +4774,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -6686,12 +6686,12 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-- int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(MYSQL_MAX(prev_decimal_int_part, item->decimal_int_part())
- + decimals, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length(precision, decimals,
-@@ -6722,7 +6722,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -6737,7 +6737,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= FLT_DIG + 6;
-@@ -6754,7 +6754,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2007-12-14 12:43:41.000000000 -0800
-+++ mysql/sql/item_cmpfunc.cc 2008-01-15 03:17:13.172408641 -0800
-@@ -554,7 +554,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1039,7 +1039,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2062,7 +2062,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2073,10 +2073,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2098,8 +2098,8 @@
-
- uint Item_func_ifnull::decimal_precision() const
- {
-- int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int max_int_part=MYSQL_MAX(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2228,7 +2228,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2272,18 +2272,18 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
- uint Item_func_if::decimal_precision() const
- {
-- int precision=(max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
-+ int precision=(MYSQL_MAX(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
- decimals);
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2708,7 +2708,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4507,7 +4507,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4526,7 +4526,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -4647,14 +4647,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -4678,14 +4678,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/sql/item_func.cc 2008-01-15 03:16:19.162403717 -0800
-@@ -539,7 +539,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1155,10 +1155,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- int max_int_part= max(args[0]->decimal_precision() - args[0]->decimals,
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ int max_int_part= MYSQL_MAX(args[0]->decimal_precision() - args[0]->decimals,
- args[1]->decimal_precision() - args[1]->decimals);
-- int precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1266,8 +1266,8 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-- int precision= min(args[0]->decimal_precision() + args[1]->decimal_precision(),
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(args[0]->decimal_precision() + args[1]->decimal_precision(),
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
- }
-@@ -1315,14 +1315,14 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() + prec_increment,
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() + prec_increment,
- DECIMAL_MAX_PRECISION);
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1336,7 +1336,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1458,8 +1458,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1977,7 +1977,7 @@
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
- max_length= args[0]->max_length;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- hybrid_type= REAL_RESULT;
- return;
- }
-@@ -1986,7 +1986,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2003,7 +2003,7 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-@@ -2110,7 +2110,7 @@
- longlong dec= args[1]->val_int();
- if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
- {
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- decimals= (uint8) dec; // to get correct output
- }
- else if (dec < INT_MIN)
-@@ -2965,7 +2965,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2974,7 +2974,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/sql/item_strfunc.cc 2008-01-15 02:53:13.440042183 -0800
-@@ -1138,7 +1138,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1158,7 +1158,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1832,7 +1832,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -2933,11 +2933,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/sql/item_sum.cc 2008-01-15 02:53:13.443375111 -0800
-@@ -1063,7 +1063,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1126,15 +1126,15 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1313,13 +1313,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-
-@@ -3380,7 +3380,7 @@
- duplicate values (according to the syntax of this function). If there
- is no DISTINCT or ORDER BY clauses, we don't create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length, compare_key, 0, NULL, (void*) this);
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/sql/item_timefunc.cc 2008-01-15 02:53:13.443375111 -0800
-@@ -306,14 +306,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -322,7 +322,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -339,15 +339,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -358,14 +358,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -373,7 +373,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -425,7 +425,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -437,7 +437,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- strict_week_number && !week_number ||
- week_number > 53)
-@@ -449,7 +449,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -594,7 +594,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_time");
-@@ -1731,7 +1731,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/sql/key.cc 2008-01-15 03:15:49.819808086 -0800
-@@ -110,13 +110,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image((char*) to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image((char*) to_key, length, Field::itRAW);
-@@ -191,13 +191,13 @@
- else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->set_key_image((char *) from_key, length);
- from_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- memcpy(to_record + key_part->offset, from_key, (size_t) length);
- }
- from_key+= length;
-@@ -257,7 +257,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -311,7 +311,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/sql/log.cc 2008-01-15 03:15:05.616156542 -0800
-@@ -458,7 +458,7 @@
- {
- char *p = fn_ext(log_name);
- uint length=(uint) (p-log_name);
-- strmake(buff,log_name,min(length,FN_REFLEN));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -2407,7 +2407,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/sql/log_event.cc 2008-01-15 03:14:08.952844393 -0800
-@@ -772,7 +772,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -3936,7 +3936,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- char buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ char buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/sql/mysqld.cc 2008-01-15 02:53:13.456709723 -0800
-@@ -2784,7 +2784,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -2796,15 +2796,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4147,7 +4147,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/my_time.c mysql/sql/my_time.c
---- mysql.orig/sql/my_time.c 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql/my_time.c 2008-01-15 02:53:13.460042805 -0800
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/net_serv.cc 2008-01-15 03:13:30.665764742 -0800
-@@ -759,7 +759,7 @@
- {
- while (remain > 0)
- {
-- uint length= min(remain, net->max_packet);
-+ uint length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, (char*) net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -930,7 +930,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/opt_range.cc 2008-01-15 03:13:09.015766060 -0800
-@@ -2446,7 +2446,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -5876,7 +5876,7 @@
- char *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -6765,13 +6765,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -6790,7 +6790,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -6858,7 +6858,7 @@
- }
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -6959,12 +6959,12 @@
- last_range= *(cur_range++);
-
- start_key.key= (const byte*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const byte*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
- prefix we want to find all keys with this prefix
-@@ -7260,7 +7260,7 @@
- KEY_PART *key_part = key_parts,
- *key_part_end= key_part+used_key_parts;
-
-- for (offset= 0, end = min(range_arg->min_length, range_arg->max_length) ;
-+ for (offset= 0, end = MYSQL_MIN(range_arg->min_length, range_arg->max_length) ;
- offset < end && key_part != key_part_end ;
- offset+= key_part++->store_length)
- {
-@@ -7605,7 +7605,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -7835,7 +7835,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- cur_used_key_parts.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -8440,9 +8440,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/protocol.cc 2008-01-15 02:53:13.473379287 -0800
-@@ -190,7 +190,7 @@
- length=sizeof(text_pos)-1;
- #endif
- length=my_vsnprintf(my_const_cast(char*) (text_pos),
-- min(length, sizeof(net->last_error)),
-+ MYSQL_MIN(length, sizeof(net->last_error)),
- format,args);
- va_end(args);
-
-@@ -296,7 +296,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(thd->total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(thd->total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -371,7 +371,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+ uint tmp= (thd->spcont ? 0 : MYSQL_MIN(thd->total_warn_count, 65535));
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/sql/set_var.cc 2008-01-15 03:11:39.577022864 -0800
-@@ -1813,7 +1813,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/sql/slave.cc 2008-01-15 03:09:44.315795304 -0800
-@@ -2543,7 +2543,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- protocol->store_null();
-@@ -3434,7 +3434,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4849,7 +4849,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/sql/spatial.h 2008-01-15 02:53:58.130038225 -0800
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/sql/sp_head.cc 2008-01-15 03:09:01.051306283 -0800
-@@ -2161,7 +2161,7 @@
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
- // 1024 is for not to confuse old clients
- Item_empty_string *definition=
-- new Item_empty_string("Create Procedure", max(buffer.length(),1024));
-+ new Item_empty_string("Create Procedure", MYSQL_MAX(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
-@@ -2231,7 +2231,7 @@
- field_list.push_back(new Item_empty_string("Function",NAME_LEN));
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
- Item_empty_string *definition=
-- new Item_empty_string("Create Function", max(buffer.length(),1024));
-+ new Item_empty_string("Create Function", MYSQL_MAX(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
-@@ -2380,7 +2380,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/sql_acl.cc 2008-01-15 02:53:58.136704647 -0800
-@@ -676,7 +676,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/sql/sql_analyse.cc 2008-01-15 03:07:35.602475062 -0800
-@@ -281,16 +281,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1044,7 +1044,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1069,7 +1069,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1186,7 +1186,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/sql/sql_cache.cc 2008-01-15 03:07:17.752468035 -0800
-@@ -753,7 +753,7 @@
-
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2076,7 +2076,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block = allocate_block(max(align_len,
-+ Query_cache_block *block = allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),
- 1, 0, under_guard);
- if (block != 0)
-@@ -2141,7 +2141,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2173,7 +2173,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((void*) (((byte*) last_block) + last_block->used), (void*) data,
-@@ -2262,8 +2262,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2295,7 +2295,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size,
- 1)))
-@@ -2305,7 +2305,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -2630,7 +2630,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu, uder_guard %d",
- len, not_less,min,under_guard));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/sql/sql_class.cc 2008-01-15 02:53:58.146704342 -0800
-@@ -1315,7 +1315,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/sql_client.cc 2008-01-15 02:53:58.146704342 -0800
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2007-12-14 12:43:32.000000000 -0800
-+++ mysql/sql/sql_load.cc 2008-01-15 02:55:25.622528525 -0800
-@@ -917,7 +917,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2007-12-14 12:43:41.000000000 -0800
-+++ mysql/sql/sql_parse.cc 2008-01-15 02:55:25.626717333 -0800
-@@ -5804,7 +5804,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7232,7 +7232,7 @@
- char command[80];
- Lex_input_stream *lip= thd->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/sql/sql_prepare.cc 2008-01-15 02:55:53.545869502 -0800
-@@ -228,7 +228,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql/sql_repl.cc 2008-01-15 02:55:53.545869502 -0800
-@@ -1180,12 +1180,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1323,7 +1323,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/sql_select.cc 2008-01-15 03:04:34.729142890 -0800
-@@ -2715,7 +2715,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3578,7 +3578,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3601,7 +3601,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3750,7 +3750,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->records, 100);
- }
- }
- /*
-@@ -4064,7 +4064,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4208,7 +4208,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5107,7 +5107,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -9021,7 +9021,7 @@
- item->unsigned_flag) - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- len -= item->decimals - dec; // corrected value fits
- }
-@@ -13109,7 +13109,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -13227,7 +13227,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql/sql_show.cc 2008-01-15 03:02:45.792495815 -0800
-@@ -428,14 +428,14 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
- else
- {
- field_list.push_back(new Item_empty_string("Table",NAME_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1390,7 +1390,7 @@
- the comment in sql_class.h why this prevents crashes in possible
- races with query_length
- */
-- uint length= min(max_query_length, tmp->query_length);
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length);
- thd_info->query=(char*) thd->strmake(tmp->query,length);
- }
- thread_infos.append(thd_info);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/sql/sql_string.cc 2008-01-15 02:55:53.559192993 -0800
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -906,7 +906,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2007-12-14 12:43:14.000000000 -0800
-+++ mysql/sql/sql_table.cc 2008-01-15 02:55:53.559192993 -0800
-@@ -1355,7 +1355,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2007-12-14 12:56:33.000000000 -0800
-+++ mysql/sql/sql_yacc.cc 2008-01-15 02:55:53.572525507 -0800
-@@ -14535,7 +14535,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -14551,7 +14551,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[0].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/sql/sql_yacc.yy 2008-01-15 02:55:53.579192451 -0800
-@@ -1452,7 +1452,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1462,7 +1462,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/stacktrace.c mysql/sql/stacktrace.c
---- mysql.orig/sql/stacktrace.c 2007-12-14 12:43:14.000000000 -0800
-+++ mysql/sql/stacktrace.c 2008-01-15 02:55:53.579192451 -0800
-@@ -146,7 +146,7 @@
-
- if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (gptr) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/thr_malloc.cc 2008-01-15 02:55:53.579192451 -0800
-@@ -103,7 +103,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/sql/tztime.cc 2008-01-15 02:55:53.582526325 -0800
-@@ -167,7 +167,7 @@
- char buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1866,7 +1866,7 @@
- unsigned char types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
-
- DBUG_ENTER("tz_load_from_open_tables");
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/unireg.cc 2008-01-15 02:55:53.582526325 -0800
-@@ -360,7 +360,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -579,7 +579,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql-common/client.c 2008-01-15 02:55:53.582526325 -0800
-@@ -630,7 +630,7 @@
- pos+= SQLSTATE_LENGTH+1;
- }
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2026,7 +2026,7 @@
- goto error;
- }
- memcpy(&sock_addr.sin_addr, hp->h_addr,
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- }
- sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql-common/my_time.c 2008-01-15 02:55:53.585859414 -0800
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2007-12-14 12:42:50.000000000 -0800
-+++ mysql/strings/ctype-big5.c 2008-01-15 03:23:09.812731349 -0800
-@@ -253,7 +253,7 @@
- const uchar *b, uint b_length,
- my_bool b_is_prefix)
- {
-- uint length= min(a_length, b_length);
-+ uint length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, uint b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- uint length= min(a_length, b_length);
-+ uint length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/strings/ctype-bin.c 2008-01-15 03:22:59.871697030 -0800
-@@ -80,7 +80,7 @@
- const uchar *t, uint tlen,
- my_bool t_is_prefix)
- {
-- uint len=min(slen,tlen);
-+ uint len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, uint tlen,
- my_bool t_is_prefix)
- {
-- uint len=min(slen,tlen);
-+ uint len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -402,7 +402,7 @@
- const uchar *src, uint srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -415,7 +415,7 @@
- const uchar *src, uint srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/strings/ctype-gbk.c 2008-01-15 03:22:50.485708147 -0800
-@@ -2616,7 +2616,7 @@
- const uchar *b, uint b_length,
- my_bool b_is_prefix)
- {
-- uint length= min(a_length, b_length);
-+ uint length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, uint b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- uint length= min(a_length, b_length);
-+ uint length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/strings/ctype-mb.c 2008-01-15 03:22:36.899082525 -0800
-@@ -364,7 +364,7 @@
- const uchar *t, uint tlen,
- my_bool t_is_prefix)
- {
-- uint len=min(slen,tlen);
-+ uint len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -408,7 +408,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -447,7 +447,7 @@
- const uchar *src, uint srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/strings/ctype-simple.c 2008-01-15 03:22:31.829033671 -0800
-@@ -153,7 +153,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -865,7 +865,7 @@
- val= new_val;
- }
-
-- len= min(len, (uint) (e-p));
-+ len= MYSQL_MIN(len, (uint) (e-p));
- memcpy(dst, p, len);
- return (int) len+sign;
- }
-@@ -918,7 +918,7 @@
- long_val= quo;
- }
-
-- len= min(len, (uint) (e-p));
-+ len= MYSQL_MIN(len, (uint) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1148,7 +1148,7 @@
- {
- uint nbytes= (uint) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/strings/ctype-tis620.c 2008-01-15 03:22:20.655702553 -0800
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar * src, uint srclen)
- {
- uint dstlen= len;
-- len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (uint) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/strings/ctype-uca.c 2008-01-15 03:22:03.369781512 -0800
-@@ -7566,7 +7566,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (uint) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (uint) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/strings/ctype-ucs2.c 2008-01-15 02:59:21.079171475 -0800
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1332,7 +1332,7 @@
- uint nbytes= ((uint) (e-b)) & ~(uint) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1427,7 +1427,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1474,7 +1474,7 @@
- const uchar *src, uint srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/strings/ctype-utf8.c 2008-01-15 02:59:21.082505011 -0800
-@@ -1935,7 +1935,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/strings/decimal.c 2008-01-15 02:59:21.082505011 -0800
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1514,8 +1514,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1526,7 +1526,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1616,7 +1616,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1635,7 +1635,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1684,11 +1684,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1703,7 +1703,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1728,7 +1728,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1757,14 +1757,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1785,7 +1785,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1860,7 +1860,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1895,7 +1895,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2153,11 +2153,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2281,7 +2281,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2319,7 +2319,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/strings/my_vsnprintf.c 2008-01-15 02:59:21.085838998 -0800
-@@ -140,7 +140,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- uint diff= (length- res_length);
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/strings/str2int.c 2008-01-15 02:59:21.085838998 -0800
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2008-01-15 02:51:18.252555000 -0800
-+++ mysql/tests/mysql_client_test.c 2008-01-15 02:59:21.092504605 -0800
-@@ -562,7 +562,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude mysql_client_test.c.orig mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/vio/viosocket.c 2008-01-15 03:18:31.319897345 -0800
-@@ -67,7 +67,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min(vio->read_end - vio->read_pos, size);
-+ rc= MYSQL_MIN(vio->read_end - vio->read_pos, size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
-diff -Nuar --exclude list mysql.orig/heap/hp_create.c mysql/heap/hp_create.c
---- mysql.orig/heap/hp_create.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/heap/hp_create.c 2008-01-15 05:20:18.576923482 -0800
-@@ -215,7 +215,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(byte**) - 1) & ~(sizeof(byte**) - 1);
-diff -Nuar --exclude list mysql.orig/heap/hp_test2.c mysql/heap/hp_test2.c
---- mysql.orig/heap/hp_test2.c 2007-12-14 12:42:50.000000000 -0800
-+++ mysql/heap/hp_test2.c 2008-01-15 05:20:21.899846014 -0800
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar --exclude list mysql.orig/libmysqld/client.c mysql/libmysqld/client.c
---- mysql.orig/libmysqld/client.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/client.c 2008-01-15 05:00:06.807069490 -0800
-@@ -630,7 +630,7 @@
- pos+= SQLSTATE_LENGTH+1;
- }
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2026,7 +2026,7 @@
- goto error;
- }
- memcpy(&sock_addr.sin_addr, hp->h_addr,
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- }
- sock_addr.sin_port = (ushort) htons((ushort) port);
-diff -Nuar --exclude list mysql.orig/libmysqld/examples/mysql.cc mysql/libmysqld/examples/mysql.cc
---- mysql.orig/libmysqld/examples/mysql.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/libmysqld/examples/mysql.cc 2008-01-15 04:54:16.436515243 -0800
-@@ -2501,9 +2501,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -2523,7 +2523,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude list mysql.orig/libmysqld/examples/mysql_client_test.c mysql/libmysqld/examples/mysql_client_test.c
---- mysql.orig/libmysqld/examples/mysql_client_test.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/examples/mysql_client_test.c 2008-01-15 04:53:59.241817964 -0800
-@@ -562,7 +562,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude list mysql.orig/libmysqld/examples/mysqltest.c mysql/libmysqld/examples/mysqltest.c
---- mysql.orig/libmysqld/examples/mysqltest.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/libmysqld/examples/mysqltest.c 2008-01-15 04:53:54.975161976 -0800
-@@ -4548,9 +4548,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude list mysql.orig/libmysqld/field.cc mysql/libmysqld/field.cc
---- mysql.orig/libmysqld/field.cc 2007-12-14 12:42:41.000000000 -0800
-+++ mysql/libmysqld/field.cc 2008-01-15 04:59:59.525947525 -0800
-@@ -49,7 +49,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- /*
- Rules for merging different types of fields in UNION
-@@ -1889,7 +1889,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -1897,7 +1897,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2708,7 +2708,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -2914,7 +2914,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3125,7 +3125,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3338,7 +3338,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3573,7 +3573,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -3750,7 +3750,7 @@
- #endif
- memcpy_fixed((byte*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4085,7 +4085,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -5968,13 +5968,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(0, (int) max_length - fractional);
-+ digits= MYSQL_MAX(0, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(0, (int) digits + exp);
-+ digits= MYSQL_MAX(0, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -5982,7 +5982,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6171,7 +6171,7 @@
-
- char *Field_string::pack(char *to, const char *from, uint max_length)
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -6997,7 +6997,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7142,7 +7142,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8148,7 +8148,7 @@
- String *val_ptr __attribute__((unused)))
- {
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -8204,7 +8204,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -8228,7 +8228,7 @@
- uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -8606,7 +8606,7 @@
- and 19 as length of 4.1 compatible representation.
- */
- length= ((length+1)/2)*2; /* purecov: inspected */
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (fld_default_value)
-diff -Nuar --exclude list mysql.orig/libmysqld/filesort.cc mysql/libmysqld/filesort.cc
---- mysql.orig/libmysqld/filesort.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/libmysqld/filesort.cc 2008-01-15 04:59:40.890111247 -0800
-@@ -175,7 +175,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -197,12 +197,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -976,7 +976,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(byte*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1239,7 +1239,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude list mysql.orig/libmysqld/ha_berkeley.cc mysql/libmysqld/ha_berkeley.cc
---- mysql.orig/libmysqld/ha_berkeley.cc 2007-12-14 12:43:32.000000000 -0800
-+++ mysql/libmysqld/ha_berkeley.cc 2008-01-15 04:59:28.155118105 -0800
-@@ -159,7 +159,7 @@
- */
- if (!berkeley_log_buffer_size)
- {
-- berkeley_log_buffer_size= max(table_cache_size*512,32*1024);
-+ berkeley_log_buffer_size= MYSQL_MAX(table_cache_size*512,32*1024);
- }
- /*
- Berkeley DB require that
-@@ -167,7 +167,7 @@
- */
- berkeley_log_file_size= berkeley_log_buffer_size*4;
- berkeley_log_file_size= MY_ALIGN(berkeley_log_file_size,1024*1024L);
-- berkeley_log_file_size= max(berkeley_log_file_size, 10*1024*1024L);
-+ berkeley_log_file_size= MYSQL_MAX(berkeley_log_file_size, 10*1024*1024L);
-
- if (db_env_create(&db_env,0))
- goto error;
-diff -Nuar --exclude list mysql.orig/libmysqld/ha_federated.cc mysql/libmysqld/ha_federated.cc
---- mysql.orig/libmysqld/ha_federated.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/ha_federated.cc 2008-01-15 04:59:24.729605914 -0800
-@@ -511,7 +511,7 @@
- my_free((gptr) share->scheme, MYF(0));
- share->scheme= 0;
- }
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1086,7 +1086,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= 1;
- DBUG_DUMP("key, start of loop", (char *) ptr, length);
-
-diff -Nuar --exclude list mysql.orig/libmysqld/ha_innodb.cc mysql/libmysqld/ha_innodb.cc
---- mysql.orig/libmysqld/ha_innodb.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/libmysqld/ha_innodb.cc 2008-01-15 04:59:35.739052196 -0800
-@@ -627,7 +627,7 @@
- max_query_len = 300;
- }
-
-- len = min(thd->query_length, max_query_len);
-+ len = MYSQL_MIN(thd->query_length, max_query_len);
-
- if (len > (sizeof(buf) - 1))
- {
-@@ -6900,7 +6900,7 @@
- goto func_exit;
- }
- } else {
-- /* Initialize to max(col) + 1; we use
-+ /* Initialize to MYSQL_MAX(col) + 1; we use
- 'found_next_number_field' below because MySQL in SHOW TABLE
- STATUS does not seem to set 'next_number_field'. The comment
- in table.h says that 'next_number_field' is set when it is
-diff -Nuar --exclude list mysql.orig/libmysqld/ha_myisam.cc mysql/libmysqld/ha_myisam.cc
---- mysql.orig/libmysqld/ha_myisam.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/libmysqld/ha_myisam.cc 2008-01-15 04:59:21.293632296 -0800
-@@ -1411,7 +1411,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude list mysql.orig/libmysqld/ha_myisammrg.cc mysql/libmysqld/ha_myisammrg.cc
---- mysql.orig/libmysqld/ha_myisammrg.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/ha_myisammrg.cc 2008-01-15 04:59:18.685951474 -0800
-@@ -407,7 +407,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- return 0;
-diff -Nuar --exclude list mysql.orig/libmysqld/item_buff.cc mysql/libmysqld/item_buff.cc
---- mysql.orig/libmysqld/item_buff.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/libmysqld/item_buff.cc 2008-01-15 04:59:03.295160585 -0800
-@@ -51,7 +51,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -60,7 +60,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude list mysql.orig/libmysqld/item.cc mysql/libmysqld/item.cc
---- mysql.orig/libmysqld/item.cc 2007-12-14 12:42:41.000000000 -0800
-+++ mysql/libmysqld/item.cc 2008-01-15 04:59:16.415129429 -0800
-@@ -73,7 +73,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -429,9 +429,9 @@
- Item_result restype= result_type();
-
- if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
-- return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
-+ return MYSQL_MIN(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
- DECIMAL_MAX_PRECISION);
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -720,7 +720,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -4774,7 +4774,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -4826,7 +4826,7 @@
- void Item_hex_string::print(String *str)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -6686,12 +6686,12 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-- int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(MYSQL_MAX(prev_decimal_int_part, item->decimal_int_part())
- + decimals, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length(precision, decimals,
-@@ -6722,7 +6722,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -6737,7 +6737,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= FLT_DIG + 6;
-@@ -6754,7 +6754,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude list mysql.orig/libmysqld/item_cmpfunc.cc mysql/libmysqld/item_cmpfunc.cc
---- mysql.orig/libmysqld/item_cmpfunc.cc 2007-12-14 12:43:41.000000000 -0800
-+++ mysql/libmysqld/item_cmpfunc.cc 2008-01-15 04:58:58.609723157 -0800
-@@ -554,7 +554,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1039,7 +1039,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2062,7 +2062,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2073,10 +2073,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2098,8 +2098,8 @@
-
- uint Item_func_ifnull::decimal_precision() const
- {
-- int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int max_int_part=MYSQL_MAX(args[0]->decimal_int_part(),args[1]->decimal_int_part());
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2228,7 +2228,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2272,18 +2272,18 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
- uint Item_func_if::decimal_precision() const
- {
-- int precision=(max(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
-+ int precision=(MYSQL_MAX(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
- decimals);
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2708,7 +2708,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4647,14 +4647,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -4678,14 +4678,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude list mysql.orig/libmysqld/item_func.cc mysql/libmysqld/item_func.cc
---- mysql.orig/libmysqld/item_func.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/libmysqld/item_func.cc 2008-01-15 04:58:29.481801779 -0800
-@@ -539,7 +539,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1155,10 +1155,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- int max_int_part= max(args[0]->decimal_precision() - args[0]->decimals,
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ int max_int_part= MYSQL_MAX(args[0]->decimal_precision() - args[0]->decimals,
- args[1]->decimal_precision() - args[1]->decimals);
-- int precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1266,8 +1266,8 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-- int precision= min(args[0]->decimal_precision() + args[1]->decimal_precision(),
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ int precision= MYSQL_MIN(args[0]->decimal_precision() + args[1]->decimal_precision(),
- DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
- }
-@@ -1315,14 +1315,14 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() + prec_increment,
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() + prec_increment,
- DECIMAL_MAX_PRECISION);
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
- }
-@@ -1336,7 +1336,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1458,8 +1458,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1977,7 +1977,7 @@
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
- max_length= args[0]->max_length;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- hybrid_type= REAL_RESULT;
- return;
- }
-@@ -1986,7 +1986,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2003,7 +2003,7 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-@@ -2110,7 +2110,7 @@
- longlong dec= args[1]->val_int();
- if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
- {
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- decimals= (uint8) dec; // to get correct output
- }
- else if (dec < INT_MIN)
-@@ -2965,7 +2965,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2974,7 +2974,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude list mysql.orig/libmysqld/item_strfunc.cc mysql/libmysqld/item_strfunc.cc
---- mysql.orig/libmysqld/item_strfunc.cc 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/libmysqld/item_strfunc.cc 2008-01-15 04:58:11.691803743 -0800
-@@ -1138,7 +1138,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1158,7 +1158,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1832,7 +1832,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -2933,11 +2933,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -Nuar --exclude list mysql.orig/libmysqld/item_sum.cc mysql/libmysqld/item_sum.cc
---- mysql.orig/libmysqld/item_sum.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/libmysqld/item_sum.cc 2008-01-15 04:58:04.956601763 -0800
-@@ -1063,7 +1063,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1126,15 +1126,15 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1313,13 +1313,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
-
-@@ -3380,7 +3380,7 @@
- duplicate values (according to the syntax of this function). If there
- is no DISTINCT or ORDER BY clauses, we don't create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length, compare_key, 0, NULL, (void*) this);
- }
-diff -Nuar --exclude list mysql.orig/libmysqld/item_timefunc.cc mysql/libmysqld/item_timefunc.cc
---- mysql.orig/libmysqld/item_timefunc.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/libmysqld/item_timefunc.cc 2008-01-15 04:57:57.533455689 -0800
-@@ -306,14 +306,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -322,7 +322,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -339,15 +339,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -358,14 +358,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -373,7 +373,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -425,7 +425,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -437,7 +437,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- strict_week_number && !week_number ||
- week_number > 53)
-@@ -449,7 +449,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -594,7 +594,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_time");
-@@ -1731,7 +1731,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude list mysql.orig/libmysqld/key.cc mysql/libmysqld/key.cc
---- mysql.orig/libmysqld/key.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/libmysqld/key.cc 2008-01-15 04:57:45.439625295 -0800
-@@ -110,13 +110,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image((char*) to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image((char*) to_key, length, Field::itRAW);
-@@ -191,13 +191,13 @@
- else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->set_key_image((char *) from_key, length);
- from_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- memcpy(to_record + key_part->offset, from_key, (size_t) length);
- }
- from_key+= length;
-@@ -257,7 +257,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -311,7 +311,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude list mysql.orig/libmysqld/libmysql.c mysql/libmysqld/libmysql.c
---- mysql.orig/libmysqld/libmysql.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/libmysql.c 2008-01-15 05:00:13.572819445 -0800
-@@ -1558,7 +1558,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3562,7 +3562,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3794,9 +3794,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(14,width), value);
-+ MYSQL_MIN(14,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4113,7 +4113,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4125,7 +4125,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude list mysql.orig/libmysqld/log.cc mysql/libmysqld/log.cc
---- mysql.orig/libmysqld/log.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/libmysqld/log.cc 2008-01-15 04:57:36.468463518 -0800
-@@ -458,7 +458,7 @@
- {
- char *p = fn_ext(log_name);
- uint length=(uint) (p-log_name);
-- strmake(buff,log_name,min(length,FN_REFLEN));
-+ strmake(buff,log_name,MYSQL_MIN(length,FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -2407,7 +2407,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude list mysql.orig/libmysqld/log_event.cc mysql/libmysqld/log_event.cc
---- mysql.orig/libmysqld/log_event.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/libmysqld/log_event.cc 2008-01-15 04:57:31.873287310 -0800
-@@ -772,7 +772,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -1551,7 +1551,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -3936,7 +3936,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- char buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ char buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-diff -Nuar --exclude list mysql.orig/libmysqld/my_time.c mysql/libmysqld/my_time.c
---- mysql.orig/libmysqld/my_time.c 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/libmysqld/my_time.c 2008-01-15 05:00:02.886165492 -0800
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude list mysql.orig/libmysqld/net_serv.cc mysql/libmysqld/net_serv.cc
---- mysql.orig/libmysqld/net_serv.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/net_serv.cc 2008-01-15 04:57:16.804037492 -0800
-@@ -759,7 +759,7 @@
- {
- while (remain > 0)
- {
-- uint length= min(remain, net->max_packet);
-+ uint length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, (char*) net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -930,7 +930,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude list mysql.orig/libmysqld/opt_range.cc mysql/libmysqld/opt_range.cc
---- mysql.orig/libmysqld/opt_range.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/opt_range.cc 2008-01-15 04:57:11.205132367 -0800
-@@ -2446,7 +2446,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -5876,7 +5876,7 @@
- char *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -6765,13 +6765,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -6790,7 +6790,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -6858,7 +6858,7 @@
- }
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -6959,12 +6959,12 @@
- last_range= *(cur_range++);
-
- start_key.key= (const byte*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const byte*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
- prefix we want to find all keys with this prefix
-@@ -7260,7 +7260,7 @@
- KEY_PART *key_part = key_parts,
- *key_part_end= key_part+used_key_parts;
-
-- for (offset= 0, end = min(range_arg->min_length, range_arg->max_length) ;
-+ for (offset= 0, end = MYSQL_MIN(range_arg->min_length, range_arg->max_length) ;
- offset < end && key_part != key_part_end ;
- offset+= key_part++->store_length)
- {
-@@ -7835,7 +7835,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- cur_used_key_parts.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -8440,9 +8440,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude list mysql.orig/libmysqld/protocol.cc mysql/libmysqld/protocol.cc
---- mysql.orig/libmysqld/protocol.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/protocol.cc 2008-01-15 04:57:24.735204042 -0800
-@@ -190,7 +190,7 @@
- length=sizeof(text_pos)-1;
- #endif
- length=my_vsnprintf(my_const_cast(char*) (text_pos),
-- min(length, sizeof(net->last_error)),
-+ MYSQL_MIN(length, sizeof(net->last_error)),
- format,args);
- va_end(args);
-
-@@ -296,7 +296,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(thd->total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(thd->total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -371,7 +371,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= (thd->spcont ? 0 : min(thd->total_warn_count, 65535));
-+ uint tmp= (thd->spcont ? 0 : MYSQL_MIN(thd->total_warn_count, 65535));
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude list mysql.orig/libmysqld/set_var.cc mysql/libmysqld/set_var.cc
---- mysql.orig/libmysqld/set_var.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/libmysqld/set_var.cc 2008-01-15 04:55:11.850517748 -0800
-@@ -1813,7 +1813,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -Nuar --exclude list mysql.orig/libmysqld/sp_head.cc mysql/libmysqld/sp_head.cc
---- mysql.orig/libmysqld/sp_head.cc 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/libmysqld/sp_head.cc 2008-01-15 04:54:24.706976834 -0800
-@@ -2161,7 +2161,7 @@
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
- // 1024 is for not to confuse old clients
- Item_empty_string *definition=
-- new Item_empty_string("Create Procedure", max(buffer.length(),1024));
-+ new Item_empty_string("Create Procedure", MYSQL_MAX(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
-@@ -2231,7 +2231,7 @@
- field_list.push_back(new Item_empty_string("Function",NAME_LEN));
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode_len));
- Item_empty_string *definition=
-- new Item_empty_string("Create Function", max(buffer.length(),1024));
-+ new Item_empty_string("Create Function", MYSQL_MAX(buffer.length(),1024));
- definition->maybe_null= TRUE;
- field_list.push_back(definition);
-
-@@ -2380,7 +2380,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_acl.cc mysql/libmysqld/sql_acl.cc
---- mysql.orig/libmysqld/sql_acl.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/sql_acl.cc 2008-01-15 04:56:49.898477593 -0800
-@@ -676,7 +676,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_analyse.cc mysql/libmysqld/sql_analyse.cc
---- mysql.orig/libmysqld/sql_analyse.cc 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/libmysqld/sql_analyse.cc 2008-01-15 04:56:42.522668328 -0800
-@@ -281,16 +281,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1044,7 +1044,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1069,7 +1069,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1186,7 +1186,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_cache.cc mysql/libmysqld/sql_cache.cc
---- mysql.orig/libmysqld/sql_cache.cc 2007-12-14 12:43:33.000000000 -0800
-+++ mysql/libmysqld/sql_cache.cc 2008-01-15 04:56:28.868480095 -0800
-@@ -753,7 +753,7 @@
-
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2076,7 +2076,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block = allocate_block(max(align_len,
-+ Query_cache_block *block = allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),
- 1, 0, under_guard);
- if (block != 0)
-@@ -2141,7 +2141,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2173,7 +2173,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((void*) (((byte*) last_block) + last_block->used), (void*) data,
-@@ -2262,8 +2262,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2295,7 +2295,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size,
- 1)))
-@@ -2305,7 +2305,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -2630,7 +2630,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu, uder_guard %d",
- len, not_less,min,under_guard));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_class.cc mysql/libmysqld/sql_class.cc
---- mysql.orig/libmysqld/sql_class.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/libmysqld/sql_class.cc 2008-01-15 04:56:11.311817643 -0800
-@@ -1315,7 +1315,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_load.cc mysql/libmysqld/sql_load.cc
---- mysql.orig/libmysqld/sql_load.cc 2007-12-14 12:43:32.000000000 -0800
-+++ mysql/libmysqld/sql_load.cc 2008-01-15 04:56:45.753606953 -0800
-@@ -917,7 +917,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_parse.cc mysql/libmysqld/sql_parse.cc
---- mysql.orig/libmysqld/sql_parse.cc 2007-12-14 12:43:41.000000000 -0800
-+++ mysql/libmysqld/sql_parse.cc 2008-01-15 04:56:08.288471890 -0800
-@@ -858,7 +858,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-@@ -5804,7 +5804,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7232,7 +7232,7 @@
- char command[80];
- Lex_input_stream *lip= thd->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_prepare.cc mysql/libmysqld/sql_prepare.cc
---- mysql.orig/libmysqld/sql_prepare.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/libmysqld/sql_prepare.cc 2008-01-15 04:56:01.889508255 -0800
-@@ -228,7 +228,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_select.cc mysql/libmysqld/sql_select.cc
---- mysql.orig/libmysqld/sql_select.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/sql_select.cc 2008-01-15 04:55:58.115149679 -0800
-@@ -2715,7 +2715,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3578,7 +3578,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3601,7 +3601,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3750,7 +3750,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->records, 100);
- }
- }
- /*
-@@ -4064,7 +4064,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4208,7 +4208,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5107,7 +5107,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -9008,7 +9008,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -9021,7 +9021,7 @@
- item->unsigned_flag) - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- len -= item->decimals - dec; // corrected value fits
- }
-@@ -9728,7 +9728,7 @@
- table->s->max_rows= ~(ha_rows) 0;
- else
- table->s->max_rows= (ha_rows) (((table->s->db_type == DB_TYPE_HEAP) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size)/
- table->s->reclength);
-@@ -13109,7 +13109,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -13227,7 +13227,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_show.cc mysql/libmysqld/sql_show.cc
---- mysql.orig/libmysqld/sql_show.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/libmysqld/sql_show.cc 2008-01-15 04:55:18.649317055 -0800
-@@ -428,14 +428,14 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
- else
- {
- field_list.push_back(new Item_empty_string("Table",NAME_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1390,7 +1390,7 @@
- the comment in sql_class.h why this prevents crashes in possible
- races with query_length
- */
-- uint length= min(max_query_length, tmp->query_length);
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length);
- thd_info->query=(char*) thd->strmake(tmp->query,length);
- }
- thread_infos.append(thd_info);
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_string.cc mysql/libmysqld/sql_string.cc
---- mysql.orig/libmysqld/sql_string.cc 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/libmysqld/sql_string.cc 2008-01-15 04:55:07.147346327 -0800
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -906,7 +906,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_table.cc mysql/libmysqld/sql_table.cc
---- mysql.orig/libmysqld/sql_table.cc 2007-12-14 12:43:14.000000000 -0800
-+++ mysql/libmysqld/sql_table.cc 2008-01-15 04:54:55.981822019 -0800
-@@ -1355,7 +1355,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude list mysql.orig/libmysqld/sql_yacc.cc mysql/libmysqld/sql_yacc.cc
---- mysql.orig/libmysqld/sql_yacc.cc 2007-12-14 12:56:33.000000000 -0800
-+++ mysql/libmysqld/sql_yacc.cc 2008-01-15 04:54:52.908481533 -0800
-@@ -14535,7 +14535,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -14551,7 +14551,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[0].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude list mysql.orig/libmysqld/stacktrace.c mysql/libmysqld/stacktrace.c
---- mysql.orig/libmysqld/stacktrace.c 2007-12-14 12:43:14.000000000 -0800
-+++ mysql/libmysqld/stacktrace.c 2008-01-15 04:54:38.816500221 -0800
-@@ -146,7 +146,7 @@
-
- if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (gptr) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar --exclude list mysql.orig/libmysqld/thr_malloc.cc mysql/libmysqld/thr_malloc.cc
---- mysql.orig/libmysqld/thr_malloc.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysqld/thr_malloc.cc 2008-01-15 04:54:48.189313451 -0800
-@@ -103,7 +103,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude list mysql.orig/libmysqld/tztime.cc mysql/libmysqld/tztime.cc
---- mysql.orig/libmysqld/tztime.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/libmysqld/tztime.cc 2008-01-15 04:54:35.013363373 -0800
-@@ -167,7 +167,7 @@
- char buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1866,7 +1866,7 @@
- unsigned char types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
-
- DBUG_ENTER("tz_load_from_open_tables");
-diff -Nuar --exclude list mysql.orig/libmysqld/unireg.cc mysql/libmysqld/unireg.cc
---- mysql.orig/libmysqld/unireg.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/libmysqld/unireg.cc 2008-01-15 04:54:43.965979033 -0800
-@@ -360,7 +360,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -579,7 +579,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude list mysql.orig/libmysql_r/libmysql.c mysql/libmysql_r/libmysql.c
---- mysql.orig/libmysql_r/libmysql.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/libmysql_r/libmysql.c 2008-01-15 05:00:22.418590356 -0800
-@@ -1558,7 +1558,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3562,7 +3562,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3794,9 +3794,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(14,width), value);
-+ MYSQL_MIN(14,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4113,7 +4113,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4125,7 +4125,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude list mysql.orig/myisam/mi_cache.c mysql/myisam/mi_cache.c
---- mysql.orig/myisam/mi_cache.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/myisam/mi_cache.c 2008-01-15 04:53:28.461310784 -0800
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length,(uint) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length,(uint) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar --exclude list mysql.orig/myisam/mi_check.c mysql/myisam/mi_check.c
---- mysql.orig/myisam/mi_check.c 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/myisam/mi_check.c 2008-01-15 04:53:12.065157033 -0800
-@@ -2163,7 +2163,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2319,7 +2319,7 @@
- sort_param.wordlist=NULL;
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2746,7 +2746,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3932,7 +3932,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-@@ -4283,7 +4283,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar --exclude list mysql.orig/myisam/mi_create.c mysql/myisam/mi_create.c
---- mysql.orig/myisam/mi_create.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/myisam/mi_create.c 2008-01-15 04:53:18.555165949 -0800
-@@ -517,7 +517,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -551,7 +551,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar --exclude list mysql.orig/myisam/mi_dynrec.c mysql/myisam/mi_dynrec.c
---- mysql.orig/myisam/mi_dynrec.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/myisam/mi_dynrec.c 2008-01-15 04:53:22.159320450 -0800
-@@ -668,7 +668,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar --exclude list mysql.orig/myisam/mi_extra.c mysql/myisam/mi_extra.c
---- mysql.orig/myisam/mi_extra.c 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/myisam/mi_extra.c 2008-01-15 04:53:39.755153495 -0800
-@@ -120,7 +120,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar --exclude list mysql.orig/myisam/mi_key.c mysql/myisam/mi_key.c
---- mysql.orig/myisam/mi_key.c 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/myisam/mi_key.c 2008-01-15 04:53:34.287164618 -0800
-@@ -228,7 +228,7 @@
- old+=keyseg->length, keyseg++)
- {
- enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
-- uint length=min((uint) keyseg->length,(uint) k_length);
-+ uint length=MYSQL_MIN((uint) keyseg->length,(uint) k_length);
- uint char_length;
- uchar *pos;
- CHARSET_INFO *cs=keyseg->charset;
-diff -Nuar --exclude list mysql.orig/myisam/mi_open.c mysql/myisam/mi_open.c
---- mysql.orig/myisam/mi_open.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/myisam/mi_open.c 2008-01-15 04:53:48.265981858 -0800
-@@ -306,7 +306,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- for (i=0 ; i < keys ; i++)
-@@ -475,7 +475,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
-
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
-@@ -676,10 +676,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar --exclude list mysql.orig/myisam/mi_packrec.c mysql/myisam/mi_packrec.c
---- mysql.orig/myisam/mi_packrec.c 2007-12-14 12:43:25.000000000 -0800
-+++ mysql/myisam/mi_packrec.c 2008-01-15 05:00:51.535962630 -0800
-@@ -676,7 +676,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1391,7 +1391,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar --exclude list mysql.orig/myisam/mi_test1.c mysql/myisam/mi_test1.c
---- mysql.orig/myisam/mi_test1.c 2007-12-14 12:42:50.000000000 -0800
-+++ mysql/myisam/mi_test1.c 2008-01-15 04:51:24.163954438 -0800
-@@ -433,7 +433,7 @@
- uint tmp;
- char *ptr;;
- sprintf(blob_record,"... row: %d", rownr);
-- strappend(blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend(blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen(blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar --exclude list mysql.orig/myisam/mi_test2.c mysql/myisam/mi_test2.c
---- mysql.orig/myisam/mi_test2.c 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/myisam/mi_test2.c 2008-01-15 04:51:15.429059961 -0800
-@@ -591,7 +591,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar --exclude list mysql.orig/myisam/myisamlog.c mysql/myisam/myisamlog.c
---- mysql.orig/myisam/myisamlog.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/myisam/myisamlog.c 2008-01-15 04:51:05.047004548 -0800
-@@ -88,7 +88,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar --exclude list mysql.orig/myisam/myisampack.c mysql/myisam/myisampack.c
---- mysql.orig/myisam/myisampack.c 2007-12-14 12:42:59.000000000 -0800
-+++ mysql/myisam/myisampack.c 2008-01-15 05:00:55.035108740 -0800
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar --exclude list mysql.orig/myisam/rt_mbr.c mysql/myisam/rt_mbr.c
---- mysql.orig/myisam/rt_mbr.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/myisam/rt_mbr.c 2008-01-15 04:52:21.735993423 -0800
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar --exclude list mysql.orig/myisam/sort.c mysql/myisam/sort.c
---- mysql.orig/myisam/sort.c 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/myisam/sort.c 2008-01-15 04:52:42.581836127 -0800
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -813,7 +813,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(byte*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -834,7 +834,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar --exclude list mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/mysys/my_conio.c 2008-01-15 05:16:58.673301325 -0800
-@@ -167,10 +167,10 @@
- later we may want to cycle from min(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (unsigned long)csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (unsigned long)csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, plen, NULL))
- {
- result= NULL;
-diff -Nuar --exclude list mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/mysys/my_static.h 2008-01-15 05:17:08.126484924 -0800
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar --exclude list mysql.orig/mysys/raid.cc mysql/mysys/raid.cc
---- mysql.orig/mysys/raid.cc 2007-12-14 12:42:50.000000000 -0800
-+++ mysql/mysys/raid.cc 2008-01-15 05:17:16.075010698 -0800
-@@ -558,7 +558,7 @@
- DBUG_RETURN(-1);
- _seek_vector[_this_block]=RAID_SEEK_DONE;
- }
-- ReadNowCount = min(Count, _remaining_bytes);
-+ ReadNowCount = MYSQL_MIN(Count, _remaining_bytes);
- GotBytes = my_write(_fd_vector[_this_block], bufptr, ReadNowCount,
- MyFlags);
- DBUG_PRINT("loop",("Wrote bytes: %d", GotBytes));
-@@ -599,7 +599,7 @@
- _seek_vector[_this_block]=RAID_SEEK_DONE;
- }
- // and read
-- ReadNowCount = min(Count, _remaining_bytes);
-+ ReadNowCount = MYSQL_MIN(Count, _remaining_bytes);
- GotBytes = my_read(_fd_vector[_this_block], bufptr, ReadNowCount,
- MyFlags & ~(MY_NABP | MY_FNABP));
- DBUG_PRINT("loop",("Got bytes: %u", GotBytes));
-@@ -631,7 +631,7 @@
- Calculate();
- for (uint i = _this_block ; (i < _raid_chunks) && length ; i++ )
- {
-- uint ReadNowCount = min(length, _remaining_bytes);
-+ uint ReadNowCount = MYSQL_MIN(length, _remaining_bytes);
- uint GotBytes = my_lock(_fd_vector[i], locktype, bufptr, ReadNowCount,
- MyFlags);
- if ((int) GotBytes == -1)
-diff -Nuar --exclude list mysql.orig/sql/ha_berkeley.cc mysql/sql/ha_berkeley.cc
---- mysql.orig/sql/ha_berkeley.cc 2007-12-14 12:43:32.000000000 -0800
-+++ mysql/sql/ha_berkeley.cc 2008-01-15 05:18:05.347377416 -0800
-@@ -159,7 +159,7 @@
- */
- if (!berkeley_log_buffer_size)
- {
-- berkeley_log_buffer_size= max(table_cache_size*512,32*1024);
-+ berkeley_log_buffer_size= MYSQL_MAX(table_cache_size*512,32*1024);
- }
- /*
- Berkeley DB require that
-@@ -167,7 +167,7 @@
- */
- berkeley_log_file_size= berkeley_log_buffer_size*4;
- berkeley_log_file_size= MY_ALIGN(berkeley_log_file_size,1024*1024L);
-- berkeley_log_file_size= max(berkeley_log_file_size, 10*1024*1024L);
-+ berkeley_log_file_size= MYSQL_MAX(berkeley_log_file_size, 10*1024*1024L);
-
- if (db_env_create(&db_env,0))
- goto error;
-diff -Nuar --exclude list mysql.orig/sql/ha_federated.cc mysql/sql/ha_federated.cc
---- mysql.orig/sql/ha_federated.cc 2007-12-14 12:42:51.000000000 -0800
-+++ mysql/sql/ha_federated.cc 2008-01-15 05:18:11.602504971 -0800
-@@ -511,7 +511,7 @@
- my_free((gptr) share->scheme, MYF(0));
- share->scheme= 0;
- }
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1086,7 +1086,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= 1;
- DBUG_DUMP("key, start of loop", (char *) ptr, length);
-
-diff -Nuar --exclude list mysql.orig/sql/ha_innodb.cc mysql/sql/ha_innodb.cc
---- mysql.orig/sql/ha_innodb.cc 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/sql/ha_innodb.cc 2008-01-15 05:18:16.465356748 -0800
-@@ -627,7 +627,7 @@
- max_query_len = 300;
- }
-
-- len = min(thd->query_length, max_query_len);
-+ len = MYSQL_MIN(thd->query_length, max_query_len);
-
- if (len > (sizeof(buf) - 1))
- {
-diff -Nuar --exclude list mysql.orig/sql/ha_myisam.cc mysql/sql/ha_myisam.cc
---- mysql.orig/sql/ha_myisam.cc 2007-12-14 12:43:13.000000000 -0800
-+++ mysql/sql/ha_myisam.cc 2008-01-15 05:18:19.521682056 -0800
-@@ -1411,7 +1411,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude list mysql.orig/sql/ha_myisammrg.cc mysql/sql/ha_myisammrg.cc
---- mysql.orig/sql/ha_myisammrg.cc 2007-12-14 12:43:15.000000000 -0800
-+++ mysql/sql/ha_myisammrg.cc 2008-01-15 05:18:21.855015186 -0800
-@@ -407,7 +407,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- return 0;
-diff -Nuar --exclude list mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2008-01-15 04:39:41.921904000 -0800
-+++ mysql/sql/ha_ndbcluster.cc 2008-01-15 05:18:28.705535179 -0800
-@@ -6248,10 +6248,10 @@
- sql_print_error("unpackfrm: ver != 1");
- DBUG_RETURN(1);
- }
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- {
- sql_print_error("unpackfrm: my_malloc(%u)",
-- (unsigned int)max(orglen, complen));
-+ (unsigned int)MYSQL_MAX(orglen, complen));
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- }
- memcpy(data, blob->data, complen);
-diff -Nuar --exclude list mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2008-01-15 04:39:41.921904000 -0800
-+++ mysql/sql/item.cc 2008-01-15 05:18:30.751681400 -0800
-@@ -4826,7 +4826,7 @@
- void Item_hex_string::print(String *str)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-diff -Nuar --exclude list mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2008-01-15 04:39:41.931903000 -0800
-+++ mysql/sql/log_event.cc 2008-01-15 05:18:33.198338005 -0800
-@@ -1551,7 +1551,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-diff -Nuar --exclude list mysql.orig/sql/mysql_tzinfo_to_sql.cc mysql/sql/mysql_tzinfo_to_sql.cc
---- mysql.orig/sql/mysql_tzinfo_to_sql.cc 2007-12-14 12:43:51.000000000 -0800
-+++ mysql/sql/mysql_tzinfo_to_sql.cc 2008-01-15 05:18:38.366693436 -0800
-@@ -167,7 +167,7 @@
- char buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1866,7 +1866,7 @@
- unsigned char types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
-
- DBUG_ENTER("tz_load_from_open_tables");
-diff -Nuar --exclude list mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2008-01-15 04:39:41.938571000 -0800
-+++ mysql/sql/slave.cc 2008-01-15 05:18:41.308901512 -0800
-@@ -2723,7 +2723,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -2733,7 +2733,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar --exclude list mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2008-01-15 04:39:41.945237000 -0800
-+++ mysql/sql/sql_parse.cc 2008-01-15 05:20:25.791685282 -0800
-@@ -858,7 +858,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar --exclude list mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2008-01-15 04:39:41.951904000 -0800
-+++ mysql/sql/sql_select.cc 2008-01-15 05:18:56.591678282 -0800
-@@ -6371,7 +6371,7 @@
- a correlated subquery itself, but has subqueries, we can free it
- fully and also free JOINs of all its subqueries. The exception
- is a subquery in SELECT list, e.g:
-- SELECT a, (select max(b) from t1) group by c
-+ SELECT a, (select MYSQLMYSQL__MAX(b) from t1) group by c
- This subquery will not be evaluated at first sweep and its value will
- not be inserted into the temporary table. Instead, it's evaluated
- when selecting from the temporary table. Therefore, it can't be freed
-@@ -9008,7 +9008,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -9728,7 +9728,7 @@
- table->s->max_rows= ~(ha_rows) 0;
- else
- table->s->max_rows= (ha_rows) (((table->s->db_type == DB_TYPE_HEAP) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size)/
- table->s->reclength);
-diff -Nuar mysql.orig/ndb/src/common/portlib/NdbTCP.cpp mysql/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/ndb/src/common/portlib/NdbTCP.cpp 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/ndb/src/common/portlib/NdbTCP.cpp 2008-01-15 06:17:04.021329045 -0800
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp mysql/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp
---- mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp 2007-12-14 12:43:00.000000000 -0800
-+++ mysql/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp 2008-01-15 06:16:30.076634382 -0800
-@@ -54,7 +54,7 @@
- ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
- // sizes
- const unsigned size1 = ah(searchKey).getDataSize();
-- const unsigned size2 = min(ah(entryData).getDataSize(), len2);
-+ const unsigned size2 = MYSQL_MIN(ah(entryData).getDataSize(), len2);
- len2 -= size2;
- // compare
- NdbSqlUtil::Cmp* const cmp = c_sqlCmp[start];
-@@ -139,7 +139,7 @@
- ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
- // sizes
- const unsigned size1 = ah(boundInfo).getDataSize();
-- const unsigned size2 = min(ah(entryData).getDataSize(), len2);
-+ const unsigned size2 = MYSQL_MIN(ah(entryData).getDataSize(), len2);
- len2 -= size2;
- // compare
- NdbSqlUtil::Cmp* const cmp = c_sqlCmp[index];
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2007-12-14 12:43:42.000000000 -0800
-+++ mysql/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2008-01-15 06:16:35.579748782 -0800
-@@ -242,7 +242,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp mysql/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp
---- mysql.orig/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp 2007-12-14 12:43:24.000000000 -0800
-+++ mysql/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp 2008-01-15 06:17:09.381704725 -0800
-@@ -251,7 +251,7 @@
- selectNode(leafNode, leafLoc);
- if (semiNode.getOccup() < tree.m_minOccup) {
- jam();
-- unsigned cnt = min(leafNode.getOccup(), tree.m_minOccup - semiNode.getOccup());
-+ unsigned cnt = MYSQL_MIN(leafNode.getOccup(), tree.m_minOccup - semiNode.getOccup());
- nodeSlide(semiNode, leafNode, cnt, i);
- if (leafNode.getOccup() == 0) {
- // remove empty leaf
-@@ -281,7 +281,7 @@
- jam();
- if (parentNode.getOccup() < tree.m_minOccup) {
- jam();
-- unsigned cnt = min(leafNode.getOccup(), tree.m_minOccup - parentNode.getOccup());
-+ unsigned cnt = MYSQL_MIN(leafNode.getOccup(), tree.m_minOccup - parentNode.getOccup());
- nodeSlide(parentNode, leafNode, cnt, i);
- }
- }
diff --git a/07110_all_mysql_gcc-4.2_5.1.39.patch b/07110_all_mysql_gcc-4.2_5.1.39.patch
deleted file mode 100644
index f791dd3..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.39.patch
+++ /dev/null
@@ -1,7917 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -urN mysql-old/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-old/client/mysqlbinlog.cc 2009-12-10 00:54:18.744801535 -0100
-+++ mysql/client/mysqlbinlog.cc 2009-12-10 00:57:22.925800633 -0100
-@@ -34,6 +34,7 @@
- #include "mysql_priv.h"
- #include "log_event.h"
- #include "sql_common.h"
-+#include "my_global.h"
-
- #define BIN_LOG_HEADER_SIZE 4
- #define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
-@@ -1924,7 +1925,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -urN mysql-old/client/mysql.cc mysql/client/mysql.cc
---- mysql-old/client/mysql.cc 2009-12-10 00:54:18.744801535 -0100
-+++ mysql/client/mysql.cc 2009-12-10 00:57:22.926584989 -0100
-@@ -3281,9 +3281,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3303,7 +3303,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -urN mysql-old/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-old/client/mysqldump.c 2009-12-10 00:54:18.743800406 -0100
-+++ mysql/client/mysqldump.c 2009-12-10 00:57:22.929800060 -0100
-@@ -808,7 +808,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff), err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4486,7 +4486,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff), var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff), var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -urN mysql-old/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-old/client/mysqltest.cc 2009-12-10 00:54:18.743800406 -0100
-+++ mysql/client/mysqltest.cc 2009-12-10 00:57:22.933924977 -0100
-@@ -5302,9 +5302,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -urN mysql-old/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-old/client/mysql_upgrade.c 2009-12-10 00:54:18.744801535 -0100
-+++ mysql/client/mysql_upgrade.c 2009-12-10 00:57:22.937549888 -0100
-@@ -502,7 +502,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -urN mysql-old/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-old/client/sql_string.cc 2009-12-10 00:54:18.744801535 -0100
-+++ mysql/client/sql_string.cc 2009-12-10 00:57:22.937549888 -0100
-@@ -659,7 +659,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -urN mysql-old/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-old/dbug/dbug.c 2009-12-10 00:54:18.750801052 -0100
-+++ mysql/dbug/dbug.c 2009-12-10 00:57:22.939550060 -0100
-@@ -1202,7 +1202,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -urN mysql-old/extra/yassl/src/handshake.cpp mysql/extra/yassl/src/handshake.cpp
---- mysql-old/extra/yassl/src/handshake.cpp 2009-12-10 00:54:18.747800268 -0100
-+++ mysql/extra/yassl/src/handshake.cpp 2009-12-10 00:57:22.940550053 -0100
-@@ -26,6 +26,7 @@
- #include "runtime.hpp"
- #include "handshake.hpp"
- #include "yassl_int.hpp"
-+#include "my_global.h"
-
-
- namespace yaSSL {
-@@ -936,7 +937,7 @@
- int sent = 0;
-
- for (;;) {
-- int len = min(sz - sent, MAX_RECORD_SIZE);
-+ int len = MYSQL_MIN(sz - sent, MAX_RECORD_SIZE);
- output_buffer out;
- input_buffer tmp;
-
-diff -urN mysql-old/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-old/extra/yassl/src/ssl.cpp 2009-12-10 00:54:18.747800268 -0100
-+++ mysql/extra/yassl/src/ssl.cpp 2009-12-10 00:57:22.941550523 -0100
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-@@ -320,7 +321,7 @@
-
- int SSL_read(SSL* ssl, void* buffer, int sz)
- {
-- Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
-+ Data data(MYSQL_MIN(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
- return receiveData(*ssl, data);
- }
-
-@@ -618,7 +619,7 @@
- if (!name->GetName()) return buffer;
-
- int len = (int)strlen(name->GetName()) + 1;
-- int copySz = min(len, sz);
-+ int copySz = MYSQL_MIN(len, sz);
-
- if (!buffer) {
- buffer = (char*)malloc(len);
-@@ -1080,7 +1081,7 @@
- }
-
- if (keyLeft) {
-- int store = min(keyLeft, static_cast<int>(digestSz));
-+ int store = MYSQL_MIN(keyLeft, static_cast<int>(digestSz));
- memcpy(&key[keyLen - keyLeft], digest, store);
-
- keyOutput += store;
-@@ -1089,7 +1090,7 @@
- }
-
- if (ivLeft && digestLeft) {
-- int store = min(ivLeft, digestLeft);
-+ int store = MYSQL_MIN(ivLeft, digestLeft);
- memcpy(&iv[ivLen - ivLeft], &digest[digestSz - digestLeft], store);
-
- keyOutput += store;
-@@ -1414,7 +1415,7 @@
-
- int SSL_peek(SSL* ssl, void* buffer, int sz)
- {
-- Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
-+ Data data(MYSQL_MIN(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
- return receiveData(*ssl, data, true);
- }
-
-diff -urN mysql-old/extra/yassl/src/yassl_imp.cpp mysql/extra/yassl/src/yassl_imp.cpp
---- mysql-old/extra/yassl/src/yassl_imp.cpp 2009-12-10 00:54:18.747800268 -0100
-+++ mysql/extra/yassl/src/yassl_imp.cpp 2009-12-10 00:57:22.942549730 -0100
-@@ -22,6 +22,7 @@
- #include "runtime.hpp"
- #include "yassl_int.hpp"
- #include "handshake.hpp"
-+#include "my_global.h"
-
- #include "asn.hpp" // provide crypto wrapper??
-
-@@ -1435,7 +1436,7 @@
- tmp[1] = input[AUTO];
- ato16(tmp, len);
-
-- hello.suite_len_ = min(len, static_cast<uint16>(MAX_SUITE_SZ));
-+ hello.suite_len_ = MYSQL_MIN(len, static_cast<uint16>(MAX_SUITE_SZ));
- input.read(hello.cipher_suites_, hello.suite_len_);
- if (len > hello.suite_len_) // ignore extra suites
- input.set_current(input.get_current() + len - hello.suite_len_);
-diff -urN mysql-old/extra/yassl/src/yassl_int.cpp mysql/extra/yassl/src/yassl_int.cpp
---- mysql-old/extra/yassl/src/yassl_int.cpp 2009-12-10 00:54:18.747800268 -0100
-+++ mysql/extra/yassl/src/yassl_int.cpp 2009-12-10 00:57:22.944549884 -0100
-@@ -25,6 +25,7 @@
- #include "yassl_int.hpp"
- #include "handshake.hpp"
- #include "timer.hpp"
-+#include "my_global.h"
-
- #ifdef _POSIX_THREADS
- #include "pthread.h"
-@@ -1052,12 +1053,12 @@
- size_t elements = buffers_.getData().size();
-
- data.set_length(0); // output, actual data filled
-- dataSz = min(dataSz, bufferedData());
-+ dataSz = MYSQL_MIN(dataSz, bufferedData());
-
- for (size_t i = 0; i < elements; i++) {
- input_buffer* front = buffers_.getData().front();
- uint frontSz = front->get_remaining();
-- uint readSz = min(dataSz - data.get_length(), frontSz);
-+ uint readSz = MYSQL_MIN(dataSz - data.get_length(), frontSz);
-
- front->read(data.set_buffer() + data.get_length(), readSz);
- data.set_length(data.get_length() + readSz);
-@@ -1082,13 +1083,13 @@
- size_t elements = buffers_.getData().size();
-
- data.set_length(0); // output, actual data filled
-- dataSz = min(dataSz, bufferedData());
-+ dataSz = MYSQL_MIN(dataSz, bufferedData());
-
- Buffers::inputList::iterator front = buffers_.useData().begin();
-
- while (elements) {
- uint frontSz = (*front)->get_remaining();
-- uint readSz = min(dataSz - data.get_length(), frontSz);
-+ uint readSz = MYSQL_MIN(dataSz - data.get_length(), frontSz);
- uint before = (*front)->get_current();
-
- (*front)->read(data.set_buffer() + data.get_length(), readSz);
-@@ -1977,9 +1978,9 @@
- haystack = strstr(haystack, needle);
-
- if (!haystack) // last cipher
-- len = min(sizeof(name), strlen(prev));
-+ len = MYSQL_MIN(sizeof(name), strlen(prev));
- else
-- len = min(sizeof(name), (size_t)(haystack - prev));
-+ len = MYSQL_MIN(sizeof(name), (size_t)(haystack - prev));
-
- strncpy(name, prev, len);
- name[(len == sizeof(name)) ? len - 1 : len] = 0;
-diff -urN mysql-old/extra/yassl/taocrypt/src/algebra.cpp mysql/extra/yassl/taocrypt/src/algebra.cpp
---- mysql-old/extra/yassl/taocrypt/src/algebra.cpp 2009-12-10 00:54:18.749800229 -0100
-+++ mysql/extra/yassl/taocrypt/src/algebra.cpp 2009-12-10 00:57:22.945550049 -0100
-@@ -22,6 +22,7 @@
-
- #include "runtime.hpp"
- #include "algebra.hpp"
-+#include "my_global.h"
- #ifdef USE_SYS_STL
- #include <vector>
- #else
-@@ -109,7 +110,7 @@
- Integer AbstractGroup::CascadeScalarMultiply(const Element &x,
- const Integer &e1, const Element &y, const Integer &e2) const
- {
-- const unsigned expLen = max(e1.BitCount(), e2.BitCount());
-+ const unsigned expLen = MYSQL_MAX(e1.BitCount(), e2.BitCount());
- if (expLen==0)
- return Identity();
-
-diff -urN mysql-old/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-old/extra/yassl/taocrypt/src/dh.cpp 2009-12-10 00:54:18.749800229 -0100
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2009-12-10 00:57:22.945550049 -0100
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -urN mysql-old/extra/yassl/taocrypt/src/hash.cpp mysql/extra/yassl/taocrypt/src/hash.cpp
---- mysql-old/extra/yassl/taocrypt/src/hash.cpp 2009-12-10 00:54:18.749800229 -0100
-+++ mysql/extra/yassl/taocrypt/src/hash.cpp 2009-12-10 00:57:22.946550129 -0100
-@@ -22,6 +22,7 @@
- #include "runtime.hpp"
- #include <string.h>
- #include <assert.h>
-+#include "my_global.h"
-
- #include "hash.hpp"
-
-@@ -53,7 +54,7 @@
- byte* local = reinterpret_cast<byte*>(buffer_);
-
- while (len) {
-- word32 add = min(len, blockSz - buffLen_);
-+ word32 add = MYSQL_MIN(len, blockSz - buffLen_);
- memcpy(&local[buffLen_], data, add);
-
- buffLen_ += add;
-@@ -135,7 +136,7 @@
- byte* local = reinterpret_cast<byte*>(buffer_);
-
- while (len) {
-- word32 add = min(len, blockSz - buffLen_);
-+ word32 add = MYSQL_MIN(len, blockSz - buffLen_);
- memcpy(&local[buffLen_], data, add);
-
- buffLen_ += add;
-diff -urN mysql-old/extra/yassl/taocrypt/src/integer.cpp mysql/extra/yassl/taocrypt/src/integer.cpp
---- mysql-old/extra/yassl/taocrypt/src/integer.cpp 2009-12-10 00:54:18.748800554 -0100
-+++ mysql/extra/yassl/taocrypt/src/integer.cpp 2009-12-10 00:57:22.947549909 -0100
-@@ -24,7 +24,7 @@
- #include "integer.hpp"
- #include "modarith.hpp"
- #include "asn.hpp"
--
-+#include "my_global.h"
-
-
- #ifdef __DECCXX
-@@ -2675,7 +2675,7 @@
- else
- {
- // take two's complement of *this
-- Integer temp = Integer::Power2(8*max(ByteCount(), outputLen)) + *this;
-+ Integer temp = Integer::Power2(8*MYSQL_MAX(ByteCount(), outputLen)) + *this;
- for (unsigned i=0; i<outputLen; i++)
- output[idx++] = temp.GetByte(outputLen-i-1);
- }
-@@ -3009,7 +3009,7 @@
-
- unsigned int Integer::MinEncodedSize(Signedness signedness) const
- {
-- unsigned int outputLen = max(1U, ByteCount());
-+ unsigned int outputLen = MYSQL_MAX(1U, ByteCount());
- if (signedness == UNSIGNED)
- return outputLen;
- if (NotNegative() && (GetByte(outputLen-1) & 0x80))
-@@ -3138,7 +3138,7 @@
-
- Integer Integer::Plus(const Integer& b) const
- {
-- Integer sum((word)0, max(reg_.size(), b.reg_.size()));
-+ Integer sum((word)0, MYSQL_MAX(reg_.size(), b.reg_.size()));
- if (NotNegative())
- {
- if (b.NotNegative())
-@@ -3162,7 +3162,7 @@
-
- Integer Integer::Minus(const Integer& b) const
- {
-- Integer diff((word)0, max(reg_.size(), b.reg_.size()));
-+ Integer diff((word)0, MYSQL_MAX(reg_.size(), b.reg_.size()));
- if (NotNegative())
- {
- if (b.NotNegative())
-diff -urN mysql-old/extra/yassl/taocrypt/src/md5.cpp mysql/extra/yassl/taocrypt/src/md5.cpp
---- mysql-old/extra/yassl/taocrypt/src/md5.cpp 2009-12-10 00:54:18.748800554 -0100
-+++ mysql/extra/yassl/taocrypt/src/md5.cpp 2009-12-10 00:57:22.948549881 -0100
-@@ -92,7 +92,7 @@
-
- // remove buffered data if possible
- if (buffLen_) {
-- word32 add = min(len, BLOCK_SIZE - buffLen_);
-+ word32 add = MYSQL_MIN(len, BLOCK_SIZE - buffLen_);
- memcpy(&local[buffLen_], data, add);
-
- buffLen_ += add;
-diff -urN mysql-old/extra/yassl/taocrypt/src/ripemd.cpp mysql/extra/yassl/taocrypt/src/ripemd.cpp
---- mysql-old/extra/yassl/taocrypt/src/ripemd.cpp 2009-12-10 00:54:18.748800554 -0100
-+++ mysql/extra/yassl/taocrypt/src/ripemd.cpp 2009-12-10 00:57:22.949549895 -0100
-@@ -94,7 +94,7 @@
-
- // remove buffered data if possible
- if (buffLen_) {
-- word32 add = min(len, BLOCK_SIZE - buffLen_);
-+ word32 add = MYSQL_MIN(len, BLOCK_SIZE - buffLen_);
- memcpy(&local[buffLen_], data, add);
-
- buffLen_ += add;
-diff -urN mysql-old/extra/yassl/taocrypt/src/sha.cpp mysql/extra/yassl/taocrypt/src/sha.cpp
---- mysql-old/extra/yassl/taocrypt/src/sha.cpp 2009-12-10 00:54:18.748800554 -0100
-+++ mysql/extra/yassl/taocrypt/src/sha.cpp 2009-12-10 00:57:22.950549861 -0100
-@@ -327,7 +327,7 @@
-
- // remove buffered data if possible
- if (buffLen_) {
-- word32 add = min(len, BLOCK_SIZE - buffLen_);
-+ word32 add = MYSQL_MIN(len, BLOCK_SIZE - buffLen_);
- memcpy(&local[buffLen_], data, add);
-
- buffLen_ += add;
-diff -urN mysql-old/include/my_global.h mysql/include/my_global.h
---- mysql-old/include/my_global.h 2009-12-10 00:54:18.779802347 -0100
-+++ mysql/include/my_global.h 2009-12-10 00:57:22.951607937 -0100
-@@ -578,10 +578,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-@@ -1542,8 +1540,8 @@
-
- /* Define some useful general macros (should be done after all headers). */
- #if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
- #endif
- /*
- Only Linux is known to need an explicit sync of the directory to make sure a
-diff -urN mysql-old/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-old/libmysql/libmysql.c 2009-12-10 00:54:18.744801535 -0100
-+++ mysql/libmysql/libmysql.c 2009-12-10 00:57:22.953925237 -0100
-@@ -1570,7 +1570,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3603,7 +3603,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3836,9 +3836,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG, width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4156,7 +4156,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4168,7 +4168,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -urN mysql-old/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-old/libmysqld/lib_sql.cc 2009-12-10 00:54:18.661800728 -0100
-+++ mysql/libmysqld/lib_sql.cc 2009-12-10 00:57:22.955848803 -0100
-@@ -821,7 +821,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -urN mysql-old/mysys/array.c mysql/mysys/array.c
---- mysql-old/mysys/array.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/array.c 2009-12-10 00:57:22.956690677 -0100
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -urN mysql-old/mysys/default.c mysql/mysys/default.c
---- mysql-old/mysys/default.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/default.c 2009-12-10 00:57:22.956690677 -0100
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -urN mysql-old/mysys/mf_dirname.c mysql/mysys/mf_dirname.c
---- mysql-old/mysys/mf_dirname.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/mf_dirname.c 2009-12-10 00:57:22.957925185 -0100
-@@ -82,7 +82,7 @@
- SYNPOSIS
- convert_dirname()
- to Store result here. Must be at least of size
-- min(FN_REFLEN, strlen(from) + 1) to make room
-+ MYSQL_MIN(FN_REFLEN, strlen(from) + 1) to make room
- for adding FN_LIBCHAR at the end.
- from Original filename. May be == to
- from_end Pointer at end of filename (normally end \0)
-diff -urN mysql-old/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-old/mysys/mf_format.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/mf_format.c 2009-12-10 00:57:22.957925185 -0100
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -urN mysql-old/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-old/mysys/mf_iocache.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/mf_iocache.c 2009-12-10 00:57:22.958901705 -0100
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -urN mysql-old/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-old/mysys/my_alloc.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/my_alloc.c 2009-12-10 00:57:22.959925357 -0100
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -urN mysql-old/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-old/mysys/my_bitmap.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/my_bitmap.c 2009-12-10 00:57:22.960925083 -0100
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -urN mysql-old/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-old/mysys/my_compress.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/my_compress.c 2009-12-10 00:57:22.961925361 -0100
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -urN mysql-old/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-old/mysys/my_conio.c 2009-12-10 00:54:18.750801052 -0100
-+++ mysql/mysys/my_conio.c 2009-12-10 00:57:22.962639993 -0100
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -urN mysql-old/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-old/mysys/my_file.c 2009-12-10 00:54:18.753800571 -0100
-+++ mysql/mysys/my_file.c 2009-12-10 00:57:22.962639993 -0100
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -urN mysql-old/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-old/mysys/my_getopt.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/my_getopt.c 2009-12-10 00:57:22.963651365 -0100
-@@ -973,7 +973,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -urN mysql-old/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql-old/mysys/my_handler.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/my_handler.c 2009-12-10 00:57:22.964925212 -0100
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -urN mysql-old/mysys/my_static.h mysql/mysys/my_static.h
---- mysql-old/mysys/my_static.h 2009-12-10 00:54:18.753800571 -0100
-+++ mysql/mysys/my_static.h 2009-12-10 00:57:22.965774449 -0100
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -urN mysql-old/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-old/mysys/safemalloc.c 2009-12-10 00:54:18.752800365 -0100
-+++ mysql/mysys/safemalloc.c 2009-12-10 00:57:22.965774449 -0100
-@@ -238,7 +238,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -urN mysql-old/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-old/mysys/stacktrace.c 2009-12-10 00:54:18.751800772 -0100
-+++ mysql/mysys/stacktrace.c 2009-12-10 00:57:22.966774370 -0100
-@@ -210,7 +210,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -urN mysql-old/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-old/server-tools/instance-manager/buffer.cc 2009-12-10 00:54:18.529924821 -0100
-+++ mysql/server-tools/instance-manager/buffer.cc 2009-12-10 00:57:22.966774370 -0100
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -urN mysql-old/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-old/server-tools/instance-manager/listener.cc 2009-12-10 00:54:18.529924821 -0100
-+++ mysql/server-tools/instance-manager/listener.cc 2009-12-10 00:57:22.967925092 -0100
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -urN mysql-old/sql/field.cc mysql/sql/field.cc
---- mysql-old/sql/field.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/field.cc 2009-12-10 00:57:22.970925047 -0100
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2071,7 +2071,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2079,7 +2079,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2559,7 +2559,7 @@
- }
- else
- {
-- uint room= min(DECIMAL_MAX_PRECISION - intg, DECIMAL_MAX_SCALE);
-+ uint room= MYSQL_MIN(DECIMAL_MAX_PRECISION - intg, DECIMAL_MAX_SCALE);
- if (scale > room)
- scale= room;
- }
-@@ -3130,7 +3130,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3342,7 +3342,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3559,7 +3559,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3778,7 +3778,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -4019,7 +4019,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4242,7 +4242,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4600,7 +4600,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6494,13 +6494,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6508,7 +6508,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6776,7 +6776,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7771,7 +7771,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7931,7 +7931,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8127,7 +8127,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9120,7 +9120,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9206,7 +9206,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9323,7 +9323,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9778,9 +9778,9 @@
- shrink it to MAX_DATETIME_COMPRESSED_WIDTH.
- */
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
-- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
-+ if (length != UINT_MAX) /* avoid overflow; is safe because of MYSQL_MIN() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -urN mysql-old/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-old/sql/filesort.cc 2009-12-10 00:54:18.671801382 -0100
-+++ mysql/sql/filesort.cc 2009-12-10 00:57:22.974779086 -0100
-@@ -191,7 +191,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -213,12 +213,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1113,7 +1113,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1376,7 +1376,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -urN mysql-old/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-old/sql/ha_ndbcluster.cc 2009-12-10 00:54:18.679801871 -0100
-+++ mysql/sql/ha_ndbcluster.cc 2009-12-10 00:57:22.977924887 -0100
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -urN mysql-old/sql/handler.h mysql/sql/handler.h
---- mysql-old/sql/handler.h 2009-12-10 00:54:18.682800813 -0100
-+++ mysql/sql/handler.h 2009-12-10 00:57:22.981809305 -0100
-@@ -1590,15 +1590,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -urN mysql-old/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-old/sql/item_buff.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_buff.cc 2009-12-10 00:57:22.983708902 -0100
-@@ -58,7 +58,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -urN mysql-old/sql/item.cc mysql/sql/item.cc
---- mysql-old/sql/item.cc 2009-12-10 00:54:18.678802160 -0100
-+++ mysql/sql/item.cc 2009-12-10 00:57:22.985550189 -0100
-@@ -25,6 +25,7 @@
- #include "sp_head.h"
- #include "sql_trigger.h"
- #include "sql_select.h"
-+#include "my_global.h"
-
- const String my_null_string("NULL", 4, default_charset_info);
-
-@@ -74,7 +75,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -748,7 +749,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5356,7 +5357,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5411,7 +5412,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7331,14 +7332,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7369,7 +7370,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7391,7 +7392,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7409,7 +7410,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -urN mysql-old/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-old/sql/item_cmpfunc.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_cmpfunc.cc 2009-12-10 00:57:22.989549921 -0100
-@@ -613,7 +613,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1119,7 +1119,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2142,7 +2142,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2153,10 +2153,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2180,7 +2180,7 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
- return precision;
- }
-@@ -2310,7 +2310,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2354,10 +2354,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2365,7 +2365,7 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
- return precision;
- }
-
-@@ -4662,7 +4662,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4681,7 +4681,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -4802,14 +4802,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -4833,14 +4833,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -urN mysql-old/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-old/sql/item_func.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_func.cc 2009-12-10 00:57:22.991631422 -0100
-@@ -541,7 +541,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1135,10 +1135,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1248,9 +1248,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1298,7 +1298,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1307,7 +1307,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1321,7 +1321,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1443,8 +1443,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1962,7 +1962,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1972,7 +1972,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1989,13 +1989,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2096,7 +2096,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2955,7 +2955,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2964,7 +2964,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -urN mysql-old/sql/item_func.h mysql/sql/item_func.h
---- mysql-old/sql/item_func.h 2009-12-10 00:54:18.683801106 -0100
-+++ mysql/sql/item_func.h 2009-12-10 00:57:22.994795850 -0100
-@@ -363,7 +363,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -urN mysql-old/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-old/sql/item_strfunc.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_strfunc.cc 2009-12-10 00:57:22.996753758 -0100
-@@ -384,7 +384,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -738,7 +738,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1220,7 +1220,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1240,7 +1240,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1934,7 +1934,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3065,11 +3065,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3475,7 +3475,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -urN mysql-old/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-old/sql/item_sum.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_sum.cc 2009-12-10 00:57:22.998800288 -0100
-@@ -1169,7 +1169,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1232,16 +1232,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1433,13 +1433,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3519,7 +3519,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -urN mysql-old/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-old/sql/item_timefunc.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/item_timefunc.cc 2009-12-10 00:57:23.000552809 -0100
-@@ -313,14 +313,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -329,7 +329,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -346,15 +346,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -365,14 +365,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -380,7 +380,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -432,7 +432,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -444,7 +444,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -456,7 +456,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -601,7 +601,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1838,7 +1838,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -urN mysql-old/sql/key.cc mysql/sql/key.cc
---- mysql-old/sql/key.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/key.cc 2009-12-10 00:57:23.001924865 -0100
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -urN mysql-old/sql/log.cc mysql/sql/log.cc
---- mysql-old/sql/log.cc 2009-12-10 00:54:18.673801019 -0100
-+++ mysql/sql/log.cc 2009-12-10 00:57:23.112778227 -0100
-@@ -594,11 +594,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2402,7 +2402,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -4859,7 +4859,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -urN mysql-old/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-old/sql/log_event.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/log_event.cc 2009-12-10 00:57:23.117925330 -0100
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2576,7 +2576,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5411,7 +5411,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7135,7 +7135,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-old/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql-old/sql/log_event_old.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/log_event_old.cc 2009-12-10 00:57:23.164686969 -0100
-@@ -1405,7 +1405,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-old/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-old/sql/mysqld.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/mysqld.cc 2009-12-10 00:57:23.167925364 -0100
-@@ -3298,7 +3298,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3310,15 +3310,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4967,7 +4967,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -urN mysql-old/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-old/sql/net_serv.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/net_serv.cc 2009-12-10 00:57:23.172885103 -0100
-@@ -756,7 +756,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -urN mysql-old/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-old/sql/opt_range.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/opt_range.cc 2009-12-10 00:57:23.175925139 -0100
-@@ -2352,7 +2352,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3828,7 +3828,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7341,7 +7341,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7410,7 +7410,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8325,13 +8325,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8350,7 +8350,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8433,7 +8433,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8546,13 +8546,13 @@
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -9161,7 +9161,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9387,7 +9387,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10019,9 +10019,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -urN mysql-old/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-old/sql/protocol.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/protocol.cc 2009-12-10 00:57:23.180803105 -0100
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -urN mysql-old/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-old/sql/rpl_record.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/rpl_record.cc 2009-12-10 00:57:23.181925046 -0100
-@@ -255,7 +255,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -urN mysql-old/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-old/sql/rpl_rli.cc 2009-12-10 00:54:18.669801304 -0100
-+++ mysql/sql/rpl_rli.cc 2009-12-10 00:57:23.182763515 -0100
-@@ -662,7 +662,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -672,7 +672,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -urN mysql-old/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-old/sql/rpl_utility.cc 2009-12-10 00:54:18.669801304 -0100
-+++ mysql/sql/rpl_utility.cc 2009-12-10 00:57:23.182763515 -0100
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -urN mysql-old/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql-old/sql/rpl_utility.h 2009-12-10 00:54:18.682800813 -0100
-+++ mysql/sql/rpl_utility.h 2009-12-10 00:57:23.183698833 -0100
-@@ -299,7 +299,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -urN mysql-old/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-old/sql/set_var.cc 2009-12-10 00:54:18.675801832 -0100
-+++ mysql/sql/set_var.cc 2009-12-10 00:57:23.184598496 -0100
-@@ -1850,7 +1850,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -3994,7 +3994,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -urN mysql-old/sql/slave.cc mysql/sql/slave.cc
---- mysql-old/sql/slave.cc 2009-12-10 00:54:18.670801185 -0100
-+++ mysql/sql/slave.cc 2009-12-10 00:57:23.187563669 -0100
-@@ -1703,13 +1703,13 @@
- slave is 2. At SHOW SLAVE STATUS time, assume that the difference
- between timestamp of slave and rli->last_master_timestamp is 0
- (i.e. they are in the same second), then we get 0-(2-1)=-1 as a result.
-- This confuses users, so we don't go below 0: hence the max().
-+ This confuses users, so we don't go below 0: hence the MYSQL_MAX().
-
- last_master_timestamp == 0 (an "impossible" timestamp 1970) is a
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2333,7 +2333,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -3984,7 +3984,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -urN mysql-old/sql/spatial.h mysql/sql/spatial.h
---- mysql-old/sql/spatial.h 2009-12-10 00:54:18.681800947 -0100
-+++ mysql/sql/spatial.h 2009-12-10 00:57:23.189924896 -0100
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -urN mysql-old/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-old/sql/sp_head.cc 2009-12-10 00:54:18.669801304 -0100
-+++ mysql/sql/sp_head.cc 2009-12-10 00:57:23.190925470 -0100
-@@ -2414,7 +2414,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2615,7 +2615,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -urN mysql-old/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-old/sql/sql_acl.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/sql_acl.cc 2009-12-10 00:57:23.193600784 -0100
-@@ -818,7 +818,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -urN mysql-old/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-old/sql/sql_analyse.cc 2009-12-10 00:54:18.670801185 -0100
-+++ mysql/sql/sql_analyse.cc 2009-12-10 00:57:23.196766218 -0100
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -urN mysql-old/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-old/sql/sql_cache.cc 2009-12-10 00:54:18.670801185 -0100
-+++ mysql/sql/sql_cache.cc 2009-12-10 00:57:23.198925221 -0100
-@@ -981,7 +981,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2341,7 +2341,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2396,7 +2396,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2424,7 +2424,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2512,8 +2512,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2545,7 +2545,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2554,7 +2554,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -2977,7 +2977,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -urN mysql-old/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-old/sql/sql_class.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/sql_class.cc 2009-12-10 00:57:23.200925302 -0100
-@@ -380,7 +380,7 @@
- if (max_query_len < 1)
- len= thd->query_length;
- else
-- len= min(thd->query_length, max_query_len);
-+ len= MYSQL_MIN(thd->query_length, max_query_len);
- str.append('\n');
- str.append(thd->query, len);
- }
-@@ -392,7 +392,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -1975,7 +1975,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -urN mysql-old/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-old/sql/sql_client.cc 2009-12-10 00:54:18.669801304 -0100
-+++ mysql/sql/sql_client.cc 2009-12-10 00:57:23.202924894 -0100
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -urN mysql-old/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-old/sql/sql_connect.cc 2009-12-10 00:54:18.675801832 -0100
-+++ mysql/sql/sql_connect.cc 2009-12-10 00:57:23.203830981 -0100
-@@ -670,7 +670,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -urN mysql-old/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql-old/sql/sql_load.cc 2009-12-10 00:54:18.670801185 -0100
-+++ mysql/sql/sql_load.cc 2009-12-10 00:57:23.203830981 -0100
-@@ -977,7 +977,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -urN mysql-old/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-old/sql/sql_parse.cc 2009-12-10 00:54:18.675801832 -0100
-+++ mysql/sql/sql_parse.cc 2009-12-10 00:57:23.206924939 -0100
-@@ -5563,7 +5563,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7054,7 +7054,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -urN mysql-old/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-old/sql/sql_partition.cc 2009-12-10 00:54:18.678802160 -0100
-+++ mysql/sql/sql_partition.cc 2009-12-10 00:57:23.210553448 -0100
-@@ -4516,7 +4516,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -urN mysql-old/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-old/sql/sql_plugin.cc 2009-12-10 00:54:18.668801053 -0100
-+++ mysql/sql/sql_plugin.cc 2009-12-10 00:57:23.215549997 -0100
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2092,7 +2092,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff), error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff), error_len));
- strvalue= buff;
- goto err;
- }
-diff -urN mysql-old/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-old/sql/sql_prepare.cc 2009-12-10 00:54:18.673801019 -0100
-+++ mysql/sql/sql_prepare.cc 2009-12-10 00:57:23.217549832 -0100
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -urN mysql-old/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql-old/sql/sql_profile.cc 2009-12-10 00:54:18.673801019 -0100
-+++ mysql/sql/sql_profile.cc 2009-12-10 00:57:23.218549839 -0100
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -urN mysql-old/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-old/sql/sql_repl.cc 2009-12-10 00:54:18.669801304 -0100
-+++ mysql/sql/sql_repl.cc 2009-12-10 00:57:23.219827771 -0100
-@@ -1256,12 +1256,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
-- max().
-+ MYSQL_MAX().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1423,7 +1423,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1692,14 +1692,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- mysql_bin_log.write(&a);
- }
-@@ -1707,7 +1707,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- mysql_bin_log.write(&b);
- lf_info->wrote_create_file= 1;
-diff -urN mysql-old/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-old/sql/sql_select.cc 2009-12-10 00:54:18.674801821 -0100
-+++ mysql/sql/sql_select.cc 2009-12-10 00:57:23.224925224 -0100
-@@ -881,7 +881,7 @@
- }
- #endif
-
-- /* Optimize count(*), min() and max() */
-+ /* Optimize count(*), MYSQL_MIN() and MYSQL_MAX() */
- if (tables_list && tmp_table_param.sum_func_count && ! group_list)
- {
- int res;
-@@ -2829,7 +2829,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3743,7 +3743,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3766,7 +3766,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3925,7 +3925,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4245,7 +4245,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4412,7 +4412,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5357,7 +5357,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -6718,7 +6718,7 @@
- a correlated subquery itself, but has subqueries, we can free it
- fully and also free JOINs of all its subqueries. The exception
- is a subquery in SELECT list, e.g: @n
-- SELECT a, (select max(b) from t1) group by c @n
-+ SELECT a, (select MYSQL_MAX(b) from t1) group by c @n
- This subquery will not be evaluated at first sweep and its value will
- not be inserted into the temporary table. Instead, it's evaluated
- when selecting from the temporary table. Therefore, it can't be freed
-@@ -10162,7 +10162,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13217,7 +13217,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13229,7 +13229,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -13868,7 +13868,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -13990,7 +13990,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -urN mysql-old/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-old/sql/sql_show.cc 2009-12-10 00:54:18.670801185 -0100
-+++ mysql/sql/sql_show.cc 2009-12-10 00:57:23.305553824 -0100
-@@ -640,7 +640,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -651,7 +651,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1759,7 +1759,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query)
- {
-- uint length= min(max_query_length, tmp->query_length);
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length);
- thd_info->query=(char*) thd->strmake(tmp->query,length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1888,7 +1888,7 @@
- if (tmp->query)
- {
- table->field[7]->store(tmp->query,
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length), cs);
- table->field[7]->set_notnull();
- }
-@@ -3030,7 +3030,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -6869,7 +6869,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -urN mysql-old/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-old/sql/sql_string.cc 2009-12-10 00:54:18.676678556 -0100
-+++ mysql/sql/sql_string.cc 2009-12-10 00:57:23.310733848 -0100
-@@ -661,7 +661,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1151,7 +1151,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -urN mysql-old/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-old/sql/sql_table.cc 2009-12-10 00:54:18.671801382 -0100
-+++ mysql/sql/sql_table.cc 2009-12-10 00:57:23.312925406 -0100
-@@ -3213,7 +3213,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -urN mysql-old/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-old/sql/sql_yacc.cc 2009-12-10 00:54:18.680801992 -0100
-+++ mysql/sql/sql_yacc.cc 2009-12-10 00:57:23.325926568 -0100
-@@ -16004,7 +16004,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16024,7 +16024,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -urN mysql-old/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-old/sql/thr_malloc.cc 2009-12-10 00:54:18.677801964 -0100
-+++ mysql/sql/thr_malloc.cc 2009-12-10 00:57:23.407549717 -0100
-@@ -126,7 +126,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -urN mysql-old/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-old/sql/tztime.cc 2009-12-10 00:54:18.678802160 -0100
-+++ mysql/sql/tztime.cc 2009-12-10 00:57:23.408549811 -0100
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -urN mysql-old/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-old/sql/unireg.cc 2009-12-10 00:54:18.672801332 -0100
-+++ mysql/sql/unireg.cc 2009-12-10 00:57:23.410549895 -0100
-@@ -490,7 +490,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -urN mysql-old/sql-common/client.c mysql/sql-common/client.c
---- mysql-old/sql-common/client.c 2009-12-10 00:54:18.762801391 -0100
-+++ mysql/sql-common/client.c 2009-12-10 00:57:23.411550572 -0100
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -urN mysql-old/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-old/sql-common/my_time.c 2009-12-10 00:54:18.762801391 -0100
-+++ mysql/sql-common/my_time.c 2009-12-10 00:57:23.413549779 -0100
-@@ -250,7 +250,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -urN mysql-old/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-old/storage/csv/ha_tina.cc 2009-12-10 00:54:18.742800710 -0100
-+++ mysql/storage/csv/ha_tina.cc 2009-12-10 00:57:23.414549859 -0100
-@@ -1185,7 +1185,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1421,7 +1421,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -urN mysql-old/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql-old/storage/example/ha_example.h 2009-12-10 00:54:18.741801693 -0100
-+++ mysql/storage/example/ha_example.h 2009-12-10 00:57:23.415549893 -0100
-@@ -110,14 +110,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -128,7 +128,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -139,7 +139,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -urN mysql-old/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-old/storage/federated/ha_federated.cc 2009-12-10 00:54:18.741801693 -0100
-+++ mysql/storage/federated/ha_federated.cc 2009-12-10 00:57:23.416697303 -0100
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -urN mysql-old/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-old/storage/heap/hp_create.c 2009-12-10 00:54:18.741801693 -0100
-+++ mysql/storage/heap/hp_create.c 2009-12-10 00:57:23.417678529 -0100
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -urN mysql-old/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-old/storage/heap/hp_test2.c 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/heap/hp_test2.c 2009-12-10 00:57:23.418705379 -0100
-@@ -27,6 +27,7 @@
-
- #include "heapdef.h" /* Because of hp_find_block */
- #include <signal.h>
-+#include "my_global.h"
-
- #define MAX_RECORDS 100000
- #define MAX_KEYS 4
-@@ -136,7 +137,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +218,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -urN mysql-old/storage/ibmdb2i/db2i_blobCollection.cc mysql/storage/ibmdb2i/db2i_blobCollection.cc
---- mysql-old/storage/ibmdb2i/db2i_blobCollection.cc 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/db2i_blobCollection.cc 2009-12-10 00:57:23.419619980 -0100
-@@ -61,9 +61,9 @@
-
- uint curMaxSize = table->getBlobFieldActualSize(fieldIndex);
-
-- uint defaultAllocSize = min(defaultAllocation, fieldLength);
-+ uint defaultAllocSize = MYSQL_MIN(defaultAllocation, fieldLength);
-
-- return max(defaultAllocSize, curMaxSize);
-+ return MYSQL_MAX(defaultAllocSize, curMaxSize);
-
- }
-
-diff -urN mysql-old/storage/ibmdb2i/db2i_conversion.cc mysql/storage/ibmdb2i/db2i_conversion.cc
---- mysql-old/storage/ibmdb2i/db2i_conversion.cc 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/db2i_conversion.cc 2009-12-10 00:57:23.419619980 -0100
-@@ -528,13 +528,13 @@
- {
- if (field->type() == MYSQL_TYPE_STRING)
- {
-- sprintf(stringBuildBuffer, "BINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "BINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else
- {
- if (fieldLength <= MAX_VARCHAR_LENGTH)
- {
-- sprintf(stringBuildBuffer, "VARBINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARBINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else if (blobMapping == AS_VARCHAR &&
- (field->flags & PART_KEY_FLAG))
-@@ -543,8 +543,8 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-- sprintf(stringBuildBuffer, "BLOB(%d)", max(fieldLength, 1));
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-+ sprintf(stringBuildBuffer, "BLOB(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- mapping.append(stringBuildBuffer);
-@@ -559,24 +559,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- mapping.append(stringBuildBuffer);
- }
-@@ -588,24 +588,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- else if (blobMapping == AS_VARCHAR &&
-@@ -637,30 +637,30 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-
- if (fieldCharSet->mbmaxlen > 1)
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of characters
- }
- }
-
-@@ -721,7 +721,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint truncationAmount = precision - db2Precision;
-
- if (scale >= truncationAmount)
-@@ -1101,7 +1101,7 @@
- if (maxDisplayLength == 0 && db2FieldType == QMY_GRAPHIC)
- maxDb2BytesToStore = 2;
- else
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
-
- if (bytesToStore == 0)
-@@ -1146,7 +1146,7 @@
- else // Else Far East, special UTF8 or non-special UTF8/UCS2
- {
- size_t maxDb2BytesToStore;
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
- temp = getCharacterConversionBuffer(field->field_index, maxDb2BytesToStore);
- rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore,temp,bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
-@@ -1199,7 +1199,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint decimalPlace = precision-scale+1;
- char temp[80];
-
-diff -urN mysql-old/storage/ibmdb2i/db2i_file.cc mysql/storage/ibmdb2i/db2i_file.cc
---- mysql-old/storage/ibmdb2i/db2i_file.cc 2009-12-10 00:54:18.739801321 -0100
-+++ mysql/storage/ibmdb2i/db2i_file.cc 2009-12-10 00:57:23.420925523 -0100
-@@ -335,14 +335,14 @@
- {
- strncpy(out, in, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
- ++cur;
- }
-
- strncpy(out, test, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
-
- void db2i_table::filenameToTablename(const char* in, char* out, size_t outlen)
-@@ -366,8 +366,8 @@
- part4 = strend(in);
- }
-
-- memcpy(temp, part1, min(outlen, part2 - part1));
-- temp[min(outlen-1, part2-part1)] = 0;
-+ memcpy(temp, part1, MYSQL_MIN(outlen, part2 - part1));
-+ temp[MYSQL_MIN(outlen-1, part2-part1)] = 0;
-
- int32 accumLen = smartFilenameToTableName(temp, out, outlen);
-
-@@ -376,9 +376,9 @@
- strcat(out, "#P#");
- accumLen += 4;
-
-- memset(temp, 0, min(outlen, part2-part1));
-- memcpy(temp, part3, min(outlen, part4-part3));
-- temp[min(outlen-1, part4-part3)] = 0;
-+ memset(temp, 0, MYSQL_MIN(outlen, part2-part1));
-+ memcpy(temp, part3, MYSQL_MIN(outlen, part4-part3));
-+ temp[MYSQL_MIN(outlen-1, part4-part3)] = 0;
-
- accumLen += smartFilenameToTableName(temp, strend(out), outlen-accumLen);
-
-@@ -484,7 +484,7 @@
-
- strncat(generatedName,
- tableName+1,
-- min(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-+ MYSQL_MIN(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-
- char finalName[MAX_DB2_FILENAME_LENGTH+1];
- convertMySQLNameToDB2Name(generatedName, finalName, sizeof(finalName), true, (format==ASCII_SQL));
-diff -urN mysql-old/storage/ibmdb2i/db2i_ileBridge.cc mysql/storage/ibmdb2i/db2i_ileBridge.cc
---- mysql-old/storage/ibmdb2i/db2i_ileBridge.cc 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/db2i_ileBridge.cc 2009-12-10 00:57:23.421833794 -0100
-@@ -594,7 +594,7 @@
- {
- Qmy_MSPO0100_output* output = (Qmy_MSPO0100_output*)parmBlock->outParms;
- *rfileHandle = output->ObjHnd;
-- *recLength = max(output->InNxtRowOff, output->OutNxtRowOff);
-+ *recLength = MYSQL_MAX(output->InNxtRowOff, output->OutNxtRowOff);
- }
-
-
-diff -urN mysql-old/storage/ibmdb2i/db2i_misc.h mysql/storage/ibmdb2i/db2i_misc.h
---- mysql-old/storage/ibmdb2i/db2i_misc.h 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/db2i_misc.h 2009-12-10 00:57:23.422555289 -0100
-@@ -87,7 +87,7 @@
-
- if (delimit)
- output[o++] = '"';
-- output[min(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
-+ output[MYSQL_MIN(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
- // but at least its safe.
- return (o <= outlen-1);
- }
-diff -urN mysql-old/storage/ibmdb2i/db2i_safeString.h mysql/storage/ibmdb2i/db2i_safeString.h
---- mysql-old/storage/ibmdb2i/db2i_safeString.h 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/db2i_safeString.h 2009-12-10 00:57:23.422555289 -0100
-@@ -79,7 +79,7 @@
-
- SafeString& strncat(const char* str, size_t len)
- {
-- uint64 amountToCopy = min((allocSize-1) - curPos, len);
-+ uint64 amountToCopy = MYSQL_MIN((allocSize-1) - curPos, len);
- memcpy(buf + curPos, str, amountToCopy);
- curPos += amountToCopy;
- buf[curPos] = 0;
-diff -urN mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc mysql/storage/ibmdb2i/ha_ibmdb2i.cc
---- mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.cc 2009-12-10 00:57:23.423612063 -0100
-@@ -2644,9 +2644,9 @@
- rowsToRead = 1;
- }
-
-- rowsToRead = min(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+ rowsToRead = MYSQL_MIN(stats.records+1,MYSQL_MIN(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-
-- uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
- multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
- activeReadBuf = &multiRowReadBuf;
-
-@@ -2682,9 +2682,9 @@
-
- if (unlikely(rc)) DBUG_RETURN(rc);
-
-- rowsToWrite = min(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-+ rowsToWrite = MYSQL_MIN(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-
-- uint bufSize = min((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
- multiRowWriteBuf.allocBuf(format->writeRowLen, format->writeRowNullOffset, bufSize);
- activeWriteBuf = &multiRowWriteBuf;
-
-@@ -2768,8 +2768,8 @@
- else
- {
- char unknownIndex[MAX_DB2_FILENAME_LENGTH+1];
-- convFromEbcdic(lastDupKeyNamePtr, unknownIndex, min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-- unknownIndex[min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
-+ convFromEbcdic(lastDupKeyNamePtr, unknownIndex, MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-+ unknownIndex[MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
- getErrTxt(DB2I_ERR_UNKNOWN_IDX, unknownIndex);
- }
- }
-@@ -3141,7 +3141,7 @@
- if (forceSingleRowRead)
- rowsToBuffer = 1;
- else
-- rowsToBuffer = min(rowsToBuffer, activeReadBuf->getRowCapacity());
-+ rowsToBuffer = MYSQL_MIN(rowsToBuffer, activeReadBuf->getRowCapacity());
-
- activeReadBuf->newReadRequest(activeHandle,
- orientation,
-@@ -3279,7 +3279,7 @@
- double dataPageCount = stats.data_file_length/IO_SIZE;
-
- cost = (rows * dataPageCount / totalRecords) +
-- min(idxPageCnt, (log_2(idxPageCnt) * ranges +
-+ MYSQL_MIN(idxPageCnt, (log_2(idxPageCnt) * ranges +
- rows * (log_2(idxPageCnt) + log_2(rows) - log_2(totalRecords))));
- }
- }
-diff -urN mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc.orig mysql/storage/ibmdb2i/ha_ibmdb2i.cc.orig
---- mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc.orig 1969-12-31 23:00:00.000000000 -0100
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.cc.orig 2009-12-10 00:57:23.427924858 -0100
-@@ -0,0 +1,3359 @@
-+/*
-+Licensed Materials - Property of IBM
-+DB2 Storage Engine Enablement
-+Copyright IBM Corporation 2007,2008
-+All rights reserved
-+
-+Redistribution and use in source and binary forms, with or without modification,
-+are permitted provided that the following conditions are met:
-+ (a) Redistributions of source code must retain this list of conditions, the
-+ copyright notice in section {d} below, and the disclaimer following this
-+ list of conditions.
-+ (b) Redistributions in binary form must reproduce this list of conditions, the
-+ copyright notice in section (d) below, and the disclaimer following this
-+ list of conditions, in the documentation and/or other materials provided
-+ with the distribution.
-+ (c) The name of IBM may not be used to endorse or promote products derived from
-+ this software without specific prior written permission.
-+ (d) The text of the required copyright notice is:
-+ Licensed Materials - Property of IBM
-+ DB2 Storage Engine Enablement
-+ Copyright IBM Corporation 2007,2008
-+ All rights reserved
-+
-+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
-+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-+OF SUCH DAMAGE.
-+*/
-+
-+
-+/**
-+ @file ha_ibmdb2i.cc
-+
-+ @brief
-+ The ha_ibmdb2i storage engine provides an interface from MySQL to IBM DB2 for i.
-+
-+*/
-+
-+#ifdef USE_PRAGMA_IMPLEMENTATION
-+#pragma implementation // gcc: Class implementation
-+#endif
-+
-+#include "ha_ibmdb2i.h"
-+#include "mysql_priv.h"
-+#include <mysql/plugin.h>
-+#include "db2i_ileBridge.h"
-+#include "db2i_charsetSupport.h"
-+#include <sys/utsname.h>
-+#include "db2i_safeString.h"
-+
-+static const char __NOT_NULL_VALUE_EBCDIC = 0xF0; // '0'
-+static const char __NULL_VALUE_EBCDIC = 0xF1; // '1'
-+static const char __DEFAULT_VALUE_EBCDIC = 0xC4; // 'D'
-+static const char BlankASPName[19] = " ";
-+static const int DEFAULT_MAX_ROWS_TO_BUFFER = 4096;
-+
-+static const char SAVEPOINT_PREFIX[] = {0xD4, 0xE8, 0xE2, 0xD7}; // MYSP (in EBCDIC)
-+
-+OSVersion osVersion;
-+
-+
-+// ================================================================
-+// ================================================================
-+// System variables
-+static char* ibmdb2i_rdb_name;
-+static MYSQL_SYSVAR_STR(rdb_name, ibmdb2i_rdb_name,
-+ PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY,
-+ "The name of the RDB to use",
-+ NULL,
-+ NULL,
-+ BlankASPName);
-+
-+static MYSQL_THDVAR_BOOL(transaction_unsafe,
-+ 0,
-+ "Disable support for commitment control",
-+ NULL,
-+ NULL,
-+ FALSE);
-+
-+static MYSQL_THDVAR_UINT(lob_alloc_size,
-+ 0,
-+ "Baseline allocation for lob read buffer",
-+ NULL,
-+ NULL,
-+ 2*1024*1024,
-+ 64*1024,
-+ 128*1024*1024,
-+ 1);
-+
-+static MYSQL_THDVAR_UINT(max_read_buffer_size,
-+ 0,
-+ "Maximum size of buffers used for read-ahead.",
-+ NULL,
-+ NULL,
-+ 1*1024*1024,
-+ 32*1024,
-+ 16*1024*1024,
-+ 1);
-+
-+static MYSQL_THDVAR_UINT(max_write_buffer_size,
-+ 0,
-+ "Maximum size of buffers used for bulk writes.",
-+ NULL,
-+ NULL,
-+ 8*1024*1024,
-+ 32*1024,
-+ 64*1024*1024,
-+ 1);
-+
-+static MYSQL_THDVAR_BOOL(compat_opt_time_as_duration,
-+ 0,
-+ "Control how new TIME columns should be defined in DB2. 0=time-of-day (default), 1=duration.",
-+ NULL,
-+ NULL,
-+ FALSE);
-+
-+static MYSQL_THDVAR_UINT(compat_opt_year_as_int,
-+ 0,
-+ "Control how new YEAR columns should be defined in DB2. 0=CHAR(4) (default), 1=SMALLINT.",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 1,
-+ 1);
-+
-+static MYSQL_THDVAR_UINT(compat_opt_blob_cols,
-+ 0,
-+ "Control how new TEXT and BLOB columns should be defined in DB2. 0=CLOB/BLOB (default), 1=VARCHAR/VARBINARY",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 1,
-+ 1);
-+
-+static MYSQL_THDVAR_UINT(compat_opt_allow_zero_date_vals,
-+ 0,
-+ "Allow substitute values to be used when storing a column with a 0000-00-00 date component. 0=No substitution (default), 1=Substitute '0001-01-01'",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 1,
-+ 1);
-+
-+static MYSQL_THDVAR_BOOL(propagate_default_col_vals,
-+ 0,
-+ "Should DEFAULT column values be propagated to the DB2 table definition.",
-+ NULL,
-+ NULL,
-+ TRUE);
-+
-+static my_bool ibmdb2i_assume_exclusive_use;
-+static MYSQL_SYSVAR_BOOL(assume_exclusive_use, ibmdb2i_assume_exclusive_use,
-+ 0,
-+ "Can MySQL assume that this process is the only one modifying the DB2 tables. ",
-+ NULL,
-+ NULL,
-+ FALSE);
-+
-+static MYSQL_THDVAR_BOOL(async_enabled,
-+ 0,
-+ "Should reads be done asynchronously when possible",
-+ NULL,
-+ NULL,
-+ TRUE);
-+
-+static MYSQL_THDVAR_UINT(create_index_option,
-+ 0,
-+ "Control whether additional indexes are created. 0=No (default), 1=Create additional *HEX-based index",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 1,
-+ 1);
-+
-+/* static MYSQL_THDVAR_UINT(discovery_mode,
-+ 0,
-+ "Unsupported",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 1,
-+ 1); */
-+
-+static uint32 ibmdb2i_system_trace;
-+static MYSQL_SYSVAR_UINT(system_trace_level, ibmdb2i_system_trace,
-+ 0,
-+ "Set system tracing level",
-+ NULL,
-+ NULL,
-+ 0,
-+ 0,
-+ 63,
-+ 1);
-+
-+
-+inline uint8 ha_ibmdb2i::getCommitLevel(THD* thd)
-+{
-+ if (!THDVAR(thd, transaction_unsafe))
-+ {
-+ switch (thd_tx_isolation(thd))
-+ {
-+ case ISO_READ_UNCOMMITTED:
-+ return (accessIntent == QMY_READ_ONLY ? QMY_READ_UNCOMMITTED : QMY_REPEATABLE_READ);
-+ case ISO_READ_COMMITTED:
-+ return (accessIntent == QMY_READ_ONLY ? QMY_READ_COMMITTED : QMY_REPEATABLE_READ);
-+ case ISO_REPEATABLE_READ:
-+ return QMY_REPEATABLE_READ;
-+ case ISO_SERIALIZABLE:
-+ return QMY_SERIALIZABLE;
-+ }
-+ }
-+
-+ return QMY_NONE;
-+}
-+
-+inline uint8 ha_ibmdb2i::getCommitLevel()
-+{
-+ return getCommitLevel(ha_thd());
-+}
-+
-+//=====================================================================
-+
-+static handler *ibmdb2i_create_handler(handlerton *hton,
-+ TABLE_SHARE *table,
-+ MEM_ROOT *mem_root);
-+static void ibmdb2i_drop_database(handlerton *hton, char* path);
-+static int ibmdb2i_savepoint_set(handlerton *hton, THD* thd, void *sv);
-+static int ibmdb2i_savepoint_rollback(handlerton *hton, THD* thd, void *sv);
-+static int ibmdb2i_savepoint_release(handlerton *hton, THD* thd, void *sv);
-+static uint ibmdb2i_alter_table_flags(uint flags);
-+
-+handlerton *ibmdb2i_hton;
-+static bool was_ILE_inited;
-+
-+/* Tracks the number of open tables */
-+static HASH ibmdb2i_open_tables;
-+
-+/* Mutex used to synchronize initialization of the hash */
-+static pthread_mutex_t ibmdb2i_mutex;
-+
-+
-+/**
-+ Create hash key for tracking open tables.
-+*/
-+
-+static uchar* ibmdb2i_get_key(IBMDB2I_SHARE *share,size_t *length,
-+ bool not_used __attribute__((unused)))
-+{
-+ *length=share->table_name_length;
-+ return (uchar*) share->table_name;
-+}
-+
-+
-+int ibmdb2i_close_connection(handlerton* hton, THD *thd)
-+{
-+ DBUG_PRINT("ha_ibmdb2i::close_connection", ("Closing %d", thd->thread_id));
-+ db2i_ileBridge::getBridgeForThread(thd)->closeConnection(thd->thread_id);
-+ db2i_ileBridge::destroyBridgeForThread(thd);
-+
-+ return 0;
-+}
-+
-+
-+static int ibmdb2i_init_func(void *p)
-+{
-+ DBUG_ENTER("ibmdb2i_init_func");
-+
-+ utsname tempName;
-+ uname(&tempName);
-+ osVersion.v = atoi(tempName.version);
-+ osVersion.r = atoi(tempName.release);
-+
-+ was_ILE_inited = false;
-+ ibmdb2i_hton= (handlerton *)p;
-+ VOID(pthread_mutex_init(&ibmdb2i_mutex,MY_MUTEX_INIT_FAST));
-+ (void) hash_init(&ibmdb2i_open_tables,system_charset_info,32,0,0,
-+ (hash_get_key) ibmdb2i_get_key,0,0);
-+
-+ ibmdb2i_hton->state= SHOW_OPTION_YES;
-+ ibmdb2i_hton->create= ibmdb2i_create_handler;
-+ ibmdb2i_hton->drop_database= ibmdb2i_drop_database;
-+ ibmdb2i_hton->commit= ha_ibmdb2i::doCommit;
-+ ibmdb2i_hton->rollback= ha_ibmdb2i::doRollback;
-+ ibmdb2i_hton->savepoint_offset= 0;
-+ ibmdb2i_hton->savepoint_set= ibmdb2i_savepoint_set;
-+ ibmdb2i_hton->savepoint_rollback= ibmdb2i_savepoint_rollback;
-+ ibmdb2i_hton->savepoint_release= ibmdb2i_savepoint_release;
-+ ibmdb2i_hton->alter_table_flags=ibmdb2i_alter_table_flags;
-+ ibmdb2i_hton->close_connection=ibmdb2i_close_connection;
-+
-+ int rc;
-+
-+ rc = initCharsetSupport();
-+
-+ if (!rc)
-+ rc = db2i_ileBridge::setup();
-+
-+ if (!rc)
-+ {
-+ int nameLen = strlen(ibmdb2i_rdb_name);
-+ for (int i = 0; i < nameLen; ++i)
-+ {
-+ ibmdb2i_rdb_name[i] = my_toupper(system_charset_info, (uchar)ibmdb2i_rdb_name[i]);
-+ }
-+
-+ rc = db2i_ileBridge::initILE(ibmdb2i_rdb_name, (uint16*)(((char*)&ibmdb2i_system_trace)+2));
-+ if (rc == 0)
-+ {
-+ was_ILE_inited = true;
-+ }
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+static int ibmdb2i_done_func(void *p)
-+{
-+ int error= 0;
-+ DBUG_ENTER("ibmdb2i_done_func");
-+
-+ if (ibmdb2i_open_tables.records)
-+ error= 1;
-+
-+ if (was_ILE_inited)
-+ db2i_ileBridge::exitILE();
-+
-+ db2i_ileBridge::takedown();
-+
-+ doneCharsetSupport();
-+
-+ hash_free(&ibmdb2i_open_tables);
-+ pthread_mutex_destroy(&ibmdb2i_mutex);
-+
-+ DBUG_RETURN(0);
-+}
-+
-+
-+IBMDB2I_SHARE *ha_ibmdb2i::get_share(const char *table_name, TABLE *table)
-+{
-+ IBMDB2I_SHARE *share;
-+ uint length;
-+ char *tmp_name;
-+
-+ pthread_mutex_lock(&ibmdb2i_mutex);
-+ length=(uint) strlen(table_name);
-+
-+ if (!(share=(IBMDB2I_SHARE*) hash_search(&ibmdb2i_open_tables,
-+ (uchar*)table_name,
-+ length)))
-+ {
-+ if (!(share=(IBMDB2I_SHARE *)
-+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
-+ &share, sizeof(*share),
-+ &tmp_name, length+1,
-+ NullS)))
-+ {
-+ pthread_mutex_unlock(&ibmdb2i_mutex);
-+ return NULL;
-+ }
-+
-+ share->use_count=0;
-+ share->table_name_length=length;
-+ share->table_name=tmp_name;
-+ strmov(share->table_name,table_name);
-+ if (my_hash_insert(&ibmdb2i_open_tables, (uchar*) share))
-+ goto error;
-+ thr_lock_init(&share->lock);
-+ pthread_mutexattr_t mutexattr = MY_MUTEX_INIT_FAST;
-+ pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
-+ pthread_mutex_init(&share->mutex, &mutexattr);
-+
-+ share->db2Table = new db2i_table(table->s, table_name);
-+ int32 rc = share->db2Table->initDB2Objects(table_name);
-+
-+ if (rc)
-+ {
-+ delete share->db2Table;
-+ hash_delete(&ibmdb2i_open_tables, (uchar*) share);
-+ thr_lock_delete(&share->lock);
-+ my_errno = rc;
-+ goto error;
-+ }
-+
-+ memset(&share->cachedStats, 0, sizeof(share->cachedStats));
-+ }
-+ share->use_count++;
-+ pthread_mutex_unlock(&ibmdb2i_mutex);
-+
-+ db2Table = share->db2Table;
-+
-+ return share;
-+
-+error:
-+ pthread_mutex_destroy(&share->mutex);
-+ my_free((uchar*) share, MYF(0));
-+ pthread_mutex_unlock(&ibmdb2i_mutex);
-+
-+ return NULL;
-+}
-+
-+
-+
-+int ha_ibmdb2i::free_share(IBMDB2I_SHARE *share)
-+{
-+ pthread_mutex_lock(&ibmdb2i_mutex);
-+ if (!--share->use_count)
-+ {
-+ delete share->db2Table;
-+ db2Table = NULL;
-+
-+ hash_delete(&ibmdb2i_open_tables, (uchar*) share);
-+ thr_lock_delete(&share->lock);
-+ pthread_mutex_destroy(&share->mutex);
-+ my_free(share, MYF(0));
-+ pthread_mutex_unlock(&ibmdb2i_mutex);
-+ return 1;
-+ }
-+ pthread_mutex_unlock(&ibmdb2i_mutex);
-+
-+ return 0;
-+}
-+
-+static handler* ibmdb2i_create_handler(handlerton *hton,
-+ TABLE_SHARE *table,
-+ MEM_ROOT *mem_root)
-+{
-+ return new (mem_root) ha_ibmdb2i(hton, table);
-+}
-+
-+static void ibmdb2i_drop_database(handlerton *hton, char* path)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::ibmdb2i_drop_database");
-+ int rc = 0;
-+ char queryBuffer[200];
-+ String query(queryBuffer, sizeof(queryBuffer), system_charset_info);
-+ query.length(0);
-+ query.append(STRING_WITH_LEN(" DROP SCHEMA \""));
-+ query.append(path+2, strchr(path+2, '/')-(path+2));
-+ query.append('"');
-+
-+ SqlStatementStream sqlStream(query);
-+
-+ rc = db2i_ileBridge::getBridgeForThread()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ QMY_NONE,
-+ FALSE,
-+ TRUE);
-+ DBUG_VOID_RETURN;
-+}
-+
-+inline static void genSavepointName(const void* sv, char* out)
-+{
-+ *(uint32*)out = *(uint32*)SAVEPOINT_PREFIX;
-+ DBUG_ASSERT(sizeof(SAVEPOINT_PREFIX) == 4);
-+ out += sizeof(SAVEPOINT_PREFIX);
-+
-+ longlong2str((longlong)sv, out, 10);
-+ while (*out)
-+ {
-+ out += 0xF0;
-+ ++out;
-+ }
-+}
-+
-+
-+/*********************************************************************
-+Sets a transaction savepoint. */
-+static int ibmdb2i_savepoint_set(handlerton* hton, THD* thd, void* sv)
-+{
-+ DBUG_ENTER("ibmdb2i_savepoint_set");
-+ int rc = 0;
-+ if (!THDVAR(thd ,transaction_unsafe))
-+ {
-+ char name[64];
-+ genSavepointName(sv, name);
-+ DBUG_PRINT("ibmdb2i_savepoint_set",("Setting %s", name));
-+ rc = ha_ibmdb2i::doSavepointSet(thd, name);
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/*********************************************************************
-+Rollback a savepoint. */
-+static int ibmdb2i_savepoint_rollback(handlerton* hton, THD* thd, void* sv)
-+{
-+ DBUG_ENTER("ibmdb2i_savepoint_rollback");
-+ int rc = 0;
-+ if (!THDVAR(thd,transaction_unsafe))
-+ {
-+ char name[64];
-+ genSavepointName(sv, name);
-+ DBUG_PRINT("ibmdb2i_savepoint_rollback",("Rolling back %s", name));
-+ rc = ha_ibmdb2i::doSavepointRollback(thd, name);
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/*********************************************************************
-+Release a savepoint. */
-+static int ibmdb2i_savepoint_release(handlerton* hton, THD* thd, void* sv)
-+{
-+ DBUG_ENTER("ibmdb2i_savepoint_release");
-+ int rc = 0;
-+ if (!THDVAR(thd,transaction_unsafe))
-+ {
-+ char name[64];
-+ genSavepointName(sv, name);
-+ DBUG_PRINT("ibmdb2i_savepoint_release",("Releasing %s", name));
-+ rc = ha_ibmdb2i::doSavepointRelease(thd, name);
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+/* Thse flags allow for the online add and drop of an index via the CREATE INDEX,
-+ DROP INDEX, and ALTER TABLE statements. These flags indicate that MySQL is not
-+ required to lock the table before calling the storage engine to add or drop the
-+ index(s). */
-+static uint ibmdb2i_alter_table_flags(uint flags)
-+{
-+ return (HA_ONLINE_ADD_INDEX | HA_ONLINE_DROP_INDEX |
-+ HA_ONLINE_ADD_UNIQUE_INDEX | HA_ONLINE_DROP_UNIQUE_INDEX |
-+ HA_ONLINE_ADD_PK_INDEX | HA_ONLINE_DROP_PK_INDEX);
-+}
-+
-+ha_ibmdb2i::ha_ibmdb2i(handlerton *hton, TABLE_SHARE *table_arg)
-+ :share(NULL), handler(hton, table_arg),
-+ activeHandle(0), dataHandle(0),
-+ activeReadBuf(NULL), activeWriteBuf(NULL),
-+ blobReadBuffers(NULL), accessIntent(QMY_UPDATABLE), currentRRN(0),
-+ releaseRowNeeded(FALSE),
-+ indexReadSizeEstimates(NULL),
-+ outstanding_start_bulk_insert(false),
-+ last_rnd_init_rc(0),
-+ last_index_init_rc(0),
-+ last_start_bulk_insert_rc(0),
-+ autoIncLockAcquired(false),
-+ got_auto_inc_values(false),
-+ next_identity_value(0),
-+ indexHandles(0),
-+ returnDupKeysImmediately(false),
-+ onDupUpdate(false),
-+ blobWriteBuffers(NULL),
-+ forceSingleRowRead(false)
-+ {
-+ activeReferences = 0;
-+ ref_length = sizeof(currentRRN);
-+ if (table_share && table_share->keys > 0)
-+ {
-+ indexHandles = (FILE_HANDLE*)my_malloc(table_share->keys * sizeof(FILE_HANDLE), MYF(MY_WME | MY_ZEROFILL));
-+ }
-+ clear_alloc_root(&conversionBufferMemroot);
-+ }
-+
-+
-+ha_ibmdb2i::~ha_ibmdb2i()
-+{
-+ DBUG_ASSERT(activeReferences == 0 || outstanding_start_bulk_insert);
-+
-+ if (indexHandles)
-+ my_free(indexHandles, MYF(0));
-+ if (indexReadSizeEstimates)
-+ my_free(indexReadSizeEstimates, MYF(0));
-+
-+ cleanupBuffers();
-+}
-+
-+
-+static const char *ha_ibmdb2i_exts[] = {
-+ FID_EXT,
-+ NullS
-+};
-+
-+const char **ha_ibmdb2i::bas_ext() const
-+{
-+ return ha_ibmdb2i_exts;
-+}
-+
-+
-+int ha_ibmdb2i::open(const char *name, int mode, uint test_if_locked)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::open");
-+
-+ initBridge();
-+
-+ dataHandle = bridge()->findAndRemovePreservedHandle(name, &share);
-+
-+ if (share)
-+ db2Table = share->db2Table;
-+
-+ if (!share && (!(share = get_share(name, table))))
-+ DBUG_RETURN(my_errno);
-+ thr_lock_data_init(&share->lock,&lock,NULL);
-+
-+ info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
-+
-+
-+ DBUG_RETURN(0);
-+}
-+
-+
-+
-+
-+int ha_ibmdb2i::close(void)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::close");
-+ int32 rc = 0;
-+ bool preserveShare = false;
-+
-+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread();
-+
-+ if (dataHandle)
-+ {
-+ if (bridge->expectErrors(QMY_ERR_PEND_LOCKS)->deallocateFile(dataHandle, FALSE) == QMY_ERR_PEND_LOCKS)
-+ {
-+ bridge->preserveHandle(share->table_name, dataHandle, share);
-+ preserveShare = true;
-+ }
-+ dataHandle = 0;
-+ }
-+
-+ for (int idx = 0; idx < table_share->keys; ++idx)
-+ {
-+ if (indexHandles[idx] != 0)
-+ {
-+ bridge->deallocateFile(indexHandles[idx], FALSE);
-+ }
-+ }
-+
-+ cleanupBuffers();
-+
-+ if (!preserveShare)
-+ {
-+ if (free_share(share))
-+ share = NULL;
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+
-+int ha_ibmdb2i::write_row(uchar * buf)
-+{
-+
-+ DBUG_ENTER("ha_ibmdb2i::write_row");
-+
-+ if (last_start_bulk_insert_rc)
-+ DBUG_RETURN( last_start_bulk_insert_rc );
-+
-+ ha_statistic_increment(&SSV::ha_write_count);
-+ int rc = 0;
-+
-+ bool fileHandleNeedsRelease = false;
-+
-+ if (!activeHandle)
-+ {
-+ rc = useDataFile();
-+ if (rc) DBUG_RETURN(rc);
-+ fileHandleNeedsRelease = true;
-+ }
-+
-+ if (!outstanding_start_bulk_insert)
-+ rc = prepWriteBuffer(1, getFileForActiveHandle());
-+
-+ if (!rc)
-+ {
-+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
-+ table->timestamp_field->set_time();
-+
-+ char* writeBuffer = activeWriteBuf->addRow();
-+ rc = prepareRowForWrite(writeBuffer,
-+ writeBuffer+activeWriteBuf->getRowNullOffset(),
-+ true);
-+ if (rc == 0)
-+ {
-+ // If we are doing block inserts, if the MI is supposed to generate an auto_increment
-+ // (i.e. identity column) value for this record, and if this is not the first record in
-+ // the block, then store the value (that the MI will generate for the identity column)
-+ // into the MySQL write buffer. We can predetermine the value because the file is locked.
-+
-+ if ((autoIncLockAcquired) && (default_identity_value) && (got_auto_inc_values))
-+ {
-+ if (unlikely((next_identity_value - 1) ==
-+ maxValueForField(table->next_number_field)))
-+ {
-+ rc = QMY_ERR_MAXVALUE;
-+ }
-+ else
-+ {
-+ rc = table->next_number_field->store((longlong) next_identity_value, TRUE);
-+ next_identity_value = next_identity_value + incrementByValue;
-+ }
-+ }
-+ // If the buffer is full, or if we locked the file and this is the first or last row
-+ // of a blocked insert, then flush the buffer.
-+ if (!rc && (activeWriteBuf->endOfBuffer()) ||
-+ ((autoIncLockAcquired) &&
-+ ((!got_auto_inc_values))) ||
-+ (returnDupKeysImmediately))
-+ rc = flushWrite(activeHandle, buf);
-+ }
-+ else
-+ activeWriteBuf->deleteRow();
-+ }
-+
-+ if (fileHandleNeedsRelease)
-+ releaseActiveHandle();
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+/**
-+ @brief
-+ Helper function used by write_row and update_row to prepare the MySQL
-+ row for insertion into DB2.
-+*/
-+int ha_ibmdb2i::prepareRowForWrite(char* data, char* nulls, bool honorIdentCols)
-+{
-+ int rc = 0;
-+
-+ // set null map all to non nulls
-+ memset(nulls,__NOT_NULL_VALUE_EBCDIC, table->s->fields);
-+ default_identity_value = FALSE;
-+
-+ ulong sql_mode = ha_thd()->variables.sql_mode;
-+
-+ my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
-+ for (Field **field = table->field; *field && !rc; ++field)
-+ {
-+ int fieldIndex = (*field)->field_index;
-+ if ((*field)->Field::is_null())
-+ {
-+ nulls[fieldIndex] = __NULL_VALUE_EBCDIC;
-+ }
-+ if (honorIdentCols && ((*field)->flags & AUTO_INCREMENT_FLAG) &&
-+ *field == table->next_number_field)
-+// && ((!autoIncLockAcquired) || (!got_auto_inc_values)))
-+ {
-+ if (sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
-+ {
-+ if (!table->auto_increment_field_not_null)
-+ {
-+ nulls[fieldIndex] = __DEFAULT_VALUE_EBCDIC;
-+ default_identity_value = TRUE;
-+ }
-+ }
-+ else if ((*field)->val_int() == 0)
-+ {
-+ nulls[fieldIndex] = __DEFAULT_VALUE_EBCDIC;
-+ default_identity_value = TRUE;
-+ }
-+ }
-+
-+ DB2Field& db2Field = db2Table->db2Field(fieldIndex);
-+ if (nulls[fieldIndex] == __NOT_NULL_VALUE_EBCDIC ||
-+ db2Field.isBlob())
-+ {
-+ rc = convertMySQLtoDB2(*field, db2Field, data + db2Field.getBufferOffset());
-+ }
-+ }
-+
-+ if (!rc && db2Table->hasBlobs())
-+ rc = db2i_ileBridge::getBridgeForThread()->objectOverride(activeHandle,
-+ activeWriteBuf->ptr());
-+
-+ dbug_tmp_restore_column_map(table->read_set, old_map);
-+
-+ return rc;
-+}
-+
-+
-+
-+int ha_ibmdb2i::update_row(const uchar * old_data, uchar * new_data)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::update_row");
-+ ha_statistic_increment(&SSV::ha_update_count);
-+ int rc;
-+
-+ bool fileHandleNeedsRelease = false;
-+
-+ if (!activeHandle)
-+ {
-+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
-+ if (rc) DBUG_RETURN(rc);
-+ fileHandleNeedsRelease = true;
-+ }
-+
-+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
-+ table->timestamp_field->set_time();
-+
-+ char* writeBuf = activeWriteBuf->addRow();
-+ rc = prepareRowForWrite(writeBuf,
-+ writeBuf+activeWriteBuf->getRowNullOffset(),
-+ onDupUpdate);
-+
-+ char* lastDupKeyNamePtr = NULL;
-+ uint32 lastDupKeyNameLen = 0;
-+
-+ if (!rc)
-+ {
-+ rc = db2i_ileBridge::getBridgeForThread()->updateRow(activeHandle,
-+ currentRRN,
-+ activeWriteBuf->ptr(),
-+ &lastDupKeyRRN,
-+ &lastDupKeyNamePtr,
-+ &lastDupKeyNameLen);
-+ }
-+
-+ if (lastDupKeyNameLen)
-+ {
-+ lastDupKeyID = getKeyFromName(lastDupKeyNamePtr, lastDupKeyNameLen);
-+ rrnAssocHandle = activeHandle;
-+ }
-+
-+ if (fileHandleNeedsRelease)
-+ releaseActiveHandle();
-+
-+ activeWriteBuf->resetAfterWrite();
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::delete_row(const uchar * buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::delete_row");
-+ ha_statistic_increment(&SSV::ha_delete_count);
-+
-+ bool needReleaseFile = false;
-+ int rc = 0;
-+
-+ if (!activeHandle) // In some circumstances, MySQL comes here after
-+ { // closing the active handle. We need to re-open.
-+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
-+ needReleaseFile = true;
-+ }
-+
-+ if (likely(!rc))
-+ {
-+ rc = db2i_ileBridge::getBridgeForThread()->deleteRow(activeHandle,
-+ currentRRN);
-+ invalidateCachedStats();
-+ if (needReleaseFile)
-+ releaseActiveHandle();
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+
-+int ha_ibmdb2i::index_init(uint idx, bool sorted)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_init");
-+
-+ int& rc = last_index_init_rc;
-+ rc = 0;
-+
-+ invalidDataFound=false;
-+ tweakReadSet();
-+
-+ active_index=idx;
-+
-+ rc = useIndexFile(idx);
-+
-+ if (!rc)
-+ {
-+// THD* thd = ha_thd();
-+// if (accessIntent == QMY_UPDATABLE &&
-+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
-+// !THDVAR(thd, transaction_unsafe))
-+// {
-+// readAccessIntent = QMY_READ_ONLY;
-+// }
-+// else
-+// {
-+ readAccessIntent = accessIntent;
-+// }
-+
-+ if (!rc && accessIntent != QMY_READ_ONLY)
-+ rc = prepWriteBuffer(1, db2Table->indexFile(idx));
-+
-+ if (rc)
-+ releaseIndexFile(idx);
-+ }
-+
-+ rrnAssocHandle= 0;
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+
-+int ha_ibmdb2i::index_read(uchar * buf, const uchar * key,
-+ uint key_len,
-+ enum ha_rkey_function find_flag)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_read");
-+
-+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
-+
-+ int rc;
-+
-+ ha_rows estimatedRows = getIndexReadEstimate(active_index);
-+ rc = prepReadBuffer(estimatedRows, db2Table->indexFile(active_index), readAccessIntent);
-+ if (unlikely(rc)) DBUG_RETURN(rc);
-+
-+ DBUG_ASSERT(activeReadBuf);
-+
-+ keyBuf.allocBuf(activeReadBuf->getRowLength(),
-+ activeReadBuf->getRowNullOffset(),
-+ activeReadBuf->getRowLength());
-+ keyBuf.zeroBuf();
-+
-+ char* db2KeyBufPtr = keyBuf.ptr();
-+ char* nullKeyMap = db2KeyBufPtr + activeReadBuf->getRowNullOffset();
-+
-+ const uchar* keyBegin = key;
-+ int partsInUse;
-+
-+ KEY& curKey = table->key_info[active_index];
-+
-+ for (partsInUse = 0; partsInUse < curKey.key_parts, key - keyBegin < key_len; ++partsInUse)
-+ {
-+ Field* field = curKey.key_part[partsInUse].field;
-+ if ((curKey.key_part[partsInUse].null_bit) &&
-+ (char*)key[0])
-+ {
-+ if (field->flags & AUTO_INCREMENT_FLAG)
-+ {
-+ table->status = STATUS_NOT_FOUND;
-+ DBUG_RETURN(HA_ERR_END_OF_FILE);
-+ }
-+ else
-+ {
-+ nullKeyMap[partsInUse] = __NULL_VALUE_EBCDIC;
-+ }
-+ }
-+ else
-+ {
-+ nullKeyMap[partsInUse] = __NOT_NULL_VALUE_EBCDIC;
-+ convertMySQLtoDB2(field,
-+ db2Table->db2Field(field->field_index),
-+ db2KeyBufPtr,
-+ (uchar*)key+((curKey.key_part[partsInUse].null_bit)? 1 : 0) ); // + (curKey.key_parts+7) / 8);
-+ }
-+
-+ db2KeyBufPtr += db2Table->db2Field(field->field_index).getByteLengthInRecord();
-+ key += curKey.key_part[partsInUse].store_length;
-+ }
-+
-+ keyLen = db2KeyBufPtr - (char*)keyBuf.ptr();
-+
-+ DBUG_PRINT("ha_ibmdb2i::index_read", ("find_flag: %d", find_flag));
-+
-+ char readDirection = QMY_NEXT;
-+
-+ switch (find_flag)
-+ {
-+ case HA_READ_AFTER_KEY:
-+ doInitialRead(QMY_AFTER_EQUAL, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ break;
-+ case HA_READ_BEFORE_KEY:
-+ doInitialRead(QMY_BEFORE_EQUAL, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ break;
-+ case HA_READ_KEY_OR_NEXT:
-+ doInitialRead(QMY_AFTER_OR_EQUAL, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ break;
-+ case HA_READ_KEY_OR_PREV:
-+ DBUG_ASSERT(0); // This function is unused
-+ doInitialRead(QMY_BEFORE_OR_EQUAL, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ break;
-+ case HA_READ_PREFIX_LAST_OR_PREV:
-+ doInitialRead(QMY_LAST_PREVIOUS, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ readDirection = QMY_PREVIOUS;
-+ break;
-+ case HA_READ_PREFIX_LAST:
-+ doInitialRead(QMY_PREFIX_LAST, estimatedRows,
-+ keyBuf.ptr(), keyLen, partsInUse);
-+ readDirection = QMY_PREVIOUS;
-+ break;
-+ case HA_READ_KEY_EXACT:
-+ doInitialRead(QMY_EQUAL, estimatedRows, keyBuf.ptr(), keyLen, partsInUse);
-+ break;
-+ default:
-+ DBUG_ASSERT(0);
-+ return HA_ERR_GENERIC;
-+ break;
-+ }
-+
-+ ha_statistic_increment(&SSV::ha_read_key_count);
-+ rc = readFromBuffer(buf, readDirection);
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::index_next(uchar * buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_next");
-+ ha_statistic_increment(&SSV::ha_read_next_count);
-+
-+ int rc = readFromBuffer(buf, QMY_NEXT);
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::index_next_same(uchar *buf, const uchar *key, uint keylen)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_next_same");
-+ ha_statistic_increment(&SSV::ha_read_next_count);
-+
-+ int rc = readFromBuffer(buf, QMY_NEXT_EQUAL);
-+
-+ if (rc == HA_ERR_KEY_NOT_FOUND)
-+ {
-+ rc = HA_ERR_END_OF_FILE;
-+ }
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+int ha_ibmdb2i::index_read_last(uchar * buf, const uchar * key, uint key_len)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_read_last");
-+ DBUG_RETURN(index_read(buf, key, key_len, HA_READ_PREFIX_LAST));
-+}
-+
-+
-+
-+int ha_ibmdb2i::index_prev(uchar * buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_prev");
-+ ha_statistic_increment(&SSV::ha_read_prev_count);
-+
-+ int rc = readFromBuffer(buf, QMY_PREVIOUS);
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::index_first(uchar * buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_first");
-+
-+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
-+
-+ int rc = prepReadBuffer(DEFAULT_MAX_ROWS_TO_BUFFER,
-+ db2Table->indexFile(active_index),
-+ readAccessIntent);
-+
-+ if (rc == 0)
-+ {
-+ doInitialRead(QMY_FIRST, DEFAULT_MAX_ROWS_TO_BUFFER);
-+ ha_statistic_increment(&SSV::ha_read_first_count);
-+ rc = readFromBuffer(buf, QMY_NEXT);
-+ }
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::index_last(uchar * buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_last");
-+
-+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
-+
-+ int rc = prepReadBuffer(DEFAULT_MAX_ROWS_TO_BUFFER,
-+ db2Table->indexFile(active_index),
-+ readAccessIntent);
-+
-+ if (rc == 0)
-+ {
-+ doInitialRead(QMY_LAST, DEFAULT_MAX_ROWS_TO_BUFFER);
-+ ha_statistic_increment(&SSV::ha_read_last_count);
-+ rc = readFromBuffer(buf, QMY_PREVIOUS);
-+ }
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::rnd_init(bool scan)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::rnd_init");
-+
-+ int& rc = last_rnd_init_rc;
-+ rc = 0;
-+
-+ tweakReadSet();
-+ invalidDataFound=false;
-+
-+ uint32 rowsToBlockOnRead;
-+
-+ if (!scan)
-+ {
-+ rowsToBlockOnRead = 1;
-+ }
-+ else
-+ {
-+ rowsToBlockOnRead = DEFAULT_MAX_ROWS_TO_BUFFER;
-+ }
-+
-+ rc = useDataFile();
-+
-+ if (!rc)
-+ {
-+// THD* thd = ha_thd();
-+// if (accessIntent == QMY_UPDATABLE &&
-+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
-+// !THDVAR(thd, transaction_unsafe))
-+// {
-+// readAccessIntent = QMY_READ_ONLY;
-+// }
-+// else
-+// {
-+ readAccessIntent = accessIntent;
-+// }
-+
-+ rc = prepReadBuffer(rowsToBlockOnRead, db2Table->dataFile(), readAccessIntent);
-+
-+ if (!rc && accessIntent != QMY_READ_ONLY)
-+ rc = prepWriteBuffer(1, db2Table->dataFile());
-+
-+ if (!rc && scan)
-+ doInitialRead(QMY_FIRST, rowsToBlockOnRead);
-+
-+ if (rc)
-+ releaseDataFile();
-+ }
-+
-+ rrnAssocHandle= 0;
-+
-+ DBUG_RETURN(0); // MySQL sometimes does not check the return code, causing
-+ // an assert in ha_rnd_end later on if we return a non-zero
-+ // value here.
-+}
-+
-+int ha_ibmdb2i::rnd_end()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::rnd_end");
-+
-+ warnIfInvalidData();
-+ if (likely(activeReadBuf))
-+ activeReadBuf->endRead();
-+ if (last_rnd_init_rc == 0)
-+ releaseActiveHandle();
-+ last_rnd_init_rc = 0;
-+ DBUG_RETURN(0);
-+}
-+
-+
-+int32 ha_ibmdb2i::mungeDB2row(uchar* record, const char* dataPtr, const char* nullMapPtr, bool skipLOBs)
-+{
-+ DBUG_ASSERT(dataPtr);
-+
-+ my_bitmap_map *old_write_map= dbug_tmp_use_all_columns(table, table->write_set);
-+ my_bitmap_map *old_read_map;
-+
-+ if (unlikely(readAllColumns))
-+ old_read_map = tmp_use_all_columns(table, table->read_set);
-+
-+ resetCharacterConversionBuffers();
-+
-+ my_ptrdiff_t old_ptr= (my_ptrdiff_t) (record - table->record[0]);
-+ int fieldIndex = 0;
-+ for (Field **field = table->field; *field; ++field, ++fieldIndex)
-+ {
-+ if (unlikely(old_ptr))
-+ (*field)->move_field_offset(old_ptr);
-+ if (nullMapPtr[fieldIndex] == __NULL_VALUE_EBCDIC ||
-+ (!bitmap_is_set(table->read_set, fieldIndex)) ||
-+ (skipLOBs && db2Table->db2Field(fieldIndex).isBlob()))
-+ {
-+ (*field)->set_null();
-+ }
-+ else
-+ {
-+ (*field)->set_notnull();
-+ convertDB2toMySQL(db2Table->db2Field(fieldIndex), *field, dataPtr);
-+ }
-+ if (unlikely(old_ptr))
-+ (*field)->move_field_offset(-old_ptr);
-+
-+ }
-+
-+ if (unlikely(readAllColumns))
-+ tmp_restore_column_map(table->read_set, old_read_map);
-+ dbug_tmp_restore_column_map(table->write_set, old_write_map);
-+
-+ return 0;
-+}
-+
-+
-+int ha_ibmdb2i::rnd_next(uchar *buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::rnd_next");
-+
-+ if (unlikely(last_rnd_init_rc)) DBUG_RETURN(last_rnd_init_rc);
-+ ha_statistic_increment(&SSV::ha_read_rnd_next_count);
-+
-+ int rc;
-+
-+ rc = readFromBuffer(buf, QMY_NEXT);
-+
-+ table->status= (rc ? STATUS_NOT_FOUND: 0);
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+void ha_ibmdb2i::position(const uchar *record)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::position");
-+ my_store_ptr(ref, ref_length, currentRRN);
-+ DBUG_VOID_RETURN;
-+}
-+
-+
-+int ha_ibmdb2i::rnd_pos(uchar * buf, uchar *pos)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::rnd_pos");
-+ if (unlikely(last_rnd_init_rc)) DBUG_RETURN( last_rnd_init_rc);
-+ ha_statistic_increment(&SSV::ha_read_rnd_count);
-+
-+ currentRRN = my_get_ptr(pos, ref_length);
-+
-+ tweakReadSet();
-+
-+ int rc = 0;
-+
-+ if (rrnAssocHandle &&
-+ (activeHandle != rrnAssocHandle))
-+ {
-+ if (activeHandle) releaseActiveHandle();
-+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
-+ }
-+
-+ if (likely(rc == 0))
-+ {
-+ rc = prepReadBuffer(1, getFileForActiveHandle(), accessIntent);
-+
-+ if (likely(rc == 0) && accessIntent == QMY_UPDATABLE)
-+ rc = prepWriteBuffer(1, getFileForActiveHandle());
-+
-+ if (likely(rc == 0))
-+ {
-+ rc = db2i_ileBridge::getBridgeForThread()->readByRRN(activeHandle,
-+ activeReadBuf->ptr(),
-+ currentRRN,
-+ accessIntent,
-+ getCommitLevel());
-+
-+ if (likely(rc == 0))
-+ {
-+ rrnAssocHandle = activeHandle;
-+ const char* readBuf = activeReadBuf->getRowN(0);
-+ rc = mungeDB2row(buf, readBuf, readBuf + activeReadBuf->getRowNullOffset(), false);
-+ releaseRowNeeded = TRUE;
-+ }
-+ }
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::info(uint flag)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::info");
-+
-+ uint16 infoRequested = 0;
-+ ValidatedPointer<char> rowKeySpcPtr; // Space pointer passed to DB2
-+ uint32 rowKeySpcLen; // Length of space passed to DB2
-+ THD* thd = ha_thd();
-+ int command = thd_sql_command(thd);
-+
-+ if (flag & HA_STATUS_AUTO)
-+ stats.auto_increment_value = (ulonglong) 0;
-+
-+ if (flag & HA_STATUS_ERRKEY)
-+ {
-+ errkey = lastDupKeyID;
-+ my_store_ptr(dup_ref, ref_length, lastDupKeyRRN);
-+ }
-+
-+ if (flag & HA_STATUS_TIME)
-+ {
-+ if ((flag & HA_STATUS_NO_LOCK) &&
-+ ibmdb2i_assume_exclusive_use &&
-+ share &&
-+ (share->cachedStats.isInited(lastModTime)))
-+ stats.update_time = share->cachedStats.getUpdateTime();
-+ else
-+ infoRequested |= lastModTime;
-+ }
-+
-+ if (flag & HA_STATUS_CONST)
-+ {
-+ stats.block_size=4096;
-+ infoRequested |= createTime;
-+
-+ if (table->s->keys)
-+ {
-+ infoRequested |= rowsPerKey;
-+ rowKeySpcLen = (table->s->keys) * MAX_DB2_KEY_PARTS * sizeof(uint64);
-+ rowKeySpcPtr.alloc(rowKeySpcLen);
-+ memset(rowKeySpcPtr, 0, rowKeySpcLen); // Clear the allocated space
-+ }
-+ }
-+
-+ if (flag & HA_STATUS_VARIABLE)
-+ {
-+ if ((flag & HA_STATUS_NO_LOCK) &&
-+ (command != SQLCOM_SHOW_TABLE_STATUS) &&
-+ ibmdb2i_assume_exclusive_use &&
-+ share &&
-+ (share->cachedStats.isInited(rowCount | deletedRowCount | meanRowLen | ioCount)) &&
-+ (share->cachedStats.getRowCount() >= 2))
-+ {
-+ stats.records = share->cachedStats.getRowCount();
-+ stats.deleted = share->cachedStats.getDelRowCount();
-+ stats.mean_rec_length = share->cachedStats.getMeanLength();
-+ stats.data_file_length = share->cachedStats.getAugmentedDataLength();
-+ }
-+ else
-+ {
-+ infoRequested |= rowCount | deletedRowCount | meanRowLen;
-+ if (command == SQLCOM_SHOW_TABLE_STATUS)
-+ infoRequested |= objLength;
-+ else
-+ infoRequested |= ioCount;
-+ }
-+ }
-+
-+ int rc = 0;
-+
-+ if (infoRequested)
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::info",("Retrieving fresh stats %d", flag));
-+
-+ initBridge(thd);
-+ rc = bridge()->retrieveTableInfo((dataHandle ? dataHandle : db2Table->dataFile()->getMasterDefnHandle()),
-+ infoRequested,
-+ stats,
-+ rowKeySpcPtr);
-+
-+ if (!rc)
-+ {
-+ if ((flag & HA_STATUS_VARIABLE) &&
-+ (command != SQLCOM_SHOW_TABLE_STATUS))
-+ stats.data_file_length = stats.data_file_length * IO_SIZE;
-+
-+ if ((ibmdb2i_assume_exclusive_use) &&
-+ (share) &&
-+ (command != SQLCOM_SHOW_TABLE_STATUS))
-+ {
-+ if (flag & HA_STATUS_VARIABLE)
-+ {
-+ share->cachedStats.cacheRowCount(stats.records);
-+ share->cachedStats.cacheDelRowCount(stats.deleted);
-+ share->cachedStats.cacheMeanLength(stats.mean_rec_length);
-+ share->cachedStats.cacheAugmentedDataLength(stats.data_file_length);
-+ }
-+
-+ if (flag & HA_STATUS_TIME)
-+ {
-+ share->cachedStats.cacheUpdateTime(stats.update_time);
-+ }
-+ }
-+
-+ if (flag & HA_STATUS_CONST)
-+ {
-+ ulong i; // Loop counter for indexes
-+ ulong j; // Loop counter for key parts
-+ RowKey* rowKeyPtr; // Pointer to 'number of unique rows' array for this index
-+
-+ rowKeyPtr = (RowKey_t*)(void*)rowKeySpcPtr; // Address first array of DB2 row counts
-+ for (i = 0; i < table->s->keys; i++) // Do for each index, including primary
-+ {
-+ for (j = 0; j < table->key_info[i].key_parts; j++)
-+ {
-+ table->key_info[i].rec_per_key[j]= rowKeyPtr->RowKeyArray[j];
-+ }
-+ rowKeyPtr = rowKeyPtr + 1; // Address next array of DB2 row counts
-+ }
-+ }
-+ }
-+ else if (rc == HA_ERR_LOCK_WAIT_TIMEOUT && share)
-+ {
-+ // If we couldn't retrieve the info because the object was locked,
-+ // we'll do our best by returning the most recently cached data.
-+ if ((infoRequested & rowCount) &&
-+ share->cachedStats.isInited(rowCount))
-+ stats.records = share->cachedStats.getRowCount();
-+ if ((infoRequested & deletedRowCount) &&
-+ share->cachedStats.isInited(deletedRowCount))
-+ stats.deleted = share->cachedStats.getDelRowCount();
-+ if ((infoRequested & meanRowLen) &&
-+ share->cachedStats.isInited(meanRowLen))
-+ stats.mean_rec_length = share->cachedStats.getMeanLength();
-+ if ((infoRequested & lastModTime) &&
-+ share->cachedStats.isInited(lastModTime))
-+ stats.update_time = share->cachedStats.getUpdateTime();
-+
-+ rc = 0;
-+ }
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+ha_rows ha_ibmdb2i::records()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::records");
-+ int rc;
-+ rc = bridge()->retrieveTableInfo((dataHandle ? dataHandle : db2Table->dataFile()->getMasterDefnHandle()),
-+ rowCount,
-+ stats);
-+
-+ if (unlikely(rc))
-+ {
-+ if (rc == HA_ERR_LOCK_WAIT_TIMEOUT &&
-+ share &&
-+ (share->cachedStats.isInited(rowCount)))
-+ DBUG_RETURN(share->cachedStats.getRowCount());
-+ else
-+ DBUG_RETURN(HA_POS_ERROR);
-+ }
-+ else if (share)
-+ {
-+ share->cachedStats.cacheRowCount(stats.records);
-+ }
-+
-+ DBUG_RETURN(stats.records);
-+}
-+
-+
-+int ha_ibmdb2i::extra(enum ha_extra_function operation)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::extra");
-+
-+ switch(operation)
-+ {
-+ // Can these first five flags be replaced by attending to HA_EXTRA_WRITE_CACHE?
-+ case HA_EXTRA_NO_IGNORE_DUP_KEY:
-+ case HA_EXTRA_WRITE_CANNOT_REPLACE:
-+ {
-+ returnDupKeysImmediately = false;
-+ onDupUpdate = false;
-+ }
-+ break;
-+ case HA_EXTRA_INSERT_WITH_UPDATE:
-+ {
-+ returnDupKeysImmediately = true;
-+ onDupUpdate = true;
-+ }
-+ break;
-+ case HA_EXTRA_IGNORE_DUP_KEY:
-+ case HA_EXTRA_WRITE_CAN_REPLACE:
-+ returnDupKeysImmediately = true;
-+ break;
-+ case HA_EXTRA_FLUSH_CACHE:
-+ if (outstanding_start_bulk_insert)
-+ finishBulkInsert();
-+ break;
-+ }
-+
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/**
-+ @brief
-+ The DB2 storage engine will ignore a MySQL generated value and will generate
-+ a new value in SLIC. We arbitrarily set first_value to 1, and set the
-+ interval to infinity for better performance on multi-row inserts.
-+*/
-+void ha_ibmdb2i::get_auto_increment(ulonglong offset, ulonglong increment,
-+ ulonglong nb_desired_values,
-+ ulonglong *first_value,
-+ ulonglong *nb_reserved_values)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::get_auto_increment");
-+ *first_value= 1;
-+ *nb_reserved_values= ULONGLONG_MAX;
-+}
-+
-+
-+
-+void ha_ibmdb2i::update_create_info(HA_CREATE_INFO *create_info)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::update_create_info");
-+
-+ if ((!(create_info->used_fields & HA_CREATE_USED_AUTO)) &&
-+ (table->found_next_number_field != NULL))
-+ {
-+ initBridge();
-+
-+ create_info->auto_increment_value= 1;
-+
-+ ha_rows rowCount = records();
-+
-+ if (rowCount == 0)
-+ {
-+ create_info->auto_increment_value = db2Table->getStartId();
-+ DBUG_VOID_RETURN;
-+ }
-+ else if (rowCount == HA_POS_ERROR)
-+ {
-+ DBUG_VOID_RETURN;
-+ }
-+
-+ getNextIdVal(&create_info->auto_increment_value);
-+ }
-+ DBUG_VOID_RETURN;
-+}
-+
-+
-+int ha_ibmdb2i::getNextIdVal(ulonglong *value)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::getNextIdVal");
-+
-+ char queryBuffer[MAX_DB2_COLNAME_LENGTH + MAX_DB2_QUALIFIEDNAME_LENGTH + 64];
-+ strcpy(queryBuffer, " SELECT CAST(MAX( ");
-+ convertMySQLNameToDB2Name(table->found_next_number_field->field_name,
-+ strend(queryBuffer),
-+ MAX_DB2_COLNAME_LENGTH+1);
-+ strcat(queryBuffer, ") AS BIGINT) FROM ");
-+ db2Table->getDB2QualifiedName(strend(queryBuffer));
-+ DBUG_ASSERT(strlen(queryBuffer) < sizeof(queryBuffer));
-+
-+ SqlStatementStream sqlStream(queryBuffer);
-+ DBUG_PRINT("ha_ibmdb2i::getNextIdVal", ("Sent to DB2: %s",queryBuffer));
-+
-+ int rc = 0;
-+ FILE_HANDLE fileHandle2;
-+ uint32 db2RowDataLen2;
-+ rc = bridge()->prepOpen(sqlStream.getPtrToData(),
-+ &fileHandle2,
-+ &db2RowDataLen2);
-+ if (likely(rc == 0))
-+ {
-+ IOReadBuffer rowBuffer(1, db2RowDataLen2);
-+ rc = bridge()->read(fileHandle2,
-+ rowBuffer.ptr(),
-+ QMY_READ_ONLY,
-+ QMY_NONE,
-+ QMY_FIRST);
-+
-+ if (likely(rc == 0))
-+ {
-+ /* This check is here for the case where the table is not empty,
-+ but the auto_increment starting value has been changed since
-+ the last record was written. */
-+
-+ longlong maxIdVal = *(longlong*)(rowBuffer.getRowN(0));
-+ if ((maxIdVal + 1) > db2Table->getStartId())
-+ *value = maxIdVal + 1;
-+ else
-+ *value = db2Table->getStartId();
-+ }
-+
-+ bridge()->deallocateFile(fileHandle2);
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/*
-+ Updates index cardinalities.
-+*/
-+int ha_ibmdb2i::analyze(THD* thd, HA_CHECK_OPT *check_opt)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::analyze");
-+ info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
-+ DBUG_RETURN(0);
-+}
-+
-+int ha_ibmdb2i::optimize(THD* thd, HA_CHECK_OPT *check_opt)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::optimize");
-+
-+ initBridge(thd);
-+
-+ if (unlikely(records() == 0))
-+ DBUG_RETURN(0); // DB2 doesn't like to reorganize a table with no data.
-+
-+ quiesceAllFileHandles();
-+
-+ int32 rc = bridge()->optimizeTable(db2Table->dataFile()->getMasterDefnHandle());
-+ info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/**
-+ @brief
-+ Determines if an ALTER TABLE is allowed to switch the storage engine
-+ for this table. If the table has a foreign key or is referenced by a
-+ foreign key, then it cannot be switched.
-+*/
-+bool ha_ibmdb2i::can_switch_engines(void)
-+/*=================================*/
-+{
-+ DBUG_ENTER("ha_ibmdb2i::can_switch_engines");
-+
-+ int rc = 0;
-+ FILE_HANDLE queryFile = 0;
-+ uint32 resultRowLen;
-+ uint count = 0;
-+ bool can_switch = FALSE; // 1 if changing storage engine is allowed
-+
-+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
-+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
-+
-+ String query(256);
-+ query.append(STRING_WITH_LEN(" SELECT COUNT(*) FROM SYSIBM.SQLFOREIGNKEYS WHERE ((PKTABLE_SCHEM = '"));
-+ query.append(libName+1, strlen(libName)-2); // Remove quotes from parent schema name
-+ query.append(STRING_WITH_LEN("' AND PKTABLE_NAME = '"));
-+ query.append(fileName+1,strlen(fileName)-2); // Remove quotes from file name
-+ query.append(STRING_WITH_LEN("') OR (FKTABLE_SCHEM = '"));
-+ query.append(libName+1,strlen(libName)-2); // Remove quotes from child schema
-+ query.append(STRING_WITH_LEN("' AND FKTABLE_NAME = '"));
-+ query.append(fileName+1,strlen(fileName)-2); // Remove quotes from child name
-+ query.append(STRING_WITH_LEN("'))"));
-+
-+ SqlStatementStream sqlStream(query);
-+
-+ rc = bridge()->prepOpen(sqlStream.getPtrToData(),
-+ &queryFile,
-+ &resultRowLen);
-+ if (rc == 0)
-+ {
-+ IOReadBuffer rowBuffer(1, resultRowLen);
-+
-+ rc = bridge()->read(queryFile,
-+ rowBuffer.ptr(),
-+ QMY_READ_ONLY,
-+ QMY_NONE,
-+ QMY_FIRST);
-+ if (!rc)
-+ {
-+ count = *(uint*)(rowBuffer.getRowN(0));
-+ if (count == 0)
-+ can_switch = TRUE;
-+ }
-+
-+ bridge()->deallocateFile(queryFile);
-+ }
-+ DBUG_RETURN(can_switch);
-+}
-+
-+
-+
-+bool ha_ibmdb2i::check_if_incompatible_data(HA_CREATE_INFO *info,
-+ uint table_changes)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::check_if_incompatible_data");
-+ uint i;
-+ /* Check that auto_increment value and field definitions were
-+ not changed. */
-+ if ((info->used_fields & HA_CREATE_USED_AUTO &&
-+ info->auto_increment_value != 0) ||
-+ table_changes != IS_EQUAL_YES)
-+ DBUG_RETURN(COMPATIBLE_DATA_NO);
-+ /* Check if any fields were renamed. */
-+ for (i= 0; i < table->s->fields; i++)
-+ {
-+ Field *field= table->field[i];
-+ if (field->flags & FIELD_IS_RENAMED)
-+ {
-+ DBUG_PRINT("info", ("Field has been renamed, copy table"));
-+ DBUG_RETURN(COMPATIBLE_DATA_NO);
-+ }
-+ }
-+ DBUG_RETURN(COMPATIBLE_DATA_YES);
-+}
-+
-+int ha_ibmdb2i::reset_auto_increment(ulonglong value)
-+ {
-+ DBUG_ENTER("ha_ibmdb2i::reset_auto_increment");
-+
-+ int rc = 0;
-+
-+ quiesceAllFileHandles();
-+
-+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
-+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
-+
-+ String query(512);
-+ query.append(STRING_WITH_LEN(" ALTER TABLE "));
-+ query.append(libName);
-+ query.append('.');
-+ query.append(fileName);
-+ query.append(STRING_WITH_LEN(" ALTER COLUMN "));
-+ char colName[MAX_DB2_COLNAME_LENGTH+1];
-+ convertMySQLNameToDB2Name(table->found_next_number_field->field_name,
-+ colName,
-+ sizeof(colName));
-+ query.append(colName);
-+
-+ char restart_value[22];
-+ CHARSET_INFO *cs= &my_charset_bin;
-+ uint len = (uint)(cs->cset->longlong10_to_str)(cs,restart_value,sizeof(restart_value), 10, value);
-+ restart_value[len] = 0;
-+
-+ query.append(STRING_WITH_LEN(" RESTART WITH "));
-+ query.append(restart_value);
-+
-+ SqlStatementStream sqlStream(query);
-+ DBUG_PRINT("ha_ibmdb2i::reset_auto_increment", ("Sent to DB2: %s",query.c_ptr()));
-+
-+ rc = db2i_ileBridge::getBridgeForThread()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ QMY_NONE, //getCommitLevel(),
-+ FALSE,
-+ FALSE,
-+ TRUE, //FALSE,
-+ dataHandle);
-+ if (rc == 0)
-+ db2Table->updateStartId(value);
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/**
-+ @brief
-+ This function receives an error code that was previously set by the handler.
-+ It returns to MySQL the error string associated with that error.
-+*/
-+bool ha_ibmdb2i::get_error_message(int error, String *buf)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::get_error_message");
-+ if ((error >= DB2I_FIRST_ERR && error <= DB2I_LAST_ERR) ||
-+ (error >= QMY_ERR_MIN && error <= QMY_ERR_MAX))
-+ {
-+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread(ha_thd());
-+ char* errMsg = bridge->getErrorStorage();
-+ buf->copy(errMsg, strlen(errMsg),system_charset_info);
-+ bridge->freeErrorStorage();
-+ }
-+ DBUG_RETURN(FALSE);
-+}
-+
-+
-+int ha_ibmdb2i::delete_all_rows()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::delete_all_rows");
-+ int rc = 0;
-+ char queryBuffer[MAX_DB2_QUALIFIEDNAME_LENGTH + 64];
-+ strcpy(queryBuffer, " DELETE FROM ");
-+ db2Table->getDB2QualifiedName(strend(queryBuffer));
-+ DBUG_ASSERT(strlen(queryBuffer) < sizeof(queryBuffer));
-+
-+ SqlStatementStream sqlStream(queryBuffer);
-+ DBUG_PRINT("ha_ibmdb2i::delete_all_rows", ("Sent to DB2: %s",queryBuffer));
-+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ getCommitLevel(),
-+ false,
-+ false,
-+ true,
-+ dataHandle);
-+
-+ /* If this method was called on behalf of a TRUNCATE TABLE statement, and if */
-+ /* the table has an auto_increment field, then reset the starting value for */
-+ /* the auto_increment field to 1.
-+ */
-+ if (rc == 0 && thd_sql_command(ha_thd()) == SQLCOM_TRUNCATE &&
-+ table->found_next_number_field )
-+ rc = reset_auto_increment(1);
-+
-+ invalidateCachedStats();
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::external_lock(THD *thd, int lock_type)
-+{
-+ int rc = 0;
-+
-+ DBUG_ENTER("ha_ibmdb2i::external_lock");
-+ DBUG_PRINT("ha_ibmdb2i::external_lock",("Lock type: %d", lock_type));
-+
-+ if (lock_type == F_RDLCK)
-+ accessIntent = QMY_READ_ONLY;
-+ else if (lock_type == F_WRLCK)
-+ accessIntent = QMY_UPDATABLE;
-+
-+ initBridge(thd);
-+ int command = thd_sql_command(thd);
-+
-+ if (!THDVAR(thd,transaction_unsafe))
-+ {
-+ if (lock_type != F_UNLCK)
-+ {
-+ if (autoCommitIsOn(thd) == QMY_YES)
-+ {
-+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
-+ }
-+ else
-+ {
-+ trans_register_ha(thd, TRUE, ibmdb2i_hton);
-+ if (likely(command != SQLCOM_CREATE_TABLE))
-+ {
-+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
-+ bridge()->beginStmtTx();
-+ }
-+ }
-+ }
-+ }
-+
-+ if (command == SQLCOM_LOCK_TABLES ||
-+ command == SQLCOM_ALTER_TABLE ||
-+ command == SQLCOM_UNLOCK_TABLES ||
-+ (accessIntent == QMY_UPDATABLE &&
-+ (command == SQLCOM_UPDATE ||
-+ command == SQLCOM_UPDATE_MULTI ||
-+ command == SQLCOM_DELETE ||
-+ command == SQLCOM_DELETE_MULTI ||
-+ command == SQLCOM_REPLACE ||
-+ command == SQLCOM_REPLACE_SELECT) &&
-+ getCommitLevel(thd) == QMY_NONE))
-+ {
-+ char action;
-+ char type;
-+ if (lock_type == F_UNLCK)
-+ {
-+ action = QMY_UNLOCK;
-+ type = accessIntent == QMY_READ_ONLY ? QMY_LSRD : QMY_LENR;
-+ }
-+ else
-+ {
-+ action = QMY_LOCK;
-+ type = lock_type == F_RDLCK ? QMY_LSRD : QMY_LENR;
-+ }
-+
-+ DBUG_PRINT("ha_ibmdb2i::external_lock",("%socking table", action==QMY_LOCK ? "L" : "Unl"));
-+
-+ if (!dataHandle)
-+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
-+
-+ rc = bridge()->lockObj(dataHandle,
-+ 0,
-+ action,
-+ type,
-+ (command == SQLCOM_LOCK_TABLES ? QMY_NO : QMY_YES));
-+
-+ }
-+
-+ // Cache this away so we don't have to access it on each row operation
-+ cachedZeroDateOption = (enum_ZeroDate)THDVAR(thd, compat_opt_allow_zero_date_vals);
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+THR_LOCK_DATA **ha_ibmdb2i::store_lock(THD *thd,
-+ THR_LOCK_DATA **to,
-+ enum thr_lock_type lock_type)
-+{
-+ if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
-+ {
-+ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
-+ lock_type <= TL_WRITE) && !(thd->in_lock_tables && thd_sql_command(thd) == SQLCOM_LOCK_TABLES))
-+ lock_type= TL_WRITE_ALLOW_WRITE;
-+ lock.type=lock_type;
-+ }
-+ *to++= &lock;
-+ return to;
-+}
-+
-+
-+int ha_ibmdb2i::delete_table(const char *name)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::delete_table");
-+ THD* thd = ha_thd();
-+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread(thd);
-+
-+ char db2Name[MAX_DB2_QUALIFIEDNAME_LENGTH];
-+ db2i_table::getDB2QualifiedNameFromPath(name, db2Name);
-+
-+ String query(128);
-+ query.append(STRING_WITH_LEN(" DROP TABLE "));
-+ query.append(db2Name);
-+
-+ if (thd_sql_command(thd) == SQLCOM_DROP_TABLE &&
-+ thd->lex->drop_mode == DROP_RESTRICT)
-+ query.append(STRING_WITH_LEN(" RESTRICT "));
-+ DBUG_PRINT("ha_ibmdb2i::delete_table", ("Sent to DB2: %s",query.c_ptr()));
-+
-+ SqlStatementStream sqlStream(query);
-+
-+ db2i_table::getDB2LibNameFromPath(name, db2Name);
-+ bool isTemporary = (strcmp(db2Name, DB2I_TEMP_TABLE_SCHEMA) == 0 ? TRUE : FALSE);
-+
-+ int rc = bridge->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ (isTemporary ? QMY_NONE : getCommitLevel(thd)),
-+ FALSE,
-+ FALSE,
-+ isTemporary);
-+
-+ if (rc == HA_ERR_NO_SUCH_TABLE)
-+ {
-+ warning(thd, DB2I_ERR_TABLE_NOT_FOUND, name);
-+ rc = 0;
-+ }
-+
-+ if (rc == 0)
-+ {
-+ db2i_table::deleteAssocFiles(name);
-+ }
-+
-+ FILE_HANDLE savedHandle = bridge->findAndRemovePreservedHandle(name, &share);
-+ while (savedHandle)
-+ {
-+ bridge->deallocateFile(savedHandle, TRUE);
-+ DBUG_ASSERT(share);
-+ if (free_share(share))
-+ share = NULL;
-+ savedHandle = bridge->findAndRemovePreservedHandle(name, &share);
-+ }
-+
-+ my_errno = rc;
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::rename_table(const char * from, const char * to)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::rename_table ");
-+
-+ char db2FromFileName[MAX_DB2_FILENAME_LENGTH + 1];
-+ char db2ToFileName[MAX_DB2_FILENAME_LENGTH+1];
-+ char db2FromLibName[MAX_DB2_SCHEMANAME_LENGTH+1];
-+ char db2ToLibName[MAX_DB2_SCHEMANAME_LENGTH+1];
-+
-+ db2i_table::getDB2LibNameFromPath(from, db2FromLibName);
-+ db2i_table::getDB2LibNameFromPath(to, db2ToLibName);
-+
-+ if (strcmp(db2FromLibName, db2ToLibName) != 0 )
-+ {
-+ getErrTxt(DB2I_ERR_RENAME_MOVE,from,to);
-+ DBUG_RETURN(DB2I_ERR_RENAME_MOVE);
-+ }
-+
-+ db2i_table::getDB2FileNameFromPath(from, db2FromFileName, db2i_table::ASCII_NATIVE);
-+ db2i_table::getDB2FileNameFromPath(to, db2ToFileName);
-+
-+ char escapedFromFileName[2 * MAX_DB2_FILENAME_LENGTH + 1];
-+
-+ uint o = 0;
-+ uint i = 1;
-+ do
-+ {
-+ escapedFromFileName[o++] = db2FromFileName[i];
-+ if (db2FromFileName[i] == '+')
-+ escapedFromFileName[o++] = '+';
-+ } while (db2FromFileName[++i]);
-+ escapedFromFileName[o-1] = 0;
-+
-+
-+ int rc = 0;
-+
-+ char queryBuffer[sizeof(db2FromLibName) + 2 * sizeof(db2FromFileName) + 256];
-+ SafeString selectQuery(queryBuffer, sizeof(queryBuffer));
-+ selectQuery.strncat(STRING_WITH_LEN("SELECT CAST(INDEX_NAME AS VARCHAR(128) CCSID 1208) FROM QSYS2.SYSINDEXES WHERE INDEX_NAME LIKE '%+_+_+_%"));
-+ selectQuery.strcat(escapedFromFileName);
-+ selectQuery.strncat(STRING_WITH_LEN("' ESCAPE '+' AND TABLE_NAME='"));
-+ selectQuery.strncat(db2FromFileName+1, strlen(db2FromFileName)-2);
-+ selectQuery.strncat(STRING_WITH_LEN("' AND TABLE_SCHEMA='"));
-+ selectQuery.strncat(db2FromLibName+1, strlen(db2FromLibName)-2);
-+ selectQuery.strcat('\'');
-+ DBUG_ASSERT(!selectQuery.overflowed());
-+
-+ SqlStatementStream indexQuery(selectQuery.ptr());
-+
-+ FILE_HANDLE queryFile = 0;
-+ uint32 resultRowLen;
-+
-+ initBridge();
-+ rc = bridge()->prepOpen(indexQuery.getPtrToData(),
-+ &queryFile,
-+ &resultRowLen);
-+
-+ if (unlikely(rc))
-+ DBUG_RETURN(rc);
-+
-+ IOReadBuffer rowBuffer(1, resultRowLen);
-+
-+ int tableNameLen = strlen(db2FromFileName) - 2;
-+
-+ SqlStatementStream renameQuery(64);
-+ String query;
-+ while (rc == 0)
-+ {
-+ query.length(0);
-+
-+ rc = bridge()->read(queryFile,
-+ rowBuffer.ptr(),
-+ QMY_READ_ONLY,
-+ QMY_NONE,
-+ QMY_NEXT);
-+
-+ if (!rc)
-+ {
-+ const char* rowData = rowBuffer.getRowN(0);
-+ char indexFileName[MAX_DB2_FILENAME_LENGTH];
-+ memset(indexFileName, 0, sizeof(indexFileName));
-+
-+ uint16 fileNameLen = *(uint16*)(rowData);
-+ strncpy(indexFileName, rowData + sizeof(uint16), fileNameLen);
-+
-+ int bytesToRetain = fileNameLen - tableNameLen;
-+ if (bytesToRetain <= 0)
-+ /* We can't handle index names in which the MySQL index name and
-+ the table name together are longer than the max index name. */
-+ {
-+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
-+ DBUG_RETURN(DB2I_ERR_INVALID_NAME);
-+ }
-+ char indexName[MAX_DB2_FILENAME_LENGTH];
-+ memset(indexName, 0, sizeof(indexName));
-+
-+ strncpy(indexName,
-+ indexFileName,
-+ bytesToRetain);
-+
-+ char db2IndexName[MAX_DB2_FILENAME_LENGTH+1];
-+
-+ convertMySQLNameToDB2Name(indexFileName, db2IndexName, sizeof(db2IndexName));
-+
-+ query.append(STRING_WITH_LEN("RENAME INDEX "));
-+ query.append(db2FromLibName);
-+ query.append('.');
-+ query.append(db2IndexName);
-+ query.append(STRING_WITH_LEN(" TO "));
-+ if (db2i_table::appendQualifiedIndexFileName(indexName, db2ToFileName, query, db2i_table::ASCII_SQL, typeNone) == -1)
-+ {
-+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
-+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
-+ }
-+ renameQuery.addStatement(query);
-+ DBUG_PRINT("ha_ibmdb2i::rename_table", ("Sent to DB2: %s",query.c_ptr_safe()));
-+ }
-+ }
-+
-+
-+ if (queryFile)
-+ bridge()->deallocateFile(queryFile);
-+
-+ if (rc != HA_ERR_END_OF_FILE)
-+ DBUG_RETURN(rc);
-+
-+ char db2Name[MAX_DB2_QUALIFIEDNAME_LENGTH];
-+
-+ /* Rename the table */
-+ query.length(0);
-+ query.append(STRING_WITH_LEN(" RENAME TABLE "));
-+ db2i_table::getDB2QualifiedNameFromPath(from, db2Name);
-+ query.append(db2Name);
-+ query.append(STRING_WITH_LEN(" TO "));
-+ query.append(db2ToFileName);
-+ DBUG_PRINT("ha_ibmdb2i::rename_table", ("Sent to DB2: %s",query.c_ptr_safe()));
-+ renameQuery.addStatement(query);
-+ rc = bridge()->execSQL(renameQuery.getPtrToData(),
-+ renameQuery.getStatementCount(),
-+ getCommitLevel());
-+
-+ if (!rc)
-+ db2i_table::renameAssocFiles(from, to);
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::create(const char *name, TABLE *table_arg,
-+ HA_CREATE_INFO *create_info)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::create");
-+
-+ int rc;
-+ char fileSortSequence[11] = "*HEX";
-+ char fileSortSequenceLibrary[11] = "";
-+ char fileSortSequenceType = ' ';
-+ char libName[MAX_DB2_SCHEMANAME_LENGTH+1];
-+ char fileName[MAX_DB2_FILENAME_LENGTH+1];
-+ char colName[MAX_DB2_COLNAME_LENGTH+1];
-+ bool isTemporary;
-+ ulong auto_inc_value;
-+
-+ db2i_table::getDB2LibNameFromPath(name, libName);
-+ db2i_table::getDB2FileNameFromPath(name, fileName);
-+
-+ if (osVersion.v < 6)
-+ {
-+ if (strlen(libName) >
-+ MAX_DB2_V5R4_LIBNAME_LENGTH + (isOrdinaryIdentifier(libName) ? 2 : 0))
-+ {
-+ getErrTxt(DB2I_ERR_TOO_LONG_SCHEMA,libName, MAX_DB2_V5R4_LIBNAME_LENGTH);
-+ DBUG_RETURN(DB2I_ERR_TOO_LONG_SCHEMA);
-+ }
-+ }
-+ else if (strlen(libName) > MAX_DB2_V6R1_LIBNAME_LENGTH)
-+ {
-+ getErrTxt(DB2I_ERR_TOO_LONG_SCHEMA,libName, MAX_DB2_V6R1_LIBNAME_LENGTH);
-+ DBUG_RETURN(DB2I_ERR_TOO_LONG_SCHEMA);
-+ }
-+
-+ String query(256);
-+
-+ if (strcmp(libName, DB2I_TEMP_TABLE_SCHEMA))
-+ {
-+ query.append(STRING_WITH_LEN("CREATE TABLE "));
-+ query.append(libName);
-+ query.append('.');
-+ query.append(fileName);
-+ isTemporary = FALSE;
-+ }
-+ else
-+ {
-+ query.append(STRING_WITH_LEN("DECLARE GLOBAL TEMPORARY TABLE "));
-+ query.append(fileName);
-+ isTemporary = TRUE;
-+ }
-+ query.append(STRING_WITH_LEN(" ("));
-+
-+ THD* thd = ha_thd();
-+ enum_TimeFormat timeFormat = (enum_TimeFormat)(THDVAR(thd, compat_opt_time_as_duration));
-+ enum_YearFormat yearFormat = (enum_YearFormat)(THDVAR(thd, compat_opt_year_as_int));
-+ enum_BlobMapping blobMapping = (enum_BlobMapping)(THDVAR(thd, compat_opt_blob_cols));
-+ enum_ZeroDate zeroDate = (enum_ZeroDate)(THDVAR(thd, compat_opt_allow_zero_date_vals));
-+ bool propagateDefaults = THDVAR(thd, propagate_default_col_vals);
-+
-+ Field **field;
-+ for (field= table_arg->field; *field; field++)
-+ {
-+ if ( field != table_arg->field ) // Not the first one
-+ query.append(STRING_WITH_LEN(" , "));
-+
-+ if (!convertMySQLNameToDB2Name((*field)->field_name, colName, sizeof(colName)))
-+ {
-+ getErrTxt(DB2I_ERR_INVALID_NAME,"field",(*field)->field_name);
-+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
-+ }
-+
-+ query.append(colName);
-+ query.append(' ');
-+
-+ if (rc = getFieldTypeMapping(*field,
-+ query,
-+ timeFormat,
-+ blobMapping,
-+ zeroDate,
-+ propagateDefaults,
-+ yearFormat))
-+ DBUG_RETURN(rc);
-+
-+ if ( (*field)->flags & NOT_NULL_FLAG )
-+ {
-+ query.append(STRING_WITH_LEN(" NOT NULL "));
-+ }
-+ if ( (*field)->flags & AUTO_INCREMENT_FLAG )
-+ {
-+#ifdef WITH_PARTITION_STORAGE_ENGINE
-+ if (table_arg->part_info)
-+ {
-+ getErrTxt(DB2I_ERR_PART_AUTOINC);
-+ DBUG_RETURN(DB2I_ERR_PART_AUTOINC);
-+ }
-+#endif
-+ query.append(STRING_WITH_LEN(" GENERATED BY DEFAULT AS IDENTITY ") );
-+ if (create_info->auto_increment_value != 0)
-+ {
-+ /* Query was ALTER TABLE...AUTO_INCREMENT = x; or
-+ CREATE TABLE ...AUTO_INCREMENT = x; Set the starting
-+ value for the auto_increment column. */
-+ char stringValue[22];
-+ CHARSET_INFO *cs= &my_charset_bin;
-+ uint len = (uint)(cs->cset->longlong10_to_str)(cs,stringValue,sizeof(stringValue), 10, create_info->auto_increment_value);
-+ stringValue[len] = 0;
-+ query.append(STRING_WITH_LEN(" (START WITH "));
-+ query.append(stringValue);
-+
-+ uint64 maxValue=maxValueForField(*field);
-+
-+ if (maxValue)
-+ {
-+ len = (uint)(cs->cset->longlong10_to_str)(cs,stringValue,sizeof(stringValue), 10, maxValue);
-+ stringValue[len] = 0;
-+ query.append(STRING_WITH_LEN(" MAXVALUE "));
-+ query.append(stringValue);
-+ }
-+
-+ query.append(STRING_WITH_LEN(") "));
-+ }
-+
-+ }
-+ }
-+
-+ String fieldDefinition(128);
-+
-+ if (table_arg->s->primary_key != MAX_KEY && !isTemporary)
-+ {
-+ query.append(STRING_WITH_LEN(", PRIMARY KEY "));
-+ rc = buildIndexFieldList(fieldDefinition,
-+ table_arg->key_info[table_arg->s->primary_key],
-+ true,
-+ &fileSortSequenceType,
-+ fileSortSequence,
-+ fileSortSequenceLibrary);
-+ if (rc) DBUG_RETURN(rc);
-+ query.append(fieldDefinition);
-+ }
-+
-+ rc = buildDB2ConstraintString(thd->lex,
-+ query,
-+ name,
-+ table_arg->field,
-+ &fileSortSequenceType,
-+ fileSortSequence,
-+ fileSortSequenceLibrary);
-+ if (rc) DBUG_RETURN (rc);
-+
-+ query.append(STRING_WITH_LEN(" ) "));
-+
-+ if (isTemporary)
-+ query.append(STRING_WITH_LEN(" ON COMMIT PRESERVE ROWS "));
-+
-+ if (create_info->alias)
-+ generateAndAppendRCDFMT(create_info->alias, query);
-+ else if (((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name)
-+ generateAndAppendRCDFMT((char*)((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name, query);
-+
-+ DBUG_PRINT("ha_ibmdb2i::create", ("Sent to DB2: %s",query.c_ptr()));
-+ SqlStatementStream sqlStream(query.length());
-+ sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary);
-+
-+ if (table_arg->s->primary_key != MAX_KEY &&
-+ !isTemporary &&
-+ (THDVAR(thd, create_index_option)==1) &&
-+ (fileSortSequenceType != 'B') &&
-+ (fileSortSequenceType != ' '))
-+ {
-+ rc = generateShadowIndex(sqlStream,
-+ table_arg->key_info[table_arg->s->primary_key],
-+ libName,
-+ fileName,
-+ fieldDefinition);
-+ if (rc) DBUG_RETURN(rc);
-+ }
-+ for (uint i = 0; i < table_arg->s->keys; ++i)
-+ {
-+ if (i != table_arg->s->primary_key || isTemporary)
-+ {
-+ rc = buildCreateIndexStatement(sqlStream,
-+ table_arg->key_info[i],
-+ false,
-+ libName,
-+ fileName);
-+ if (rc) DBUG_RETURN (rc);
-+ }
-+ }
-+
-+ bool noCommit = isTemporary || ((!autoCommitIsOn(thd)) && (thd_sql_command(thd) == SQLCOM_ALTER_TABLE));
-+
-+ initBridge();
-+
-+// if (THDVAR(thd, discovery_mode) == 1)
-+// bridge()->expectErrors(QMY_ERR_TABLE_EXISTS);
-+
-+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ (isTemporary ? QMY_NONE : getCommitLevel(thd)),
-+ TRUE,
-+ FALSE,
-+ noCommit );
-+
-+ if (unlikely(rc == QMY_ERR_MSGID) &&
-+ memcmp(bridge()->getErrorMsgID(), DB2I_SQL0350, 7) == 0)
-+ {
-+ my_error(ER_BLOB_USED_AS_KEY, MYF(0), "*unknown*");
-+ rc = ER_BLOB_USED_AS_KEY;
-+ }
-+/* else if (unlikely(rc == QMY_ERR_TABLE_EXISTS) &&
-+ THDVAR(thd, discovery_mode) == 1)
-+ {
-+ db2i_table* temp = new db2i_table(table_arg->s, name);
-+ int32 rc = temp->fastInitForCreate(name);
-+ delete temp;
-+
-+ if (!rc)
-+ warning(thd, DB2I_ERR_WARN_CREATE_DISCOVER);
-+
-+ DBUG_RETURN(rc);
-+ }
-+*/
-+
-+ if (!rc && !isTemporary)
-+ {
-+ db2i_table* temp = new db2i_table(table_arg->s, name);
-+ rc = temp->fastInitForCreate(name);
-+ delete temp;
-+ if (rc)
-+ delete_table(name);
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+/**
-+ @brief
-+ Add an index on-line to a table. This method is called on behalf of
-+ a CREATE INDEX or ALTER TABLE statement.
-+ It is implemented via a composed DDL statement passed to DB2.
-+*/
-+int ha_ibmdb2i::add_index(TABLE *table_arg,
-+ KEY *key_info,
-+ uint num_of_keys)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::add_index");
-+
-+ int rc;
-+ SqlStatementStream sqlStream(256);
-+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
-+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
-+
-+ quiesceAllFileHandles();
-+
-+ uint primaryKey = MAX_KEY;
-+ if (table_arg->s->primary_key >= MAX_KEY && !db2Table->isTemporary())
-+ {
-+ for (int i = 0; i < num_of_keys; ++i)
-+ {
-+ if (strcmp(key_info[i].name, "PRIMARY") == 0)
-+ {
-+ primaryKey = i;
-+ break;
-+ }
-+ else if (primaryKey == MAX_KEY &&
-+ key_info[i].flags & HA_NOSAME)
-+ {
-+ primaryKey = i;
-+ for (int j=0 ; j < key_info[i].key_parts ;j++)
-+ {
-+ uint fieldnr= key_info[i].key_part[j].fieldnr;
-+ if (table_arg->s->field[fieldnr]->null_ptr ||
-+ table_arg->s->field[fieldnr]->key_length() !=
-+ key_info[i].key_part[j].length)
-+ {
-+ primaryKey = MAX_KEY;
-+ break;
-+ }
-+ }
-+ }
-+ }
-+ }
-+
-+
-+ for (int i = 0; i < num_of_keys; ++i)
-+ {
-+ KEY& curKey= key_info[i];
-+ rc = buildCreateIndexStatement(sqlStream,
-+ curKey,
-+ (i == primaryKey),
-+ libName,
-+ fileName);
-+ if (rc) DBUG_RETURN (rc);
-+ }
-+
-+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ getCommitLevel(),
-+ FALSE,
-+ FALSE,
-+ FALSE,
-+ dataHandle);
-+
-+ /* Handle the case where a unique index is being created but an error occurs
-+ because the file contains duplicate key values. */
-+ if (rc == ER_DUP_ENTRY)
-+ print_keydup_error(MAX_KEY,ER(ER_DUP_ENTRY_WITH_KEY_NAME));
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+/**
-+ @brief
-+ Drop an index on-line from a table. This method is called on behalf of
-+ a DROP INDEX or ALTER TABLE statement.
-+ It is implemented via a composed DDL statement passed to DB2.
-+*/
-+int ha_ibmdb2i::prepare_drop_index(TABLE *table_arg,
-+ uint *key_num, uint num_of_keys)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::prepare_drop_index");
-+ int rc;
-+ int i = 0;
-+ String query(64);
-+ SqlStatementStream sqlStream(64 * num_of_keys);
-+ SqlStatementStream shadowStream(64 * num_of_keys);
-+
-+ quiesceAllFileHandles();
-+
-+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
-+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
-+
-+ while (i < num_of_keys)
-+ {
-+ query.length(0);
-+ DBUG_PRINT("info", ("ha_ibmdb2i::prepare_drop_index %u", key_num[i]));
-+ KEY& curKey= table_arg->key_info[key_num[i]];
-+ if (key_num[i] == table->s->primary_key && !db2Table->isTemporary())
-+ {
-+ query.append(STRING_WITH_LEN("ALTER TABLE "));
-+ query.append(libName);
-+ query.append(STRING_WITH_LEN("."));
-+ query.append(fileName);
-+ query.append(STRING_WITH_LEN(" DROP PRIMARY KEY"));
-+ }
-+ else
-+ {
-+ query.append(STRING_WITH_LEN("DROP INDEX "));
-+ query.append(libName);
-+ query.append(STRING_WITH_LEN("."));
-+ db2i_table::appendQualifiedIndexFileName(curKey.name, fileName, query);
-+ }
-+ DBUG_PRINT("ha_ibmdb2i::prepare_drop_index", ("Sent to DB2: %s",query.c_ptr_safe()));
-+ sqlStream.addStatement(query);
-+
-+ query.length(0);
-+ query.append(STRING_WITH_LEN("DROP INDEX "));
-+ query.append(libName);
-+ query.append(STRING_WITH_LEN("."));
-+ db2i_table::appendQualifiedIndexFileName(curKey.name, fileName, query, db2i_table::ASCII_SQL, typeHex);
-+
-+ DBUG_PRINT("ha_ibmdb2i::prepare_drop_index", ("Sent to DB2: %s",query.c_ptr_safe()));
-+ shadowStream.addStatement(query);
-+
-+ ++i;
-+ }
-+
-+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
-+ sqlStream.getStatementCount(),
-+ getCommitLevel(),
-+ FALSE,
-+ FALSE,
-+ FALSE,
-+ dataHandle);
-+
-+ if (rc == 0)
-+ bridge()->execSQL(shadowStream.getPtrToData(),
-+ shadowStream.getStatementCount(),
-+ getCommitLevel());
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+void
-+ha_ibmdb2i::unlock_row()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::unlock_row");
-+ DBUG_VOID_RETURN;
-+}
-+
-+int
-+ha_ibmdb2i::index_end()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::index_end");
-+ warnIfInvalidData();
-+ last_index_init_rc = 0;
-+ if (likely(activeReadBuf))
-+ activeReadBuf->endRead();
-+ if (likely(!last_index_init_rc))
-+ releaseIndexFile(active_index);
-+ active_index= MAX_KEY;
-+ DBUG_RETURN (0);
-+}
-+
-+int ha_ibmdb2i::doCommit(handlerton *hton, THD *thd, bool all)
-+{
-+ if (!THDVAR(thd, transaction_unsafe))
-+ {
-+ if (all || autoCommitIsOn(thd))
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::doCommit",("Committing all"));
-+ return (db2i_ileBridge::getBridgeForThread(thd)->commitmentControl(QMY_COMMIT));
-+ }
-+ else
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::doCommit",("Committing stmt"));
-+ return (db2i_ileBridge::getBridgeForThread(thd)->commitStmtTx());
-+ }
-+ }
-+
-+ return (0);
-+}
-+
-+
-+int ha_ibmdb2i::doRollback(handlerton *hton, THD *thd, bool all)
-+{
-+ if (!THDVAR(thd,transaction_unsafe))
-+ {
-+ if (all || autoCommitIsOn(thd))
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::doRollback",("Rolling back all"));
-+ return ( db2i_ileBridge::getBridgeForThread(thd)->commitmentControl(QMY_ROLLBACK));
-+ }
-+ else
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::doRollback",("Rolling back stmt"));
-+ return (db2i_ileBridge::getBridgeForThread(thd)->rollbackStmtTx());
-+ }
-+ }
-+ return (0);
-+}
-+
-+
-+void ha_ibmdb2i::start_bulk_insert(ha_rows rows)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::start_bulk_insert");
-+ DBUG_PRINT("ha_ibmdb2i::start_bulk_insert",("Rows hinted %d", rows));
-+ int rc;
-+ THD* thd = ha_thd();
-+ int command = thd_sql_command(thd);
-+
-+ if (db2Table->hasBlobs() ||
-+ (command == SQLCOM_REPLACE || command == SQLCOM_REPLACE_SELECT))
-+ rows = 1;
-+ else if (rows == 0)
-+ rows = DEFAULT_MAX_ROWS_TO_BUFFER; // Shoot the moon
-+
-+ // If we're doing a multi-row insert, binlogging is active, and the table has an
-+ // auto_increment column, then we'll attempt to lock the file while we perform a 'fast path' blocked
-+ // insert. If we can't get the lock, then we'll do a row-by-row 'slow path' insert instead. The reason is
-+ // because the MI generates the auto_increment (identity value), and if we can't lock the file,
-+ // then we can't predetermine what that value will be for insertion into the MySQL write buffer.
-+
-+ if ((rows > 1) && // Multi-row insert
-+ (thd->options & OPTION_BIN_LOG) && // Binlogging is on
-+ (table->found_next_number_field)) // Table has an auto_increment column
-+ {
-+ if (!dataHandle)
-+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
-+
-+ rc = bridge()->lockObj(dataHandle, 1, QMY_LOCK, QMY_LEAR, QMY_YES);
-+ if (rc==0) // Got the lock
-+ {
-+ autoIncLockAcquired = TRUE;
-+ got_auto_inc_values = FALSE;
-+ }
-+ else // Didn't get the lock
-+ rows = 1; // No problem, but don't block inserts
-+ }
-+
-+ if (activeHandle == 0)
-+ {
-+ last_start_bulk_insert_rc = useDataFile();
-+ if (last_start_bulk_insert_rc == 0)
-+ last_start_bulk_insert_rc = prepWriteBuffer(rows, db2Table->dataFile());
-+ }
-+
-+ if (last_start_bulk_insert_rc == 0)
-+ outstanding_start_bulk_insert = true;
-+ else
-+ {
-+ if (autoIncLockAcquired == TRUE)
-+ {
-+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LEAR, QMY_YES);
-+ autoIncLockAcquired = FALSE;
-+ }
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+
-+int ha_ibmdb2i::end_bulk_insert()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::end_bulk_insert");
-+ int rc = 0;
-+
-+ if (outstanding_start_bulk_insert)
-+ {
-+ rc = finishBulkInsert();
-+ }
-+
-+ my_errno = rc;
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::prepReadBuffer(ha_rows rowsToRead, const db2i_file* file, char intent)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::prepReadBuffer");
-+ DBUG_ASSERT(rowsToRead > 0);
-+
-+ THD* thd = ha_thd();
-+ char cmtLvl = getCommitLevel(thd);
-+
-+ const db2i_file::RowFormat* format;
-+ int rc = file->obtainRowFormat(activeHandle, intent, cmtLvl, &format);
-+
-+ if (unlikely(rc)) DBUG_RETURN(rc);
-+
-+ if (lobFieldsRequested())
-+ {
-+ forceSingleRowRead = true;
-+ rowsToRead = 1;
-+ }
-+
-+ rowsToRead = min(stats.records+1,MYSQL_MIN(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+
-+ uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
-+ activeReadBuf = &multiRowReadBuf;
-+
-+ if (db2Table->hasBlobs())
-+ {
-+ if (!blobReadBuffers)
-+ blobReadBuffers = new BlobCollection(db2Table, THDVAR(thd, lob_alloc_size));
-+ rc = prepareReadBufferForLobs();
-+ if (rc) DBUG_RETURN(rc);
-+ }
-+
-+// if (accessIntent == QMY_UPDATABLE &&
-+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
-+// !THDVAR(thd, transaction_unsafe))
-+// activeReadBuf->update(QMY_READ_ONLY, &releaseRowNeeded, QMY_REPEATABLE_READ);
-+// else
-+ activeReadBuf->update(intent, &releaseRowNeeded, cmtLvl);
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::prepWriteBuffer(ha_rows rowsToWrite, const db2i_file* file)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::prepWriteBuffer");
-+ DBUG_ASSERT(accessIntent == QMY_UPDATABLE && rowsToWrite > 0);
-+
-+ const db2i_file::RowFormat* format;
-+ int rc = file->obtainRowFormat(activeHandle,
-+ QMY_UPDATABLE,
-+ getCommitLevel(ha_thd()),
-+ &format);
-+
-+ if (unlikely(rc)) DBUG_RETURN(rc);
-+
-+ rowsToWrite = min(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-+
-+ uint bufSize = min((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
-+ multiRowWriteBuf.allocBuf(format->writeRowLen, format->writeRowNullOffset, bufSize);
-+ activeWriteBuf = &multiRowWriteBuf;
-+
-+ if (!blobWriteBuffers && db2Table->hasBlobs())
-+ {
-+ blobWriteBuffers = new ValidatedPointer<char>[db2Table->getBlobCount()];
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int ha_ibmdb2i::flushWrite(FILE_HANDLE fileHandle, uchar* buf )
-+{
-+ DBUG_ENTER("ha_ibmdb2i::flushWrite");
-+ int rc;
-+ int64 generatedIdValue = 0;
-+ bool IdValueWasGenerated = FALSE;
-+ char* lastDupKeyNamePtr = NULL;
-+ uint32 lastDupKeyNameLen = 0;
-+ int loopCnt = 0;
-+ bool retry_dup = FALSE;
-+
-+ while (loopCnt == 0 || retry_dup == TRUE)
-+ {
-+ rc = bridge()->writeRows(fileHandle,
-+ activeWriteBuf->ptr(),
-+ getCommitLevel(),
-+ &generatedIdValue,
-+ &IdValueWasGenerated,
-+ &lastDupKeyRRN,
-+ &lastDupKeyNamePtr,
-+ &lastDupKeyNameLen,
-+ &incrementByValue);
-+ loopCnt++;
-+ retry_dup = FALSE;
-+ invalidateCachedStats();
-+ if (lastDupKeyNameLen)
-+ {
-+ rrnAssocHandle = fileHandle;
-+
-+ int command = thd_sql_command(ha_thd());
-+
-+ if (command == SQLCOM_REPLACE ||
-+ command == SQLCOM_REPLACE_SELECT)
-+ lastDupKeyID = 0;
-+ else
-+ {
-+ lastDupKeyID = getKeyFromName(lastDupKeyNamePtr, lastDupKeyNameLen);
-+
-+ if (likely(lastDupKeyID != MAX_KEY))
-+ {
-+ uint16 failedRow = activeWriteBuf->rowsWritten()+1;
-+
-+ if (buf && (failedRow != activeWriteBuf->rowCount()))
-+ {
-+ const char* badRow = activeWriteBuf->getRowN(failedRow-1);
-+ bool savedReadAllColumns = readAllColumns;
-+ readAllColumns = true;
-+ mungeDB2row(buf,
-+ badRow,
-+ badRow + activeWriteBuf->getRowNullOffset(),
-+ true);
-+ readAllColumns = savedReadAllColumns;
-+
-+ if (table->found_next_number_field)
-+ {
-+ table->next_number_field->store(next_identity_value - (incrementByValue * (activeWriteBuf->rowCount() - (failedRow - 1))));
-+ }
-+ }
-+
-+ if (default_identity_value && // Table has ID colm and generating a value
-+ (!autoIncLockAcquired || !got_auto_inc_values) &&
-+ // Writing first or only row in block
-+ loopCnt == 1 && // Didn't already retry
-+ lastDupKeyID == table->s->next_number_index) // Autoinc column is in failed index
-+ {
-+ if (alterStartWith() == 0) // Reset next Identity value to max+1
-+ retry_dup = TRUE; // Rtry the write operation
-+ }
-+ }
-+ else
-+ {
-+ char unknownIndex[MAX_DB2_FILENAME_LENGTH+1];
-+ convFromEbcdic(lastDupKeyNamePtr, unknownIndex, min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-+ unknownIndex[min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
-+ getErrTxt(DB2I_ERR_UNKNOWN_IDX, unknownIndex);
-+ }
-+ }
-+ }
-+ }
-+
-+ if ((rc == 0 || rc == HA_ERR_FOUND_DUPP_KEY)
-+ && default_identity_value && IdValueWasGenerated &&
-+ (!autoIncLockAcquired || !got_auto_inc_values))
-+ {
-+ /* Save the generated identity value for the MySQL last_insert_id() function. */
-+ insert_id_for_cur_row = generatedIdValue;
-+
-+ /* Store the value into MySQL's buf for row-based replication
-+ or for an 'on duplicate key update' clause. */
-+ table->next_number_field->store((longlong) generatedIdValue, TRUE);
-+ if (autoIncLockAcquired)
-+ {
-+ got_auto_inc_values = TRUE;
-+ next_identity_value = generatedIdValue + incrementByValue;
-+ }
-+ }
-+ else
-+ {
-+ if (!autoIncLockAcquired) // Don't overlay value for first row of a block
-+ insert_id_for_cur_row = 0;
-+ }
-+
-+
-+ activeWriteBuf->resetAfterWrite();
-+ DBUG_RETURN(rc);
-+}
-+
-+int ha_ibmdb2i::alterStartWith()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::alterStartWith");
-+ int rc = 0;
-+ ulonglong nextIdVal;
-+ if (!dataHandle)
-+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
-+ if (!rc) {rc = bridge()->lockObj(dataHandle, 1, QMY_LOCK, QMY_LENR, QMY_YES);}
-+ if (!rc)
-+ {
-+ rc = getNextIdVal(&nextIdVal);
-+ if (!rc) {rc = reset_auto_increment(nextIdVal);}
-+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LENR, QMY_YES);
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+bool ha_ibmdb2i::lobFieldsRequested()
-+{
-+ if (!db2Table->hasBlobs())
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("No LOBs"));
-+ return (false);
-+ }
-+
-+ if (readAllColumns)
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("All cols requested"));
-+ return (true);
-+ }
-+
-+ for (int i = 0; i < db2Table->getBlobCount(); ++i)
-+ {
-+ if (bitmap_is_set(table->read_set, db2Table->blobFields[i]))
-+ {
-+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("LOB requested"));
-+ return (true);
-+ }
-+ }
-+
-+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("No LOBs requested"));
-+ return (false);
-+}
-+
-+
-+int ha_ibmdb2i::prepareReadBufferForLobs()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::prepareReadBufferForLobs");
-+ DBUG_ASSERT(db2Table->hasBlobs());
-+
-+ uint32 activeLobFields = 0;
-+ DB2LobField* lobField;
-+ uint16 blobCount = db2Table->getBlobCount();
-+
-+ char* readBuf = activeReadBuf->getRowN(0);
-+
-+ for (int i = 0; i < blobCount; ++i)
-+ {
-+ int fieldID = db2Table->blobFields[i];
-+ DB2Field& db2Field = db2Table->db2Field(fieldID);
-+ lobField = db2Field.asBlobField(readBuf);
-+ if (readAllColumns ||
-+ bitmap_is_set(table->read_set, fieldID))
-+ {
-+ lobField->dataHandle = (ILEMemHandle)blobReadBuffers->getBufferPtr(fieldID);
-+ activeLobFields++;
-+ }
-+ else
-+ {
-+ lobField->dataHandle = NULL;
-+ }
-+ }
-+
-+ if (activeLobFields == 0)
-+ {
-+ for (int i = 0; i < blobCount; ++i)
-+ {
-+ DB2Field& db2Field = db2Table->db2Field(db2Table->blobFields[i]);
-+ uint16 offset = db2Field.getBufferOffset() + db2Field.calcBlobPad();
-+
-+ for (int r = 1; r < activeReadBuf->getRowCapacity(); ++r)
-+ {
-+ lobField = (DB2LobField*)(activeReadBuf->getRowN(r) + offset);
-+ lobField->dataHandle = NULL;
-+ }
-+ }
-+ }
-+
-+ activeReadBuf->setRowsToProcess((activeLobFields ? 1 : activeReadBuf->getRowCapacity()));
-+ int rc = bridge()->objectOverride(activeHandle,
-+ activeReadBuf->ptr(),
-+ activeReadBuf->getRowLength());
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+uint32 ha_ibmdb2i::adjustLobBuffersForRead()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::adjustLobBuffersForRead");
-+
-+ char* readBuf = activeReadBuf->getRowN(0);
-+
-+ for (int i = 0; i < db2Table->getBlobCount(); ++i)
-+ {
-+ DB2Field& db2Field = db2Table->db2Field(db2Table->blobFields[i]);
-+ DB2LobField* lobField = db2Field.asBlobField(readBuf);
-+ if (readAllColumns ||
-+ bitmap_is_set(table->read_set, db2Table->blobFields[i]))
-+ {
-+ lobField->dataHandle = (ILEMemHandle)blobReadBuffers->reallocBuffer(db2Table->blobFields[i], lobField->length);
-+
-+ if (lobField->dataHandle == NULL)
-+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
-+ }
-+ else
-+ {
-+ lobField->dataHandle = 0;
-+ }
-+ }
-+
-+ int32 rc = bridge()->objectOverride(activeHandle,
-+ activeReadBuf->ptr());
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+
-+int ha_ibmdb2i::reset()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::reset");
-+
-+ if (outstanding_start_bulk_insert)
-+ {
-+ finishBulkInsert();
-+ }
-+
-+ if (activeHandle != 0)
-+ {
-+ releaseActiveHandle();
-+ }
-+
-+ cleanupBuffers();
-+
-+ db2i_ileBridge::getBridgeForThread(ha_thd())->freeErrorStorage();
-+
-+ last_rnd_init_rc = last_index_init_rc = last_start_bulk_insert_rc = 0;
-+
-+ returnDupKeysImmediately = false;
-+ onDupUpdate = false;
-+ forceSingleRowRead = false;
-+
-+#ifndef DBUG_OFF
-+ cachedBridge=NULL;
-+#endif
-+
-+ DBUG_RETURN(0);
-+}
-+
-+
-+int32 ha_ibmdb2i::buildCreateIndexStatement(SqlStatementStream& sqlStream,
-+ KEY& key,
-+ bool isPrimary,
-+ const char* db2LibName,
-+ const char* db2FileName)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::buildCreateIndexStatement");
-+
-+ char fileSortSequence[11] = "*HEX";
-+ char fileSortSequenceLibrary[11] = "";
-+ char fileSortSequenceType = ' ';
-+ String query(256);
-+ query.length(0);
-+ int rc = 0;
-+
-+ if (isPrimary)
-+ {
-+ query.append(STRING_WITH_LEN("ALTER TABLE "));
-+ query.append(db2LibName);
-+ query.append('.');
-+ query.append(db2FileName);
-+ query.append(STRING_WITH_LEN(" ADD PRIMARY KEY "));
-+ }
-+ else
-+ {
-+ query.append(STRING_WITH_LEN("CREATE"));
-+
-+ if (key.flags & HA_NOSAME)
-+ query.append(STRING_WITH_LEN(" UNIQUE WHERE NOT NULL"));
-+
-+ query.append(STRING_WITH_LEN(" INDEX "));
-+
-+ query.append(db2LibName);
-+ query.append('.');
-+ if (db2i_table::appendQualifiedIndexFileName(key.name, db2FileName, query))
-+ {
-+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
-+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
-+ }
-+
-+ query.append(STRING_WITH_LEN(" ON "));
-+
-+ query.append(db2LibName);
-+ query.append('.');
-+ query.append(db2FileName);
-+ }
-+
-+ String fieldDefinition(128);
-+ rc = buildIndexFieldList(fieldDefinition,
-+ key,
-+ isPrimary,
-+ &fileSortSequenceType,
-+ fileSortSequence,
-+ fileSortSequenceLibrary);
-+
-+ if (rc) DBUG_RETURN(rc);
-+
-+ query.append(fieldDefinition);
-+
-+ if ((THDVAR(ha_thd(), create_index_option)==1) &&
-+ (fileSortSequenceType != 'B') &&
-+ (fileSortSequenceType != ' '))
-+ {
-+ rc = generateShadowIndex(sqlStream,
-+ key,
-+ db2LibName,
-+ db2FileName,
-+ fieldDefinition);
-+ if (rc) DBUG_RETURN(rc);
-+ }
-+
-+ DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",query.c_ptr_safe()));
-+ sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary);
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/**
-+ Generate the SQL syntax for the list of fields to be assigned to the
-+ specified key. The corresponding sort sequence is also calculated.
-+
-+ @param[out] appendHere The string to receive the generated SQL
-+ @param key The key to evaluate
-+ @param isPrimary True if this is being generated on behalf of the primary key
-+ @param[out] fileSortSequenceType The type of the associated sort sequence
-+ @param[out] fileSortSequence The name of the associated sort sequence
-+ @param[out] fileSortSequenceLibrary The library of the associated sort sequence
-+
-+ @return 0 if successful; error value otherwise
-+*/
-+int32 ha_ibmdb2i::buildIndexFieldList(String& appendHere,
-+ const KEY& key,
-+ bool isPrimary,
-+ char* fileSortSequenceType,
-+ char* fileSortSequence,
-+ char* fileSortSequenceLibrary)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::buildIndexFieldList");
-+ appendHere.append(STRING_WITH_LEN(" ( "));
-+ for (int j = 0; j < key.key_parts; ++j)
-+ {
-+ char colName[MAX_DB2_COLNAME_LENGTH+1];
-+ if (j != 0)
-+ {
-+ appendHere.append(STRING_WITH_LEN(" , "));
-+ }
-+
-+ KEY_PART_INFO& kpi = key.key_part[j];
-+ Field* field = kpi.field;
-+
-+ convertMySQLNameToDB2Name(field->field_name,
-+ colName,
-+ sizeof(colName));
-+ appendHere.append(colName);
-+
-+ int32 rc;
-+ rc = updateAssociatedSortSequence(field->charset(),
-+ fileSortSequenceType,
-+ fileSortSequence,
-+ fileSortSequenceLibrary);
-+ if (rc) DBUG_RETURN (rc);
-+ }
-+
-+ appendHere.append(STRING_WITH_LEN(" ) "));
-+
-+ DBUG_RETURN(0);
-+}
-+
-+
-+/**
-+ Generate an SQL statement that defines a *HEX sorted index to implement
-+ the ibmdb2i_create_index.
-+
-+ @param[out] stream The stream to append the generated statement to
-+ @param key The key to evaluate
-+ @param[out] libName The library containg the table
-+ @param[out] fileName The DB2-compatible name of the table
-+ @param[out] fieldDefinition The list of the fields in the index, in SQL syntax
-+
-+ @return 0 if successful; error value otherwise
-+*/
-+int32 ha_ibmdb2i::generateShadowIndex(SqlStatementStream& stream,
-+ const KEY& key,
-+ const char* libName,
-+ const char* fileName,
-+ const String& fieldDefinition)
-+{
-+ String shadowQuery(256);
-+ shadowQuery.length(0);
-+ shadowQuery.append(STRING_WITH_LEN("CREATE INDEX "));
-+ shadowQuery.append(libName);
-+ shadowQuery.append('.');
-+ if (db2i_table::appendQualifiedIndexFileName(key.name, fileName, shadowQuery, db2i_table::ASCII_SQL, typeHex))
-+ {
-+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
-+ return DB2I_ERR_INVALID_NAME;
-+ }
-+ shadowQuery.append(STRING_WITH_LEN(" ON "));
-+ shadowQuery.append(libName);
-+ shadowQuery.append('.');
-+ shadowQuery.append(fileName);
-+ shadowQuery.append(fieldDefinition);
-+ DBUG_PRINT("ha_ibmdb2i::generateShadowIndex", ("Sent to DB2: %s",shadowQuery.c_ptr_safe()));
-+ stream.addStatement(shadowQuery,"*HEX","QSYS");
-+ return 0;
-+}
-+
-+
-+void ha_ibmdb2i::doInitialRead(char orientation,
-+ uint32 rowsToBuffer,
-+ ILEMemHandle key,
-+ int keyLength,
-+ int keyParts)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::doInitialRead");
-+
-+ if (forceSingleRowRead)
-+ rowsToBuffer = 1;
-+ else
-+ rowsToBuffer = min(rowsToBuffer, activeReadBuf->getRowCapacity());
-+
-+ activeReadBuf->newReadRequest(activeHandle,
-+ orientation,
-+ rowsToBuffer,
-+ THDVAR(ha_thd(), async_enabled),
-+ key,
-+ keyLength,
-+ keyParts);
-+ DBUG_VOID_RETURN;
-+}
-+
-+
-+int ha_ibmdb2i::start_stmt(THD *thd, thr_lock_type lock_type)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::start_stmt");
-+ initBridge(thd);
-+ if (!THDVAR(thd, transaction_unsafe))
-+ {
-+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
-+
-+ if (!autoCommitIsOn(thd))
-+ {
-+ bridge()->beginStmtTx();
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
-+int32 ha_ibmdb2i::handleLOBReadOverflow()
-+{
-+ DBUG_ENTER("ha_ibmdb2i::handleLOBReadOverflow");
-+ DBUG_ASSERT(db2Table->hasBlobs() && (activeReadBuf->getRowCapacity() == 1));
-+
-+ int32 rc = adjustLobBuffersForRead();
-+
-+ if (!rc)
-+ {
-+ activeReadBuf->rewind();
-+ rc = bridge()->expectErrors(QMY_ERR_END_OF_BLOCK)
-+ ->read(activeHandle,
-+ activeReadBuf->ptr(),
-+ accessIntent,
-+ getCommitLevel(),
-+ QMY_SAME);
-+ releaseRowNeeded = TRUE;
-+
-+ }
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+int32 ha_ibmdb2i::finishBulkInsert()
-+{
-+ int32 rc = 0;
-+
-+ if (activeWriteBuf->rowCount() && activeHandle)
-+ rc = flushWrite(activeHandle, table->record[0]);
-+
-+ if (activeHandle)
-+ releaseActiveHandle();
-+
-+ if (autoIncLockAcquired == TRUE)
-+ {
-+ // We could check the return code on the unlock, but beware not
-+ // to overlay the return code from the flushwrite or we will mask
-+ // duplicate key errors..
-+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LEAR, QMY_YES);
-+ autoIncLockAcquired = FALSE;
-+ }
-+ outstanding_start_bulk_insert = false;
-+ multiRowWriteBuf.freeBuf();
-+ last_start_bulk_insert_rc = 0;
-+
-+ resetCharacterConversionBuffers();
-+
-+ return rc;
-+}
-+
-+int ha_ibmdb2i::getKeyFromName(const char* name, size_t len)
-+{
-+ for (int i = 0; i < table_share->keys; ++i)
-+ {
-+ const char* indexName = db2Table->indexFile(i)->getDB2FileName();
-+ if ((strncmp(name, indexName, len) == 0) &&
-+ (strlen(indexName) == len))
-+ {
-+ return i;
-+ }
-+ }
-+ return MAX_KEY;
-+}
-+
-+/*
-+Determine the number of I/O's it takes to read through the table.
-+ */
-+double ha_ibmdb2i::scan_time()
-+ {
-+ DBUG_ENTER("ha_ibmdb2i::scan_time");
-+ DBUG_RETURN(ulonglong2double((stats.data_file_length)/IO_SIZE));
-+ }
-+
-+
-+/**
-+ Estimate the number of I/O's it takes to read a set of ranges through
-+ an index.
-+
-+ @param index
-+ @param ranges
-+ @param rows
-+
-+ @return The estimate number of I/Os
-+*/
-+
-+double ha_ibmdb2i::read_time(uint index, uint ranges, ha_rows rows)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::read_time");
-+ int rc;
-+ uint64 idxPageCnt = 0;
-+ double cost;
-+
-+ if (unlikely(rows == HA_POS_ERROR))
-+ DBUG_RETURN(double(rows) + ranges);
-+
-+ rc = bridge()->retrieveIndexInfo(db2Table->indexFile(index)->getMasterDefnHandle(),
-+ &idxPageCnt);
-+ if (!rc)
-+ {
-+ if ((idxPageCnt == 1) || // Retrieving rows in requested order or
-+ (ranges == rows)) // 'Sweep' full records retrieval
-+ cost = idxPageCnt/4;
-+ else
-+ {
-+ uint64 totalRecords = stats.records + 1;
-+ double dataPageCount = stats.data_file_length/IO_SIZE;
-+
-+ cost = (rows * dataPageCount / totalRecords) +
-+ min(idxPageCnt, (log_2(idxPageCnt) * ranges +
-+ rows * (log_2(idxPageCnt) + log_2(rows) - log_2(totalRecords))));
-+ }
-+ }
-+ else
-+ {
-+ cost = rows2double(ranges+rows); // Use default costing
-+ }
-+ DBUG_RETURN(cost);
-+}
-+
-+int ha_ibmdb2i::useIndexFile(int idx)
-+{
-+ DBUG_ENTER("ha_ibmdb2i::useIndexFile");
-+
-+ if (activeHandle)
-+ releaseActiveHandle();
-+
-+ int rc = 0;
-+
-+ if (!indexHandles[idx])
-+ rc = db2Table->indexFile(idx)->allocateNewInstance(&indexHandles[idx], curConnection);
-+
-+ if (rc == 0)
-+ {
-+ activeHandle = indexHandles[idx];
-+ bumpInUseCounter(1);
-+ }
-+
-+ DBUG_RETURN(rc);
-+}
-+
-+
-+ulong ha_ibmdb2i::index_flags(uint inx, uint part, bool all_parts) const
-+{
-+ return HA_READ_NEXT | HA_READ_PREV | HA_KEYREAD_ONLY | HA_READ_ORDER | HA_READ_RANGE;
-+}
-+
-+
-+static struct st_mysql_sys_var* ibmdb2i_system_variables[] = {
-+ MYSQL_SYSVAR(rdb_name),
-+ MYSQL_SYSVAR(transaction_unsafe),
-+ MYSQL_SYSVAR(lob_alloc_size),
-+ MYSQL_SYSVAR(max_read_buffer_size),
-+ MYSQL_SYSVAR(max_write_buffer_size),
-+ MYSQL_SYSVAR(async_enabled),
-+ MYSQL_SYSVAR(assume_exclusive_use),
-+ MYSQL_SYSVAR(compat_opt_blob_cols),
-+ MYSQL_SYSVAR(compat_opt_time_as_duration),
-+ MYSQL_SYSVAR(compat_opt_allow_zero_date_vals),
-+ MYSQL_SYSVAR(compat_opt_year_as_int),
-+ MYSQL_SYSVAR(propagate_default_col_vals),
-+ MYSQL_SYSVAR(create_index_option),
-+// MYSQL_SYSVAR(discovery_mode),
-+ MYSQL_SYSVAR(system_trace_level),
-+ NULL
-+};
-+
-+
-+struct st_mysql_storage_engine ibmdb2i_storage_engine=
-+{ MYSQL_HANDLERTON_INTERFACE_VERSION };
-+
-+mysql_declare_plugin(ibmdb2i)
-+{
-+ MYSQL_STORAGE_ENGINE_PLUGIN,
-+ &ibmdb2i_storage_engine,
-+ "IBMDB2I",
-+ "The IBM development team in Rochester, Minnesota",
-+ "IBM DB2 for i Storage Engine",
-+ PLUGIN_LICENSE_GPL,
-+ ibmdb2i_init_func, /* Plugin Init */
-+ ibmdb2i_done_func, /* Plugin Deinit */
-+ 0x0100 /* 1.0 */,
-+ NULL, /* status variables */
-+ ibmdb2i_system_variables, /* system variables */
-+ NULL /* config options */
-+}
-+mysql_declare_plugin_end;
-diff -urN mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc.rej mysql/storage/ibmdb2i/ha_ibmdb2i.cc.rej
---- mysql-old/storage/ibmdb2i/ha_ibmdb2i.cc.rej 1969-12-31 23:00:00.000000000 -0100
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.cc.rej 2009-12-10 00:57:23.429840544 -0100
-@@ -0,0 +1,21 @@
-+***************
-+*** 2644,2652 ****
-+ rowsToRead = 1;
-+ }
-+
-+- rowsToRead = min(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+
-+- uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
-+ activeReadBuf = &multiRowReadBuf;
-+
-+--- 2644,2652 ----
-+ rowsToRead = 1;
-+ }
-+
-++ rowsToRead = MYSQL_MIN(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+
-++ uint bufSize = MYSQL_MIN((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
-+ activeReadBuf = &multiRowReadBuf;
-+
-diff -urN mysql-old/storage/ibmdb2i/ha_ibmdb2i.h mysql/storage/ibmdb2i/ha_ibmdb2i.h
---- mysql-old/storage/ibmdb2i/ha_ibmdb2i.h 2009-12-10 00:54:18.740801668 -0100
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.h 2009-12-10 00:57:23.429840544 -0100
-@@ -502,7 +502,7 @@
- ha_rows getIndexReadEstimate(uint index)
- {
- if (indexReadSizeEstimates)
-- return max(indexReadSizeEstimates[index], 1);
-+ return MYSQL_MAX(indexReadSizeEstimates[index], 1);
-
- return 10000; // Assume index scan if no estimate exists.
- }
-diff -urN mysql-old/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql-old/storage/innobase/include/ut0byte.h 2009-12-10 00:54:18.733801273 -0100
-+++ mysql/storage/innobase/include/ut0byte.h 2009-12-10 00:57:23.430599449 -0100
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -urN mysql-old/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql-old/storage/innodb_plugin/dict/dict0dict.c 2009-12-10 00:54:18.728801665 -0100
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2009-12-10 00:57:23.431800036 -0100
-@@ -4699,7 +4699,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4709,7 +4709,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -urN mysql-old/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql-old/storage/innodb_plugin/include/dict0dict.h 2009-12-10 00:54:18.726799841 -0100
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2009-12-10 00:57:23.433924906 -0100
-@@ -1090,7 +1090,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -urN mysql-old/storage/innodb_plugin/include/ut0byte.h mysql/storage/innodb_plugin/include/ut0byte.h
---- mysql-old/storage/innodb_plugin/include/ut0byte.h 2009-12-10 00:54:18.723801555 -0100
-+++ mysql/storage/innodb_plugin/include/ut0byte.h 2009-12-10 00:57:23.434904923 -0100
-@@ -99,7 +99,7 @@
- dulint b); /*!< in: dulint */
- /*******************************************************//**
- Calculates the max of two dulints.
--@return max(a, b) */
-+@return MYSQL_MAX(a, b) */
- UNIV_INLINE
- dulint
- ut_dulint_get_max(
-@@ -108,7 +108,7 @@
- dulint b); /*!< in: dulint */
- /*******************************************************//**
- Calculates the min of two dulints.
--@return min(a, b) */
-+@return MYSQL_MIN(a, b) */
- UNIV_INLINE
- dulint
- ut_dulint_get_min(
-diff -urN mysql-old/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql-old/storage/myisam/ft_boolean_search.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/ft_boolean_search.c 2009-12-10 00:57:23.435891307 -0100
-@@ -46,9 +46,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -urN mysql-old/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-old/storage/myisam/ha_myisam.cc 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/ha_myisam.cc 2009-12-10 00:57:23.436925199 -0100
-@@ -1519,7 +1519,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -urN mysql-old/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-old/storage/myisam/mi_cache.c 2009-12-10 00:54:18.717800958 -0100
-+++ mysql/storage/myisam/mi_cache.c 2009-12-10 00:57:23.437924978 -0100
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -urN mysql-old/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-old/storage/myisam/mi_check.c 2009-12-10 00:54:18.717800958 -0100
-+++ mysql/storage/myisam/mi_check.c 2009-12-10 00:57:23.439925308 -0100
-@@ -2165,7 +2165,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2321,7 +2321,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2772,7 +2772,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3967,7 +3967,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-@@ -4318,7 +4318,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -urN mysql-old/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-old/storage/myisam/mi_create.c 2009-12-10 00:54:18.717800958 -0100
-+++ mysql/storage/myisam/mi_create.c 2009-12-10 00:57:23.441925056 -0100
-@@ -27,6 +27,7 @@
- #endif
- #endif
- #include <m_ctype.h>
-+#include "my_global.h"
-
- /*
- Old options is used when recreating database, from myisamchk
-@@ -439,8 +440,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +530,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +568,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -urN mysql-old/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-old/storage/myisam/mi_dynrec.c 2009-12-10 00:54:18.717800958 -0100
-+++ mysql/storage/myisam/mi_dynrec.c 2009-12-10 00:57:23.442925103 -0100
-@@ -850,7 +850,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -urN mysql-old/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-old/storage/myisam/mi_extra.c 2009-12-10 00:54:18.718800573 -0100
-+++ mysql/storage/myisam/mi_extra.c 2009-12-10 00:57:23.443925275 -0100
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -urN mysql-old/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-old/storage/myisam/mi_open.c 2009-12-10 00:54:18.718800573 -0100
-+++ mysql/storage/myisam/mi_open.c 2009-12-10 00:57:23.444798045 -0100
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -711,10 +711,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -urN mysql-old/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-old/storage/myisam/mi_packrec.c 2009-12-10 00:54:18.717800958 -0100
-+++ mysql/storage/myisam/mi_packrec.c 2009-12-10 00:57:23.445902843 -0100
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -urN mysql-old/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-old/storage/myisam/mi_test1.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/mi_test1.c 2009-12-10 00:57:23.446924995 -0100
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -urN mysql-old/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-old/storage/myisam/mi_test2.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/mi_test2.c 2009-12-10 00:57:23.447736213 -0100
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -urN mysql-old/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-old/storage/myisam/myisamlog.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/myisamlog.c 2009-12-10 00:57:23.448597030 -0100
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -urN mysql-old/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-old/storage/myisam/myisampack.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/myisampack.c 2009-12-10 00:57:23.449833524 -0100
-@@ -31,6 +31,7 @@
- #endif
- #include <my_getopt.h>
- #include <assert.h>
-+#include "my_global.h"
-
- #if SIZEOF_LONG_LONG > 4
- #define BITS_SAVED 64
-@@ -1239,7 +1240,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3002,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -urN mysql-old/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-old/storage/myisam/rt_mbr.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/rt_mbr.c 2009-12-10 00:57:23.450925321 -0100
-@@ -14,6 +14,7 @@
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
- #include "myisamdef.h"
-+#include "my_global.h"
-
- #ifdef HAVE_RTREE_KEYS
-
-@@ -325,8 +326,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +339,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +418,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +432,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +509,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +520,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +605,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +616,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -urN mysql-old/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-old/storage/myisam/sort.c 2009-12-10 00:54:18.716800276 -0100
-+++ mysql/storage/myisam/sort.c 2009-12-10 00:57:23.451743818 -0100
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -813,7 +813,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -834,7 +834,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -urN mysql-old/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-old/storage/myisammrg/ha_myisammrg.cc 2009-12-10 00:54:18.715800244 -0100
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2009-12-10 00:57:23.452925312 -0100
-@@ -930,7 +930,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -urN mysql-old/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-old/storage/ndb/src/common/portlib/NdbTCP.cpp 2009-12-10 00:54:18.713799851 -0100
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2009-12-10 00:57:23.453925275 -0100
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -urN mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp
---- mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp 2009-12-10 00:54:18.702801233 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxCmp.cpp 2009-12-10 00:57:23.454888653 -0100
-@@ -54,7 +54,7 @@
- ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
- // sizes
- const unsigned size1 = ah(searchKey).getDataSize();
-- const unsigned size2 = min(ah(entryData).getDataSize(), len2);
-+ const unsigned size2 = MYSQL_MIN(ah(entryData).getDataSize(), len2);
- len2 -= size2;
- // compare
- NdbSqlUtil::Cmp* const cmp = c_sqlCmp[start];
-@@ -139,7 +139,7 @@
- ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
- // sizes
- const unsigned size1 = ah(boundInfo).getDataSize();
-- const unsigned size2 = min(ah(entryData).getDataSize(), len2);
-+ const unsigned size2 = MYSQL_MIN(ah(entryData).getDataSize(), len2);
- len2 -= size2;
- // compare
- NdbSqlUtil::Cmp* const cmp = c_sqlCmp[index];
-diff -urN mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2009-12-10 00:54:18.702801233 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2009-12-10 00:57:23.454888653 -0100
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -urN mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp
---- mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp 2009-12-10 00:54:18.702801233 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxTree.cpp 2009-12-10 00:57:23.455625758 -0100
-@@ -260,7 +260,7 @@
- selectNode(leafNode, leafLoc);
- if (semiNode.getOccup() < tree.m_minOccup) {
- jam();
-- unsigned cnt = min(leafNode.getOccup(), tree.m_minOccup - semiNode.getOccup());
-+ unsigned cnt = MYSQL_MIN(leafNode.getOccup(), tree.m_minOccup - semiNode.getOccup());
- nodeSlide(semiNode, leafNode, cnt, i);
- if (leafNode.getOccup() == 0) {
- // remove empty leaf
-@@ -290,7 +290,7 @@
- jam();
- if (parentNode.getOccup() < tree.m_minOccup) {
- jam();
-- unsigned cnt = min(leafNode.getOccup(), tree.m_minOccup - parentNode.getOccup());
-+ unsigned cnt = MYSQL_MIN(leafNode.getOccup(), tree.m_minOccup - parentNode.getOccup());
- nodeSlide(parentNode, leafNode, cnt, i);
- }
- }
-diff -urN mysql-old/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-old/storage/ndb/src/ndbapi/NdbBlob.cpp 2009-12-10 00:54:18.698800891 -0100
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2009-12-10 00:57:23.456925414 -0100
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -urN mysql-old/storage/ndb/test/ndbapi/test_event_merge.cpp mysql/storage/ndb/test/ndbapi/test_event_merge.cpp
---- mysql-old/storage/ndb/test/ndbapi/test_event_merge.cpp 2009-12-10 00:54:18.691800845 -0100
-+++ mysql/storage/ndb/test/ndbapi/test_event_merge.cpp 2009-12-10 00:57:23.457924960 -0100
-@@ -23,8 +23,8 @@
- // version >= 5.1 required
-
- #if !defined(min) || !defined(max)
--#define min(x, y) ((x) < (y) ? (x) : (y))
--#define max(x, y) ((x) > (y) ? (x) : (y))
-+#define MYSQL_MIN(x, y) ((x) < (y) ? (x) : (y))
-+#define MYSQL_MAX(x, y) ((x) > (y) ? (x) : (y))
- #endif
-
- /*
-diff -urN mysql-old/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-old/storage/ndb/test/ndbapi/testIndexStat.cpp 2009-12-10 00:54:18.692800942 -0100
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2009-12-10 00:57:23.459722163 -0100
-@@ -32,8 +32,8 @@
-
- #undef min
- #undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -urN mysql-old/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-old/storage/ndb/test/src/getarg.c 2009-12-10 00:54:18.695800160 -0100
-+++ mysql/storage/ndb/test/src/getarg.c 2009-12-10 00:57:23.459722163 -0100
-@@ -66,7 +66,7 @@
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
- #ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -urN mysql-old/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-old/strings/ctype-big5.c 2009-12-10 00:54:18.758802123 -0100
-+++ mysql/strings/ctype-big5.c 2009-12-10 00:57:23.462925882 -0100
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-old/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-old/strings/ctype-bin.c 2009-12-10 00:54:18.754801046 -0100
-+++ mysql/strings/ctype-bin.c 2009-12-10 00:57:23.466924829 -0100
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-old/strings/ctype-gbk.c 2009-12-10 00:54:18.756801544 -0100
-+++ mysql/strings/ctype-gbk.c 2009-12-10 00:57:23.470925687 -0100
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-old/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-old/strings/ctype-mb.c 2009-12-10 00:54:18.758802123 -0100
-+++ mysql/strings/ctype-mb.c 2009-12-10 00:57:23.562756029 -0100
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-old/strings/ctype-simple.c 2009-12-10 00:54:18.758802123 -0100
-+++ mysql/strings/ctype-simple.c 2009-12-10 00:57:23.563925061 -0100
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -urN mysql-old/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-old/strings/ctype-tis620.c 2009-12-10 00:54:18.755801042 -0100
-+++ mysql/strings/ctype-tis620.c 2009-12-10 00:57:23.564925210 -0100
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -urN mysql-old/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-old/strings/ctype-uca.c 2009-12-10 00:54:18.755801042 -0100
-+++ mysql/strings/ctype-uca.c 2009-12-10 00:57:23.567925139 -0100
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -urN mysql-old/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-old/strings/ctype-ucs2.c 2009-12-10 00:54:18.755801042 -0100
-+++ mysql/strings/ctype-ucs2.c 2009-12-10 00:57:23.573924782 -0100
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-old/strings/ctype-utf8.c 2009-12-10 00:54:18.755801042 -0100
-+++ mysql/strings/ctype-utf8.c 2009-12-10 00:57:23.575774954 -0100
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -urN mysql-old/strings/decimal.c mysql/strings/decimal.c
---- mysql-old/strings/decimal.c 2009-12-10 00:54:18.754801046 -0100
-+++ mysql/strings/decimal.c 2009-12-10 01:09:06.977551298 -0100
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1754,7 +1754,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN (intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1886,7 +1886,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -urN mysql-old/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-old/strings/my_vsnprintf.c 2009-12-10 00:54:18.754801046 -0100
-+++ mysql/strings/my_vsnprintf.c 2009-12-10 00:57:23.580804504 -0100
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -urN mysql-old/strings/str2int.c mysql/strings/str2int.c
---- mysql-old/strings/str2int.c 2009-12-10 00:54:18.759801315 -0100
-+++ mysql/strings/str2int.c 2009-12-10 00:57:23.580804504 -0100
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -urN mysql-old/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql-old/tests/mysql_client_test.c 2009-12-10 00:54:18.663800317 -0100
-+++ mysql/tests/mysql_client_test.c 2009-12-10 00:57:23.584924840 -0100
-@@ -587,7 +587,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -urN mysql-old/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-old/vio/viosocket.c 2009-12-10 00:54:18.765800829 -0100
-+++ mysql/vio/viosocket.c 2009-12-10 00:57:23.590799829 -0100
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.41.patch b/07110_all_mysql_gcc-4.2_5.1.41.patch
deleted file mode 100644
index aa82151..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.41.patch
+++ /dev/null
@@ -1,3460 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqlbinlog.cc ./client/mysqlbinlog.cc
---- ../mysql-5.1.22-beta.orig/client/mysqlbinlog.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqlbinlog.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1941,7 +1941,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysql.cc ./client/mysql.cc
---- ../mysql-5.1.22-beta.orig/client/mysql.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysql.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -3295,9 +3295,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3317,7 +3317,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqldump.c ./client/mysqldump.c
---- ../mysql-5.1.22-beta.orig/client/mysqldump.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqldump.c 2007-10-04 21:43:01.000000000 +0200
-@@ -808,7 +808,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff), err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4486,7 +4486,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff), var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff), var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysqltest.cc ./client/mysqltest.cc
---- ../mysql-5.1.22-beta.orig/client/mysqltest.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysqltest.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -5366,9 +5366,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -uNr ../mysql-5.1.22-beta.orig/client/mysql_upgrade.c ./client/mysql_upgrade.c
---- ../mysql-5.1.22-beta.orig/client/mysql_upgrade.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/mysql_upgrade.c 2007-10-04 21:43:01.000000000 +0200
-@@ -527,7 +527,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -uNr ../mysql-5.1.22-beta.orig/client/sql_string.cc ./client/sql_string.cc
---- ../mysql-5.1.22-beta.orig/client/sql_string.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./client/sql_string.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -659,7 +659,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -uNr ../mysql-5.1.22-beta.orig/dbug/dbug.c ./dbug/dbug.c
---- ../mysql-5.1.22-beta.orig/dbug/dbug.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./dbug/dbug.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1202,7 +1202,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -uNr ../mysql-5.1.22-beta.orig/extra/yassl/src/ssl.cpp ./extra/yassl/src/ssl.cpp
---- ../mysql-5.1.22-beta.orig/extra/yassl/src/ssl.cpp 2007-10-04 21:42:21.000000000 +0200
-+++ ./extra/yassl/src/ssl.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +113,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -uNr ../mysql-5.1.22-beta.orig/extra/yassl/taocrypt/src/dh.cpp ./extra/yassl/taocrypt/src/dh.cpp
---- ../mysql-5.1.22-beta.orig/extra/yassl/taocrypt/src/dh.cpp 2007-10-04 21:42:21.000000000 +0200
-+++ ./extra/yassl/taocrypt/src/dh.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +54,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -uNr ../mysql-5.1.22-beta.orig/include/my_global.h ./include/my_global.h
---- ../mysql-5.1.22-beta.orig/include/my_global.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./include/my_global.h 2007-10-04 21:43:01.000000000 +0200
-@@ -572,10 +572,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -uNr ../mysql-5.1.22-beta.orig/libmysql/libmysql.c ./libmysql/libmysql.c
---- ../mysql-5.1.22-beta.orig/libmysql/libmysql.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./libmysql/libmysql.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1570,7 +1570,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3617,7 +3617,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3850,9 +3850,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4170,7 +4170,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4182,7 +4182,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -uNr ../mysql-5.1.22-beta.orig/libmysqld/lib_sql.cc ./libmysqld/lib_sql.cc
---- ../mysql-5.1.22-beta.orig/libmysqld/lib_sql.cc 2007-10-04 21:42:21.000000000 +0200
-+++ ./libmysqld/lib_sql.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/array.c ./mysys/array.c
---- ../mysql-5.1.22-beta.orig/mysys/array.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/array.c 2007-10-04 21:43:01.000000000 +0200
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/default.c ./mysys/default.c
---- ../mysql-5.1.22-beta.orig/mysys/default.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/default.c 2007-10-04 21:43:01.000000000 +0200
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/mf_format.c ./mysys/mf_format.c
---- ../mysql-5.1.22-beta.orig/mysys/mf_format.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/mf_format.c 2007-10-04 21:43:01.000000000 +0200
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/mf_iocache.c ./mysys/mf_iocache.c
---- ../mysql-5.1.22-beta.orig/mysys/mf_iocache.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/mf_iocache.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_alloc.c ./mysys/my_alloc.c
---- ../mysql-5.1.22-beta.orig/mysys/my_alloc.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_alloc.c 2007-10-04 21:43:01.000000000 +0200
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_bitmap.c ./mysys/my_bitmap.c
---- ../mysql-5.1.22-beta.orig/mysys/my_bitmap.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_bitmap.c 2007-10-04 21:43:01.000000000 +0200
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_compress.c ./mysys/my_compress.c
---- ../mysql-5.1.22-beta.orig/mysys/my_compress.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_compress.c 2007-10-04 21:43:01.000000000 +0200
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_conio.c ./mysys/my_conio.c
---- ../mysql-5.1.22-beta.orig/mysys/my_conio.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_conio.c 2007-10-04 21:43:01.000000000 +0200
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_file.c ./mysys/my_file.c
---- ../mysql-5.1.22-beta.orig/mysys/my_file.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_file.c 2007-10-04 21:43:01.000000000 +0200
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_getopt.c ./mysys/my_getopt.c
---- ../mysql-5.1.22-beta.orig/mysys/my_getopt.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_getopt.c 2007-10-04 21:43:01.000000000 +0200
-@@ -973,7 +973,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/my_handler.c ./mysys/my_handler.c
---- ../mysql-5.1.22-beta.orig/mysys/my_handler.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/my_handler.c 2007-10-04 21:43:01.000000000 +0200
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/safemalloc.c ./mysys/safemalloc.c
---- ../mysql-5.1.22-beta.orig/mysys/safemalloc.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./mysys/safemalloc.c 2007-10-04 21:43:01.000000000 +0200
-@@ -238,7 +238,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -uNr ../mysql-5.1.22-beta.orig/server-tools/instance-manager/buffer.cc ./server-tools/instance-manager/buffer.cc
---- ../mysql-5.1.22-beta.orig/server-tools/instance-manager/buffer.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./server-tools/instance-manager/buffer.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -uNr ../mysql-5.1.22-beta.orig/server-tools/instance-manager/listener.cc ./server-tools/instance-manager/listener.cc
---- ../mysql-5.1.22-beta.orig/server-tools/instance-manager/listener.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./server-tools/instance-manager/listener.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
---- ../mysql-5.1.22-beta.orig/sql/field.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/field.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2071,7 +2071,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2079,7 +2079,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -3045,7 +3045,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3257,7 +3257,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3474,7 +3474,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3693,7 +3693,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3934,7 +3934,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4157,7 +4157,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4515,7 +4515,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6409,13 +6409,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6423,7 +6423,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6680,7 +6680,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7675,7 +7675,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7835,7 +7835,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -9067,7 +9067,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9153,7 +9153,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9270,7 +9270,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9726,7 +9726,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/filesort.cc ./sql/filesort.cc
---- ../mysql-5.1.22-beta.orig/sql/filesort.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/filesort.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -191,7 +191,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -213,12 +213,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1113,7 +1113,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1376,7 +1376,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/ha_ndbcluster.cc ./sql/ha_ndbcluster.cc
---- ../mysql-5.1.22-beta.orig/sql/ha_ndbcluster.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/ha_ndbcluster.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/handler.h ./sql/handler.h
---- ../mysql-5.1.22-beta.orig/sql/handler.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/handler.h 2007-10-04 21:43:01.000000000 +0200
-@@ -1598,15 +1598,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_buff.cc ./sql/item_buff.cc
---- ../mysql-5.1.22-beta.orig/sql/item_buff.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_buff.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -58,7 +58,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item.cc ./sql/item.cc
---- ../mysql-5.1.22-beta.orig/sql/item.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -443,9 +443,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -739,7 +739,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5349,7 +5349,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -7388,7 +7388,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7410,7 +7410,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7428,7 +7428,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_cmpfunc.cc ./sql/item_cmpfunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_cmpfunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_cmpfunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -622,7 +622,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1154,7 +1154,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2189,7 +2189,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2200,10 +2200,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2227,9 +2227,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2357,7 +2357,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2401,10 +2401,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2412,8 +2412,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2821,7 +2821,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4711,7 +4711,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4730,7 +4730,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -4851,14 +4851,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -4882,14 +4882,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_func.cc ./sql/item_func.cc
---- ../mysql-5.1.22-beta.orig/sql/item_func.cc 2009-12-05 16:23:27.215667455 -0100
-+++ ./sql/item_func.cc 2009-12-05 16:23:55.531666569 -0100
-@@ -466,7 +466,7 @@
- {
- int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -481,7 +481,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -577,7 +577,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1171,10 +1171,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1284,9 +1284,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1334,7 +1334,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1343,7 +1343,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1357,7 +1357,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1479,8 +1479,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1998,7 +1998,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -2008,7 +2008,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2025,13 +2025,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2132,7 +2132,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2991,7 +2991,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -3000,7 +3000,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_strfunc.cc ./sql/item_strfunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_strfunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_strfunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1225,7 +1225,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1245,7 +1245,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1939,7 +1939,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3070,11 +3070,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_sum.cc ./sql/item_sum.cc
---- ../mysql-5.1.22-beta.orig/sql/item_sum.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_sum.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1170,7 +1170,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1233,16 +1233,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1434,13 +1434,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3520,7 +3520,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/item_timefunc.cc ./sql/item_timefunc.cc
---- ../mysql-5.1.22-beta.orig/sql/item_timefunc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/item_timefunc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1829,7 +1829,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/key.cc ./sql/key.cc
---- ../mysql-5.1.22-beta.orig/sql/key.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/key.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -uNr ../mysql-5.1.22-beta.orig/sql/log.cc ./sql/log.cc
---- ../mysql-5.1.22-beta.orig/sql/log.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/log.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2407,7 +2407,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -4866,7 +4866,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/log_event.cc ./sql/log_event.cc
---- ../mysql-5.1.22-beta.orig/sql/log_event.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/log_event.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -5427,7 +5427,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7151,7 +7151,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/mysqld.cc ./sql/mysqld.cc
---- ../mysql-5.1.22-beta.orig/sql/mysqld.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/mysqld.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -3318,7 +3318,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3330,15 +3330,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4994,7 +4994,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/net_serv.cc ./sql/net_serv.cc
---- ../mysql-5.1.22-beta.orig/sql/net_serv.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/net_serv.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -756,7 +756,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql/opt_range.cc ./sql/opt_range.cc
---- ../mysql-5.1.22-beta.orig/sql/opt_range.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/opt_range.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2352,7 +2352,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3828,7 +3828,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7445,7 +7445,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7514,7 +7514,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8429,13 +8429,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8454,7 +8454,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8537,7 +8537,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8650,13 +8650,13 @@
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -9265,7 +9265,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9491,7 +9491,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10123,9 +10123,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -uNr ../mysql-5.1.22-beta.orig/sql/protocol.cc ./sql/protocol.cc
---- ../mysql-5.1.22-beta.orig/sql/protocol.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/protocol.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/rpl_rli.cc ./sql/rpl_rli.cc
---- ../mysql-5.1.22-beta.orig/sql/rpl_rli.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/rpl_rli.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -662,7 +662,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -672,7 +672,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
---- ../mysql.orig/sql/rpl_record.cc 2007-10-04 22:44:29.000000000 +0200
-+++ sql/rpl_record.cc 2007-10-04 23:36:10.000000000 +0200
-@@ -255,7 +255,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -uNr ../mysql-5.1.22-beta.orig/sql/rpl_utility.cc ./sql/rpl_utility.cc
---- ../mysql-5.1.22-beta.orig/sql/rpl_utility.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/rpl_utility.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/set_var.cc ./sql/set_var.cc
---- ../mysql-5.1.22-beta.orig/sql/set_var.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/set_var.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1857,7 +1857,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/slave.cc ./sql/slave.cc
---- ../mysql-5.1.22-beta.orig/sql/slave.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/slave.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1710,7 +1710,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2329,7 +2329,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -3987,7 +3987,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/spatial.h ./sql/spatial.h
---- ../mysql-5.1.22-beta.orig/sql/spatial.h 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/spatial.h 2007-10-04 21:43:01.000000000 +0200
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sp_head.cc ./sql/sp_head.cc
---- ../mysql-5.1.22-beta.orig/sql/sp_head.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sp_head.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2417,7 +2417,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2618,7 +2618,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_acl.cc ./sql/sql_acl.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_acl.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_acl.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -817,7 +817,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_analyse.cc ./sql/sql_analyse.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_analyse.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_analyse.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_cache.cc ./sql/sql_cache.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_cache.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_cache.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -981,7 +981,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2342,7 +2342,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2397,7 +2397,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2425,7 +2425,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2513,8 +2513,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2546,7 +2546,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2555,7 +2555,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -2978,7 +2978,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_class.cc ./sql/sql_class.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_class.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_class.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -381,7 +381,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -2015,7 +2015,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_client.cc ./sql/sql_client.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_client.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_client.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_connect.cc ./sql/sql_connect.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_connect.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_connect.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -670,7 +670,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_load.cc ./sql/sql_load.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_load.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_load.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1084,7 +1084,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_parse.cc ./sql/sql_parse.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_parse.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_parse.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -5601,7 +5601,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7094,7 +7094,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_partition.cc ./sql/sql_partition.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_partition.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_partition.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -4516,7 +4516,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_plugin.cc ./sql/sql_plugin.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_plugin.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_plugin.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2084,7 +2084,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff), error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff), error_len));
- strvalue= buff;
- goto err;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_prepare.cc ./sql/sql_prepare.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_prepare.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_prepare.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_repl.cc ./sql/sql_repl.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_repl.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_repl.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1250,12 +1250,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1417,7 +1417,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_select.cc ./sql/sql_select.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_select.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_select.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -2866,7 +2866,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3780,7 +3780,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3803,7 +3803,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3962,7 +3962,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4282,7 +4282,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4449,7 +4449,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5394,7 +5394,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10259,7 +10259,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -14023,7 +14023,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14145,7 +14145,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_string.cc ./sql/sql_string.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_string.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_string.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -661,7 +661,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_table.cc ./sql/sql_table.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_table.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_table.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -3215,7 +3215,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_yacc.cc ./sql/sql_yacc.cc
---- ../mysql-5.1.22-beta.orig/sql/sql_yacc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_yacc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -16001,7 +16001,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16021,7 +16021,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_yacc.yy ./sql/sql_yacc.yy
---- ../mysql-5.1.22-beta.orig/sql/sql_yacc.yy 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/sql_yacc.yy 2007-10-04 21:43:01.000000000 +0200
-@@ -1641,7 +1641,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1651,7 +1651,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -uNr ../mysql-5.1.22-beta.orig/mysys/stacktrace.c ./mysys/stacktrace.c
---- ../mysql-5.1.22-beta.orig/mysys/stacktrace.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./mysys/stacktrace.c 2007-10-04 21:43:01.000000000 +0200
-@@ -210,7 +210,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -uNr ../mysql-5.1.22-beta.orig/sql/thr_malloc.cc ./sql/thr_malloc.cc
---- ../mysql-5.1.22-beta.orig/sql/thr_malloc.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/thr_malloc.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -126,7 +126,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -uNr ../mysql-5.1.22-beta.orig/sql/tztime.cc ./sql/tztime.cc
---- ../mysql-5.1.22-beta.orig/sql/tztime.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/tztime.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -uNr ../mysql-5.1.22-beta.orig/sql/unireg.cc ./sql/unireg.cc
---- ../mysql-5.1.22-beta.orig/sql/unireg.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql/unireg.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -490,7 +490,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/sql-common/client.c ./sql-common/client.c
---- ../mysql-5.1.22-beta.orig/sql-common/client.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql-common/client.c 2007-10-04 21:43:01.000000000 +0200
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -uNr ../mysql-5.1.22-beta.orig/sql-common/my_time.c ./sql-common/my_time.c
---- ../mysql-5.1.22-beta.orig/sql-common/my_time.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./sql-common/my_time.c 2007-10-04 21:43:01.000000000 +0200
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/csv/ha_tina.cc ./storage/csv/ha_tina.cc
---- ../mysql-5.1.22-beta.orig/storage/csv/ha_tina.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/csv/ha_tina.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1185,7 +1185,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1421,7 +1421,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -uNr ../mysql-5.1.22-beta.orig/storage/federated/ha_federated.cc ./storage/federated/ha_federated.cc
---- ../mysql-5.1.22-beta.orig/storage/federated/ha_federated.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/federated/ha_federated.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -uNr ../mysql-5.1.22-beta.orig/storage/heap/hp_create.c ./storage/heap/hp_create.c
---- ../mysql-5.1.22-beta.orig/storage/heap/hp_create.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/heap/hp_create.c 2007-10-04 21:43:01.000000000 +0200
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/heap/hp_test2.c ./storage/heap/hp_test2.c
---- ../mysql-5.1.22-beta.orig/storage/heap/hp_test2.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/heap/hp_test2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/ha_myisam.cc ./storage/myisam/ha_myisam.cc
---- ../mysql-5.1.22-beta.orig/storage/myisam/ha_myisam.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/ha_myisam.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -1511,7 +1511,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_cache.c ./storage/myisam/mi_cache.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_cache.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_cache.c 2007-10-04 21:43:01.000000000 +0200
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_create.c ./storage/myisam/mi_create.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_create.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_create.c 2007-10-04 21:43:01.000000000 +0200
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_dynrec.c ./storage/myisam/mi_dynrec.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_dynrec.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_dynrec.c 2007-10-04 21:43:01.000000000 +0200
-@@ -850,7 +850,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_extra.c ./storage/myisam/mi_extra.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_extra.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_extra.c 2007-10-04 21:43:01.000000000 +0200
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_check.c ./storage/myisam/mi_check.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_check.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_check.c 2007-10-04 21:43:01.000000000 +0200
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2780,7 +2780,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4329,7 +4329,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_open.c ./storage/myisam/mi_open.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_open.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_open.c 2007-10-04 21:43:01.000000000 +0200
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -711,10 +711,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_packrec.c ./storage/myisam/mi_packrec.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_packrec.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_packrec.c 2007-10-04 21:43:01.000000000 +0200
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_test1.c ./storage/myisam/mi_test1.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_test1.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_test1.c 2007-10-04 21:43:01.000000000 +0200
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/mi_test2.c ./storage/myisam/mi_test2.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/mi_test2.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/mi_test2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/myisamlog.c ./storage/myisam/myisamlog.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/myisamlog.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/myisamlog.c 2007-10-04 21:43:01.000000000 +0200
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/myisampack.c ./storage/myisam/myisampack.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/myisampack.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/myisampack.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/rt_mbr.c ./storage/myisam/rt_mbr.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/rt_mbr.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/rt_mbr.c 2007-10-04 21:43:01.000000000 +0200
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisam/sort.c ./storage/myisam/sort.c
---- ../mysql-5.1.22-beta.orig/storage/myisam/sort.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisam/sort.c 2007-10-04 21:43:01.000000000 +0200
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -uNr ../mysql-5.1.22-beta.orig/storage/myisammrg/ha_myisammrg.cc ./storage/myisammrg/ha_myisammrg.cc
---- ../mysql-5.1.22-beta.orig/storage/myisammrg/ha_myisammrg.cc 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/myisammrg/ha_myisammrg.cc 2007-10-04 21:43:01.000000000 +0200
-@@ -930,7 +930,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/common/portlib/NdbTCP.cpp ./storage/ndb/src/common/portlib/NdbTCP.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/common/portlib/NdbTCP.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp ./storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/src/ndbapi/NdbBlob.cpp ./storage/ndb/src/ndbapi/NdbBlob.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/src/ndbapi/NdbBlob.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/test/ndbapi/testIndexStat.cpp ./storage/ndb/test/ndbapi/testIndexStat.cpp
---- ../mysql-5.1.22-beta.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/test/ndbapi/testIndexStat.cpp 2007-10-04 21:43:01.000000000 +0200
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -uNr ../mysql-5.1.22-beta.orig/storage/ndb/test/src/getarg.c ./storage/ndb/test/src/getarg.c
---- ../mysql-5.1.22-beta.orig/storage/ndb/test/src/getarg.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./storage/ndb/test/src/getarg.c 2007-10-04 21:43:01.000000000 +0200
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-big5.c ./strings/ctype-big5.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-big5.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-big5.c 2007-10-04 21:43:01.000000000 +0200
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-bin.c ./strings/ctype-bin.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-bin.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-bin.c 2007-10-04 21:43:01.000000000 +0200
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-gbk.c ./strings/ctype-gbk.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-gbk.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-gbk.c 2007-10-04 21:43:01.000000000 +0200
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-mb.c ./strings/ctype-mb.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-mb.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-mb.c 2007-10-04 21:43:01.000000000 +0200
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-simple.c ./strings/ctype-simple.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-simple.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-simple.c 2007-10-04 21:43:01.000000000 +0200
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-tis620.c ./strings/ctype-tis620.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-tis620.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-tis620.c 2007-10-04 21:43:01.000000000 +0200
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-uca.c ./strings/ctype-uca.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-uca.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-uca.c 2007-10-04 21:43:01.000000000 +0200
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-ucs2.c ./strings/ctype-ucs2.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-ucs2.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-ucs2.c 2007-10-04 21:43:01.000000000 +0200
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -uNr ../mysql-5.1.22-beta.orig/strings/ctype-utf8.c ./strings/ctype-utf8.c
---- ../mysql-5.1.22-beta.orig/strings/ctype-utf8.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/ctype-utf8.c 2007-10-04 21:43:01.000000000 +0200
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -uNr ../mysql-5.1.22-beta.orig/strings/decimal.c ./strings/decimal.c
---- ../mysql-5.1.22-beta.orig/strings/decimal.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/decimal.c 2007-10-04 21:43:01.000000000 +0200
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -uNr ../mysql-5.1.22-beta.orig/strings/my_vsnprintf.c ./strings/my_vsnprintf.c
---- ../mysql-5.1.22-beta.orig/strings/my_vsnprintf.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/my_vsnprintf.c 2007-10-04 21:43:01.000000000 +0200
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -uNr ../mysql-5.1.22-beta.orig/strings/str2int.c ./strings/str2int.c
---- ../mysql-5.1.22-beta.orig/strings/str2int.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./strings/str2int.c 2007-10-04 21:43:01.000000000 +0200
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -uNr ../mysql-5.1.22-beta.orig/tests/mysql_client_test.c ./tests/mysql_client_test.c
---- ../mysql-5.1.22-beta.orig/tests/mysql_client_test.c 2007-10-04 21:42:21.000000000 +0200
-+++ ./tests/mysql_client_test.c 2007-10-04 21:43:01.000000000 +0200
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -uNr ../mysql-5.1.22-beta.orig/vio/viosocket.c ./vio/viosocket.c
---- ../mysql-5.1.22-beta.orig/vio/viosocket.c 2007-10-04 21:42:20.000000000 +0200
-+++ ./vio/viosocket.c 2007-10-04 21:43:01.000000000 +0200
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
-diff -uNr ../mysql-5.1.22-beta.orig/sql/sql_show.cc ./sql/sql_show.cc
---- ../mysql.orig/sql/sql_show.cc 2007-10-05 08:53:24.000000000 +0200
-+++ sql/sql_show.cc 2007-10-05 08:53:54.000000000 +0200
-@@ -747,7 +747,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -758,7 +758,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1866,7 +1866,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1995,7 +1995,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -6978,7 +6978,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
diff --git a/07110_all_mysql_gcc-4.2_5.1.42.patch b/07110_all_mysql_gcc-4.2_5.1.42.patch
deleted file mode 100644
index 1038267..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.42.patch
+++ /dev/null
@@ -1,3465 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -ur mysql-orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-orig/client/mysqlbinlog.cc 2010-01-01 15:09:02.611335134 -0100
-+++ mysql/client/mysqlbinlog.cc 2010-01-01 15:09:47.313334938 -0100
-@@ -1941,7 +1941,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -ur mysql-orig/client/mysql.cc mysql/client/mysql.cc
---- mysql-orig/client/mysql.cc 2010-01-01 15:09:02.612336462 -0100
-+++ mysql/client/mysql.cc 2010-01-01 15:09:47.315334327 -0100
-@@ -3295,9 +3295,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3317,7 +3317,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -ur mysql-orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-orig/client/mysqldump.c 2010-01-01 15:09:02.611335134 -0100
-+++ mysql/client/mysqldump.c 2010-01-01 15:09:47.318334198 -0100
-@@ -808,7 +808,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff), err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff), err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4486,7 +4486,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff), var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff), var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -ur mysql-orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-orig/client/mysqltest.cc 2010-01-01 15:09:02.611335134 -0100
-+++ mysql/client/mysqltest.cc 2010-01-01 15:09:47.322370346 -0100
-@@ -5366,9 +5366,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -ur mysql-orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-orig/client/mysql_upgrade.c 2010-01-01 15:09:02.611335134 -0100
-+++ mysql/client/mysql_upgrade.c 2010-01-01 15:09:47.325584245 -0100
-@@ -527,7 +527,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -ur mysql-orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-orig/client/sql_string.cc 2010-01-01 15:09:02.611335134 -0100
-+++ mysql/client/sql_string.cc 2010-01-01 15:09:47.326333754 -0100
-@@ -659,7 +659,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -ur mysql-orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-orig/dbug/dbug.c 2010-01-01 15:09:02.618334905 -0100
-+++ mysql/dbug/dbug.c 2010-01-01 15:09:47.327210854 -0100
-@@ -1202,7 +1202,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -ur mysql-orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-orig/extra/yassl/src/ssl.cpp 2010-01-01 15:09:02.614335011 -0100
-+++ mysql/extra/yassl/src/ssl.cpp 2010-01-01 15:09:47.328539903 -0100
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -ur mysql-orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-orig/extra/yassl/taocrypt/src/dh.cpp 2010-01-01 15:09:02.616213679 -0100
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-01-01 15:09:47.329544969 -0100
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -ur mysql-orig/include/my_global.h mysql/include/my_global.h
---- mysql-orig/include/my_global.h 2010-01-01 15:09:02.648336364 -0100
-+++ mysql/include/my_global.h 2010-01-01 15:09:47.330336246 -0100
-@@ -572,10 +572,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -ur mysql-orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-orig/libmysql/libmysql.c 2010-01-01 15:09:02.612336462 -0100
-+++ mysql/libmysql/libmysql.c 2010-01-01 15:09:47.333209513 -0100
-@@ -1570,7 +1570,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3603,7 +3603,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3836,9 +3836,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4156,7 +4156,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4168,7 +4168,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-Only in mysql/libmysql: libmysql.c.orig
-diff -ur mysql-orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-orig/libmysqld/lib_sql.cc 2010-01-01 15:09:02.528334742 -0100
-+++ mysql/libmysqld/lib_sql.cc 2010-01-01 15:09:47.335209712 -0100
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -ur mysql-orig/mysys/array.c mysql/mysys/array.c
---- mysql-orig/mysys/array.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/array.c 2010-01-01 15:09:47.336209852 -0100
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -ur mysql-orig/mysys/default.c mysql/mysys/default.c
---- mysql-orig/mysys/default.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/default.c 2010-01-01 15:09:47.336209852 -0100
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -ur mysql-orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-orig/mysys/mf_format.c 2010-01-01 15:09:02.620335290 -0100
-+++ mysql/mysys/mf_format.c 2010-01-01 15:09:47.337209455 -0100
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -ur mysql-orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-orig/mysys/mf_iocache.c 2010-01-01 15:09:02.620335290 -0100
-+++ mysql/mysys/mf_iocache.c 2010-01-01 15:09:47.338209403 -0100
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -ur mysql-orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-orig/mysys/my_alloc.c 2010-01-01 15:09:02.620335290 -0100
-+++ mysql/mysys/my_alloc.c 2010-01-01 15:09:47.339209348 -0100
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -ur mysql-orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-orig/mysys/my_bitmap.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/my_bitmap.c 2010-01-01 15:09:47.340276962 -0100
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -ur mysql-orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-orig/mysys/my_compress.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/my_compress.c 2010-01-01 15:09:47.341334675 -0100
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -ur mysql-orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-orig/mysys/my_conio.c 2010-01-01 15:09:02.618334905 -0100
-+++ mysql/mysys/my_conio.c 2010-01-01 15:09:47.341334675 -0100
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -ur mysql-orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-orig/mysys/my_file.c 2010-01-01 15:09:02.620335290 -0100
-+++ mysql/mysys/my_file.c 2010-01-01 15:09:47.341334675 -0100
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -ur mysql-orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-orig/mysys/my_getopt.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/my_getopt.c 2010-01-01 15:09:47.342334574 -0100
-@@ -973,7 +973,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -ur mysql-orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql-orig/mysys/my_handler.c 2010-01-01 15:09:02.619335672 -0100
-+++ mysql/mysys/my_handler.c 2010-01-01 15:09:47.343334381 -0100
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -ur mysql-orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-orig/mysys/safemalloc.c 2010-01-01 15:09:02.620335290 -0100
-+++ mysql/mysys/safemalloc.c 2010-01-01 15:09:47.343334381 -0100
-@@ -238,7 +238,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -ur mysql-orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-orig/mysys/stacktrace.c 2010-01-01 15:09:02.618334905 -0100
-+++ mysql/mysys/stacktrace.c 2010-01-01 15:09:47.765336837 -0100
-@@ -210,7 +210,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -ur mysql-orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-orig/server-tools/instance-manager/buffer.cc 2010-01-01 15:09:02.392336579 -0100
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-01-01 15:09:47.344334518 -0100
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -ur mysql-orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-orig/server-tools/instance-manager/listener.cc 2010-01-01 15:09:02.393300984 -0100
-+++ mysql/server-tools/instance-manager/listener.cc 2010-01-01 15:09:47.344334518 -0100
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -ur mysql-orig/sql/field.cc mysql/sql/field.cc
---- mysql-orig/sql/field.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/field.cc 2010-01-01 15:09:47.348334190 -0100
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2071,7 +2071,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2079,7 +2079,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -3089,7 +3089,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3301,7 +3301,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3518,7 +3518,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3737,7 +3737,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3978,7 +3978,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4201,7 +4201,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4559,7 +4559,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6453,13 +6453,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6467,7 +6467,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6724,7 +6724,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7719,7 +7719,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7879,7 +7879,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -9111,7 +9111,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9197,7 +9197,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9314,7 +9314,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9770,7 +9770,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-Only in mysql/sql: field.cc.orig
-diff -ur mysql-orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-orig/sql/filesort.cc 2010-01-01 15:09:02.539336665 -0100
-+++ mysql/sql/filesort.cc 2010-01-01 15:09:47.352329335 -0100
-@@ -191,7 +191,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -213,12 +213,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1113,7 +1113,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1376,7 +1376,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -ur mysql-orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-orig/sql/ha_ndbcluster.cc 2010-01-01 15:09:02.546335464 -0100
-+++ mysql/sql/ha_ndbcluster.cc 2010-01-01 15:09:47.355459608 -0100
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -ur mysql-orig/sql/handler.h mysql/sql/handler.h
---- mysql-orig/sql/handler.h 2010-01-01 15:09:02.550334791 -0100
-+++ mysql/sql/handler.h 2010-01-01 15:09:47.360459240 -0100
-@@ -1598,15 +1598,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -ur mysql-orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-orig/sql/item_buff.cc 2010-01-01 15:09:02.545336506 -0100
-+++ mysql/sql/item_buff.cc 2010-01-01 15:09:47.361404474 -0100
-@@ -58,7 +58,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -ur mysql-orig/sql/item.cc mysql/sql/item.cc
---- mysql-orig/sql/item.cc 2010-01-01 15:09:02.545336506 -0100
-+++ mysql/sql/item.cc 2010-01-01 15:09:47.363315052 -0100
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -443,9 +443,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -739,7 +739,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5347,7 +5347,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -7501,7 +7501,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7523,7 +7523,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7541,7 +7541,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-Only in mysql/sql: item.cc.orig
-diff -ur mysql-orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-orig/sql/item_cmpfunc.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/item_cmpfunc.cc 2010-01-01 15:09:47.367325290 -0100
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1303,7 +1303,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2355,7 +2355,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2366,10 +2366,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2393,9 +2393,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2523,7 +2523,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2567,10 +2567,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2578,8 +2578,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2987,7 +2987,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4877,7 +4877,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4896,7 +4896,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5017,14 +5017,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5048,14 +5048,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-Only in mysql/sql: item_cmpfunc.cc.orig
-diff -ur mysql-orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-orig/sql/item_func.cc 2010-01-01 15:09:02.545336506 -0100
-+++ mysql/sql/item_func.cc 2010-01-01 15:09:47.372373131 -0100
-@@ -540,7 +540,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2954,7 +2954,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2963,7 +2963,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-Only in mysql/sql: item_func.cc.orig
-Only in mysql/sql: item_func.cc.rej
-diff -ur mysql-orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-orig/sql/item_strfunc.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/item_strfunc.cc 2010-01-01 15:09:47.375233116 -0100
-@@ -1225,7 +1225,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1245,7 +1245,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1940,7 +1940,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3071,11 +3071,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-Only in mysql/sql: item_strfunc.cc.orig
-diff -ur mysql-orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-orig/sql/item_sum.cc 2010-01-01 15:09:02.545336506 -0100
-+++ mysql/sql/item_sum.cc 2010-01-01 15:09:47.377318686 -0100
-@@ -1161,7 +1161,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3348,7 +3348,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-Only in mysql/sql: item_sum.cc.orig
-diff -ur mysql-orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-orig/sql/item_timefunc.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/item_timefunc.cc 2010-01-01 15:09:47.379459542 -0100
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1829,7 +1829,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -ur mysql-orig/sql/key.cc mysql/sql/key.cc
---- mysql-orig/sql/key.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/key.cc 2010-01-01 15:09:47.381304646 -0100
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -ur mysql-orig/sql/log.cc mysql/sql/log.cc
---- mysql-orig/sql/log.cc 2010-01-01 15:09:02.540336220 -0100
-+++ mysql/sql/log.cc 2010-01-01 15:09:47.383414819 -0100
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2407,7 +2407,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN));
- return (const char*)buff;
- }
- return log_name;
-@@ -4866,7 +4866,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -ur mysql-orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-orig/sql/log_event.cc 2010-01-01 15:09:02.539336665 -0100
-+++ mysql/sql/log_event.cc 2010-01-01 15:09:47.387459310 -0100
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -5427,7 +5427,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7151,7 +7151,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -ur mysql-orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-orig/sql/mysqld.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/mysqld.cc 2010-01-01 15:09:47.521210530 -0100
-@@ -3318,7 +3318,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3330,15 +3330,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5015,7 +5015,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-Only in mysql/sql: mysqld.cc.orig
-diff -ur mysql-orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-orig/sql/net_serv.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/net_serv.cc 2010-01-01 15:09:47.525334613 -0100
-@@ -756,7 +756,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -ur mysql-orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-orig/sql/opt_range.cc 2010-01-01 15:09:02.539336665 -0100
-+++ mysql/sql/opt_range.cc 2010-01-01 15:09:47.529460376 -0100
-@@ -2353,7 +2353,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3829,7 +3829,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7473,7 +7473,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7542,7 +7542,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8457,13 +8457,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8482,7 +8482,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8565,7 +8565,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8678,13 +8678,13 @@
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -9293,7 +9293,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9519,7 +9519,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10155,9 +10155,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-Only in mysql/sql: opt_range.cc.orig
-diff -ur mysql-orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-orig/sql/protocol.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/protocol.cc 2010-01-01 15:09:47.533213247 -0100
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -ur mysql-orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-orig/sql/rpl_record.cc 2010-01-01 15:09:02.539336665 -0100
-+++ mysql/sql/rpl_record.cc 2010-01-01 15:09:47.535211793 -0100
-@@ -283,7 +283,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-Only in mysql/sql: rpl_record.cc.orig
-diff -ur mysql-orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-orig/sql/rpl_rli.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/rpl_rli.cc 2010-01-01 15:09:47.534459929 -0100
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-Only in mysql/sql: rpl_rli.cc.orig
-diff -ur mysql-orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-orig/sql/rpl_utility.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/rpl_utility.cc 2010-01-01 15:09:47.536337418 -0100
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -ur mysql-orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-orig/sql/set_var.cc 2010-01-01 15:09:02.542336521 -0100
-+++ mysql/sql/set_var.cc 2010-01-01 15:09:47.537226848 -0100
-@@ -1857,7 +1857,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -ur mysql-orig/sql/slave.cc mysql/sql/slave.cc
---- mysql-orig/sql/slave.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/slave.cc 2010-01-01 15:09:47.540209361 -0100
-@@ -1710,7 +1710,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2329,7 +2329,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -3987,7 +3987,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -ur mysql-orig/sql/spatial.h mysql/sql/spatial.h
---- mysql-orig/sql/spatial.h 2010-01-01 15:09:02.548335147 -0100
-+++ mysql/sql/spatial.h 2010-01-01 15:09:47.542334334 -0100
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -ur mysql-orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-orig/sql/sp_head.cc 2010-01-01 15:09:02.536271077 -0100
-+++ mysql/sql/sp_head.cc 2010-01-01 15:09:47.544291900 -0100
-@@ -2428,7 +2428,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2629,7 +2629,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-Only in mysql/sql: sp_head.cc.orig
-diff -ur mysql-orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-orig/sql/sql_acl.cc 2010-01-01 15:09:02.540336220 -0100
-+++ mysql/sql/sql_acl.cc 2010-01-01 15:09:47.547334371 -0100
-@@ -818,7 +818,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-Only in mysql/sql: sql_acl.cc.orig
-diff -ur mysql-orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-orig/sql/sql_analyse.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/sql_analyse.cc 2010-01-01 15:09:47.550301341 -0100
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -ur mysql-orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-orig/sql/sql_cache.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/sql_cache.cc 2010-01-01 15:09:47.552459544 -0100
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2373,7 +2373,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2428,7 +2428,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2456,7 +2456,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2544,8 +2544,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2577,7 +2577,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2586,7 +2586,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3009,7 +3009,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-Only in mysql/sql: sql_cache.cc.orig
-diff -ur mysql-orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-orig/sql/sql_class.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/sql_class.cc 2010-01-01 15:09:47.554459263 -0100
-@@ -383,7 +383,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -2020,7 +2020,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-Only in mysql/sql: sql_class.cc.orig
-diff -ur mysql-orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-orig/sql/sql_client.cc 2010-01-01 15:09:02.536271077 -0100
-+++ mysql/sql/sql_client.cc 2010-01-01 15:09:47.557210111 -0100
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -ur mysql-orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-orig/sql/sql_connect.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/sql_connect.cc 2010-01-01 15:09:47.557210111 -0100
-@@ -670,7 +670,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -ur mysql-orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql-orig/sql/sql_load.cc 2010-01-01 15:09:02.538335007 -0100
-+++ mysql/sql/sql_load.cc 2010-01-01 15:09:47.558210398 -0100
-@@ -1089,7 +1089,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-Only in mysql/sql: sql_load.cc.orig
-diff -ur mysql-orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-orig/sql/sql_parse.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/sql_parse.cc 2010-01-01 15:09:47.561209267 -0100
-@@ -5601,7 +5601,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7094,7 +7094,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -ur mysql-orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-orig/sql/sql_partition.cc 2010-01-01 15:09:02.545336506 -0100
-+++ mysql/sql/sql_partition.cc 2010-01-01 15:09:47.566209211 -0100
-@@ -4529,7 +4529,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-Only in mysql/sql: sql_partition.cc.orig
-diff -ur mysql-orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-orig/sql/sql_plugin.cc 2010-01-01 15:09:02.535336882 -0100
-+++ mysql/sql/sql_plugin.cc 2010-01-01 15:09:47.569334308 -0100
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2084,7 +2084,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff), error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff), error_len));
- strvalue= buff;
- goto err;
- }
-diff -ur mysql-orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-orig/sql/sql_prepare.cc 2010-01-01 15:09:02.540336220 -0100
-+++ mysql/sql/sql_prepare.cc 2010-01-01 15:09:47.572459346 -0100
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -ur mysql-orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-orig/sql/sql_repl.cc 2010-01-01 15:09:02.537335674 -0100
-+++ mysql/sql/sql_repl.cc 2010-01-01 15:09:47.573459366 -0100
-@@ -1250,12 +1250,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1417,7 +1417,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -ur mysql-orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-orig/sql/sql_select.cc 2010-01-01 15:09:02.541335388 -0100
-+++ mysql/sql/sql_select.cc 2010-01-01 15:09:47.579584725 -0100
-@@ -2871,7 +2871,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3785,7 +3785,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3808,7 +3808,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3967,7 +3967,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4287,7 +4287,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4454,7 +4454,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5399,7 +5399,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10234,7 +10234,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -14003,7 +14003,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14125,7 +14125,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-Only in mysql/sql: sql_select.cc.orig
-diff -ur mysql-orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-orig/sql/sql_show.cc 2010-01-01 15:09:02.538335007 -0100
-+++ mysql/sql/sql_show.cc 2010-01-01 15:09:48.024210821 -0100
-@@ -747,7 +747,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -758,7 +758,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1866,7 +1866,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1995,7 +1995,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -6978,7 +6978,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -ur mysql-orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-orig/sql/sql_string.cc 2010-01-01 15:09:02.543336316 -0100
-+++ mysql/sql/sql_string.cc 2010-01-01 15:09:47.724209658 -0100
-@@ -661,7 +661,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -ur mysql-orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-orig/sql/sql_table.cc 2010-01-01 15:09:02.538335007 -0100
-+++ mysql/sql/sql_table.cc 2010-01-01 15:09:47.727209427 -0100
-@@ -3215,7 +3215,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -ur mysql-orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-orig/sql/sql_yacc.cc 2010-01-01 15:09:02.548335147 -0100
-+++ mysql/sql/sql_yacc.cc 2010-01-01 15:09:47.740584356 -0100
-@@ -16133,7 +16133,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16153,7 +16153,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-Only in mysql/sql: sql_yacc.cc.orig
-diff -ur mysql-orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql-orig/sql/sql_yacc.yy 2010-01-01 15:09:02.542336521 -0100
-+++ mysql/sql/sql_yacc.yy 2010-01-01 15:09:47.760336227 -0100
-@@ -1773,7 +1773,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1783,7 +1783,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-Only in mysql/sql: sql_yacc.yy.orig
-diff -ur mysql-orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-orig/sql/thr_malloc.cc 2010-01-01 15:09:02.544335871 -0100
-+++ mysql/sql/thr_malloc.cc 2010-01-01 15:09:47.765336837 -0100
-@@ -126,7 +126,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -ur mysql-orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-orig/sql/tztime.cc 2010-01-01 15:09:02.546335464 -0100
-+++ mysql/sql/tztime.cc 2010-01-01 15:09:47.766209386 -0100
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -ur mysql-orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-orig/sql/unireg.cc 2010-01-01 15:09:02.540336220 -0100
-+++ mysql/sql/unireg.cc 2010-01-01 15:09:47.768334209 -0100
-@@ -490,7 +490,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -ur mysql-orig/sql-common/client.c mysql/sql-common/client.c
---- mysql-orig/sql-common/client.c 2010-01-01 15:09:02.630334295 -0100
-+++ mysql/sql-common/client.c 2010-01-01 15:09:47.769334232 -0100
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -ur mysql-orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-orig/sql-common/my_time.c 2010-01-01 15:09:02.630334295 -0100
-+++ mysql/sql-common/my_time.c 2010-01-01 15:09:47.770459812 -0100
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -ur mysql-orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-orig/storage/csv/ha_tina.cc 2010-01-01 15:09:02.609335380 -0100
-+++ mysql/storage/csv/ha_tina.cc 2010-01-01 15:09:47.772459461 -0100
-@@ -1185,7 +1185,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1421,7 +1421,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -ur mysql-orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-orig/storage/federated/ha_federated.cc 2010-01-01 15:09:02.609335380 -0100
-+++ mysql/storage/federated/ha_federated.cc 2010-01-01 15:09:47.773459376 -0100
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -ur mysql-orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-orig/storage/heap/hp_create.c 2010-01-01 15:09:02.608335909 -0100
-+++ mysql/storage/heap/hp_create.c 2010-01-01 15:09:47.775459245 -0100
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -ur mysql-orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-orig/storage/heap/hp_test2.c 2010-01-01 15:09:02.608335909 -0100
-+++ mysql/storage/heap/hp_test2.c 2010-01-01 15:09:47.775459245 -0100
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -ur mysql-orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-orig/storage/myisam/ha_myisam.cc 2010-01-01 15:09:02.584335394 -0100
-+++ mysql/storage/myisam/ha_myisam.cc 2010-01-01 15:09:47.776459835 -0100
-@@ -1511,7 +1511,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -ur mysql-orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-orig/storage/myisam/mi_cache.c 2010-01-01 15:09:02.585335564 -0100
-+++ mysql/storage/myisam/mi_cache.c 2010-01-01 15:09:47.777459819 -0100
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -ur mysql-orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-orig/storage/myisam/mi_check.c 2010-01-01 15:09:02.584335394 -0100
-+++ mysql/storage/myisam/mi_check.c 2010-01-01 15:09:47.782337791 -0100
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2780,7 +2780,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4329,7 +4329,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -ur mysql-orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-orig/storage/myisam/mi_create.c 2010-01-01 15:09:02.584335394 -0100
-+++ mysql/storage/myisam/mi_create.c 2010-01-01 15:09:47.778459659 -0100
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-orig/storage/myisam/mi_dynrec.c 2010-01-01 15:09:02.585335564 -0100
-+++ mysql/storage/myisam/mi_dynrec.c 2010-01-01 15:09:47.779459619 -0100
-@@ -850,7 +850,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -ur mysql-orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-orig/storage/myisam/mi_extra.c 2010-01-01 15:09:02.585335564 -0100
-+++ mysql/storage/myisam/mi_extra.c 2010-01-01 15:09:47.780336122 -0100
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -ur mysql-orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-orig/storage/myisam/mi_open.c 2010-01-01 15:09:02.585335564 -0100
-+++ mysql/storage/myisam/mi_open.c 2010-01-01 15:09:47.874209727 -0100
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -711,10 +711,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -ur mysql-orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-orig/storage/myisam/mi_packrec.c 2010-01-01 15:09:02.585335564 -0100
-+++ mysql/storage/myisam/mi_packrec.c 2010-01-01 15:09:47.875210250 -0100
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -ur mysql-orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-orig/storage/myisam/mi_test1.c 2010-01-01 15:09:02.583334531 -0100
-+++ mysql/storage/myisam/mi_test1.c 2010-01-01 15:09:47.876209274 -0100
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -ur mysql-orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-orig/storage/myisam/mi_test2.c 2010-01-01 15:09:02.583334531 -0100
-+++ mysql/storage/myisam/mi_test2.c 2010-01-01 15:09:47.877209365 -0100
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -ur mysql-orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-orig/storage/myisam/myisamlog.c 2010-01-01 15:09:02.583334531 -0100
-+++ mysql/storage/myisam/myisamlog.c 2010-01-01 15:09:47.878209873 -0100
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -ur mysql-orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-orig/storage/myisam/myisampack.c 2010-01-01 15:09:02.583334531 -0100
-+++ mysql/storage/myisam/myisampack.c 2010-01-01 15:09:47.879209857 -0100
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-orig/storage/myisam/rt_mbr.c 2010-01-01 15:09:02.583334531 -0100
-+++ mysql/storage/myisam/rt_mbr.c 2010-01-01 15:09:47.881209086 -0100
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -ur mysql-orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-orig/storage/myisam/sort.c 2010-01-01 15:09:02.584335394 -0100
-+++ mysql/storage/myisam/sort.c 2010-01-01 15:09:47.882209975 -0100
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -ur mysql-orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-orig/storage/myisammrg/ha_myisammrg.cc 2010-01-01 15:09:02.582334730 -0100
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-01-01 15:09:47.883209454 -0100
-@@ -930,7 +930,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -ur mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-01-01 15:09:02.581334506 -0100
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-01-01 15:09:47.883209454 -0100
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -ur mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-01-01 15:09:02.569335158 -0100
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-01-01 15:09:47.884209231 -0100
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -ur mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-01-01 15:09:02.565334622 -0100
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-01-01 15:09:47.885209253 -0100
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -ur mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-01-01 15:09:02.560335164 -0100
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-01-01 15:09:47.886209882 -0100
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -ur mysql-orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-orig/storage/ndb/test/src/getarg.c 2010-01-01 15:09:02.562334469 -0100
-+++ mysql/storage/ndb/test/src/getarg.c 2010-01-01 15:09:47.887210399 -0100
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -ur mysql-orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-orig/strings/ctype-big5.c 2010-01-01 15:09:02.626335668 -0100
-+++ mysql/strings/ctype-big5.c 2010-01-01 15:09:47.889334678 -0100
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-orig/strings/ctype-bin.c 2010-01-01 15:09:02.622335015 -0100
-+++ mysql/strings/ctype-bin.c 2010-01-01 15:09:47.894212449 -0100
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-orig/strings/ctype-gbk.c 2010-01-01 15:09:02.624336432 -0100
-+++ mysql/strings/ctype-gbk.c 2010-01-01 15:09:47.897334635 -0100
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-orig/strings/ctype-mb.c 2010-01-01 15:09:02.626335668 -0100
-+++ mysql/strings/ctype-mb.c 2010-01-01 15:09:47.904334344 -0100
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-orig/strings/ctype-simple.c 2010-01-01 15:09:02.626335668 -0100
-+++ mysql/strings/ctype-simple.c 2010-01-01 15:09:47.905318104 -0100
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -ur mysql-orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-orig/strings/ctype-tis620.c 2010-01-01 15:09:02.623335356 -0100
-+++ mysql/strings/ctype-tis620.c 2010-01-01 15:09:47.906334863 -0100
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -ur mysql-orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-orig/strings/ctype-uca.c 2010-01-01 15:09:02.622335015 -0100
-+++ mysql/strings/ctype-uca.c 2010-01-01 15:09:47.909334777 -0100
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -ur mysql-orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-orig/strings/ctype-ucs2.c 2010-01-01 15:09:02.622335015 -0100
-+++ mysql/strings/ctype-ucs2.c 2010-01-01 15:09:47.915334150 -0100
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-orig/strings/ctype-utf8.c 2010-01-01 15:09:02.623335356 -0100
-+++ mysql/strings/ctype-utf8.c 2010-01-01 15:09:47.917212349 -0100
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -ur mysql-orig/strings/decimal.c mysql/strings/decimal.c
---- mysql-orig/strings/decimal.c 2010-01-01 15:09:02.622335015 -0100
-+++ mysql/strings/decimal.c 2010-01-01 15:09:47.920334220 -0100
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -ur mysql-orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-orig/strings/my_vsnprintf.c 2010-01-01 15:09:02.622335015 -0100
-+++ mysql/strings/my_vsnprintf.c 2010-01-01 15:09:47.921334665 -0100
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -ur mysql-orig/strings/str2int.c mysql/strings/str2int.c
---- mysql-orig/strings/str2int.c 2010-01-01 15:09:02.626335668 -0100
-+++ mysql/strings/str2int.c 2010-01-01 15:09:47.922334231 -0100
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -ur mysql-orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql-orig/tests/mysql_client_test.c 2010-01-01 15:09:02.530334560 -0100
-+++ mysql/tests/mysql_client_test.c 2010-01-01 15:09:47.927335120 -0100
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -ur mysql-orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-orig/vio/viosocket.c 2010-01-01 15:09:02.633335678 -0100
-+++ mysql/vio/viosocket.c 2010-01-01 15:09:48.022569086 -0100
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.43.patch b/07110_all_mysql_gcc-4.2_5.1.43.patch
deleted file mode 100644
index 2559cca..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.43.patch
+++ /dev/null
@@ -1,3444 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuarp mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-01-15 17:14:28.000000000 +0000
-+++ mysql/client/mysql.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -3295,9 +3295,9 @@ print_table_data(MYSQL_RES *result)
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3317,7 +3317,7 @@ print_table_data(MYSQL_RES *result)
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuarp mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-01-15 17:14:28.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-01-31 22:38:33.000000000 +0000
-@@ -527,7 +527,7 @@ static int extract_variable_from_show(DY
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuarp mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-01-15 17:14:28.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -1941,7 +1941,7 @@ static Exit_status dump_local_log_entrie
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuarp mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-01-15 17:14:29.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-01-31 22:40:46.000000000 +0000
-@@ -808,7 +808,7 @@ get_one_option(int optid, const struct m
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4486,7 +4486,7 @@ static ulong find_set(TYPELIB *lib, cons
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuarp mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-01-15 17:14:29.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -5366,9 +5366,9 @@ int read_line(char *buf, int size)
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuarp mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-01-15 17:14:29.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -659,7 +659,7 @@ int String::reserve(uint32 space_needed,
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@ int sortcmp(const String *s,const String
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@ String *copy_if_not_alloced(String *to,S
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuarp mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-01-15 17:14:35.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-01-31 22:38:33.000000000 +0000
-@@ -1202,7 +1202,7 @@ void _db_dump_(uint _line_, const char *
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@ static void Indent(CODE_STATE *cs, int i
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuarp mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-01-15 17:14:37.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-01-31 22:38:33.000000000 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@ int read_file(SSL_CTX* ctx, const char*
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuarp mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-01-15 17:14:39.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-01-31 22:38:33.000000000 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@ void DH::GenerateKeyPair(RandomNumberGen
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuarp mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-01-15 17:14:40.000000000 +0000
-+++ mysql/include/my_global.h 2010-01-31 22:38:33.000000000 +0000
-@@ -572,10 +572,8 @@ int __void__;
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuarp mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-01-15 17:14:43.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-01-31 22:38:33.000000000 +0000
-@@ -1572,7 +1572,7 @@ void my_net_local_init(NET *net)
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3605,7 +3605,7 @@ static void fetch_string_with_conversion
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3838,9 +3838,9 @@ static void fetch_float_with_conversion(
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4158,7 +4158,7 @@ static void fetch_result_bin(MYSQL_BIND
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4170,7 +4170,7 @@ static void fetch_result_str(MYSQL_BIND
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuarp mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-01-15 17:14:43.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -824,7 +824,7 @@ write_eof_packet(THD *thd, uint server_s
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuarp mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-01-15 17:16:29.000000000 +0000
-+++ mysql/mysys/array.c 2010-01-31 22:38:33.000000000 +0000
-@@ -47,7 +47,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRA
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@ void delete_dynamic_element(DYNAMIC_ARRA
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuarp mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-01-15 17:16:29.000000000 +0000
-+++ mysql/mysys/default.c 2010-01-31 22:38:33.000000000 +0000
-@@ -793,7 +793,7 @@ static int search_default_file_with_ext(
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuarp mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-01-31 22:38:33.000000000 +0000
-@@ -83,7 +83,7 @@ char * fn_format(char * to, const char *
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuarp mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-01-31 22:38:33.000000000 +0000
-@@ -1097,7 +1097,7 @@ static void copy_to_read_buffer(IO_CACHE
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@ read_append_buffer:
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@ int _my_b_async_read(register IO_CACHE *
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@ int _my_b_async_read(register IO_CACHE *
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuarp mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-01-31 22:38:33.000000000 +0000
-@@ -196,7 +196,7 @@ void *alloc_root(MEM_ROOT *mem_root, siz
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuarp mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-01-31 22:38:33.000000000 +0000
-@@ -365,7 +365,7 @@ void bitmap_intersect(MY_BITMAP *map, co
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuarp mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-01-31 22:38:33.000000000 +0000
-@@ -244,7 +244,7 @@ int unpackfrm(uchar **unpack_data, size_
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuarp mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-01-31 22:38:33.000000000 +0000
-@@ -165,13 +165,13 @@ char* my_cgets(char *buffer, size_t clen
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuarp mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-01-31 22:38:33.000000000 +0000
-@@ -75,7 +75,7 @@ static uint set_max_open_files(uint max_
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@ uint my_set_max_open_files(uint files)
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@ uint my_set_max_open_files(uint files)
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuarp mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-01-31 22:38:33.000000000 +0000
-@@ -973,7 +973,7 @@ static double getopt_double(char *arg, c
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuarp mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-01-15 17:16:30.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-01-31 22:38:33.000000000 +0000
-@@ -38,7 +38,7 @@ int ha_compare_text(CHARSET_INFO *charse
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@ int ha_key_cmp(register HA_KEYSEG *keyse
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuarp mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-01-15 17:16:31.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-01-31 22:38:33.000000000 +0000
-@@ -238,7 +238,7 @@ void *_myrealloc(register void *ptr, reg
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuarp mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-01-15 17:16:31.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-01-31 22:38:33.000000000 +0000
-@@ -229,7 +229,7 @@ void my_print_stacktrace(uchar* stack_bo
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuarp mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-01-15 17:16:33.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -83,8 +83,8 @@ int Buffer::reserve(size_t position, siz
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuarp mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-01-15 17:16:33.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -103,7 +103,7 @@ void Listener::run()
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuarp mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-01-15 17:16:34.000000000 +0000
-+++ mysql/sql/field.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -54,7 +54,7 @@ const char field_separator=',';
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2071,7 +2071,7 @@ int Field_decimal::store(const char *fro
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2079,7 +2079,7 @@ int Field_decimal::store(const char *fro
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -3089,7 +3089,7 @@ String *Field_tiny::val_str(String *val_
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3301,7 +3301,7 @@ String *Field_short::val_str(String *val
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3518,7 +3518,7 @@ String *Field_medium::val_str(String *va
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3737,7 +3737,7 @@ String *Field_long::val_str(String *val_
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3978,7 +3978,7 @@ String *Field_longlong::val_str(String *
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4201,7 +4201,7 @@ String *Field_float::val_str(String *val
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4559,7 +4559,7 @@ String *Field_double::val_str(String *va
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6453,13 +6453,13 @@ int Field_str::store(double nr)
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6467,7 +6467,7 @@ int Field_str::store(double nr)
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6724,7 +6724,7 @@ uchar *Field_string::pack(uchar *to, con
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7719,7 +7719,7 @@ int Field_blob::store(const char *from,u
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7879,7 +7879,7 @@ int Field_blob::cmp_binary(const uchar *
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -9110,7 +9110,7 @@ String *Field_bit::val_str(String *val_b
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9196,7 +9196,7 @@ uint Field_bit::get_key_image(uchar *buf
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9313,7 +9313,7 @@ Field_bit::pack(uchar *to, const uchar *
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9769,7 +9769,7 @@ bool Create_field::init(THD *thd, char *
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuarp mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-01-15 17:16:34.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -191,7 +191,7 @@ ha_rows filesort(THD *thd, TABLE *table,
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -213,12 +213,12 @@ ha_rows filesort(THD *thd, TABLE *table,
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1113,7 +1113,7 @@ uint read_to_buffer(IO_CACHE *fromfile,
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1376,7 +1376,7 @@ int merge_buffers(SORTPARAM *param, IO_C
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuarp mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-01-15 17:16:34.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -800,7 +800,7 @@ int ha_ndbcluster::set_ndb_value(NdbOper
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuarp mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-01-15 17:16:34.000000000 +0000
-+++ mysql/sql/handler.h 2010-01-31 22:38:33.000000000 +0000
-@@ -1598,15 +1598,15 @@ public:
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuarp mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -74,7 +74,7 @@ void
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -443,9 +443,9 @@ uint Item::decimal_precision() const
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -739,7 +739,7 @@ void Item::set_name(const char *str, uin
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5347,7 +5347,7 @@ longlong Item_hex_string::val_int()
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -7501,7 +7501,7 @@ bool Item_type_holder::join_types(THD *t
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7523,7 +7523,7 @@ bool Item_type_holder::join_types(THD *t
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7541,7 +7541,7 @@ bool Item_type_holder::join_types(THD *t
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuarp mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -58,7 +58,7 @@ Cached_item::~Cached_item() {}
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@ bool Cached_item_str::cmp(void)
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuarp mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -628,7 +628,7 @@ int Arg_comparator::set_compare_func(Ite
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1303,7 +1303,7 @@ int Arg_comparator::compare_binary_strin
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2355,7 +2355,7 @@ Item_func_ifnull::fix_length_and_dec()
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2366,10 +2366,10 @@ Item_func_ifnull::fix_length_and_dec()
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2393,9 +2393,9 @@ uint Item_func_ifnull::decimal_precision
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2523,7 +2523,7 @@ void
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2567,10 +2567,10 @@ Item_func_if::fix_length_and_dec()
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2578,8 +2578,8 @@ uint Item_func_if::decimal_precision() c
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2987,7 +2987,7 @@ uint Item_func_case::decimal_precision()
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4877,7 +4877,7 @@ void Item_func_like::turboBM_compute_suf
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4896,7 +4896,7 @@ void Item_func_like::turboBM_compute_suf
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5017,14 +5017,14 @@ bool Item_func_like::turboBM_matches(con
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5048,14 +5048,14 @@ bool Item_func_like::turboBM_matches(con
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuarp mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -540,7 +540,7 @@ void Item_func::count_decimal_length()
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@ my_decimal *Item_func_plus::decimal_op(m
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@ void Item_func_mul::result_precision()
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@ my_decimal *Item_func_div::decimal_op(my
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@ void Item_func_div::result_precision()
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@ void Item_func_div::fix_length_and_dec()
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@ my_decimal *Item_func_mod::decimal_op(my
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@ void Item_func_round::fix_length_and_dec
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@ void Item_func_round::fix_length_and_dec
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@ void Item_func_round::fix_length_and_dec
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@ my_decimal *Item_func_round::decimal_op(
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2954,7 +2954,7 @@ udf_handler::fix_fields(THD *thd, Item_r
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2963,7 +2963,7 @@ udf_handler::fix_fields(THD *thd, Item_r
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuarp mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -1225,7 +1225,7 @@ String *Item_func_substr::val_str(String
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1245,7 +1245,7 @@ void Item_func_substr::fix_length_and_de
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1937,7 +1937,7 @@ String *Item_func_soundex::val_str(Strin
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3068,11 +3068,11 @@ String* Item_func_export_set::val_str(St
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -Nuarp mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -1161,7 +1161,7 @@ Item_sum_avg_distinct::fix_length_and_de
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@ void Item_sum_avg::fix_length_and_dec()
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@ void Item_sum_variance::fix_length_and_d
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3348,7 +3348,7 @@ bool Item_func_group_concat::setup(THD *
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuarp mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -308,14 +308,14 @@ static bool extract_date_time(DATE_TIME_
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@ static bool extract_date_time(DATE_TIME_
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@ static bool extract_date_time(DATE_TIME_
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@ static bool extract_date_time(DATE_TIME_
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@ static bool extract_date_time(DATE_TIME_
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@ static bool extract_date_time(DATE_TIME_
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@ static bool extract_date_time(DATE_TIME_
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@ static bool extract_date_time(DATE_TIME_
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@ static bool extract_date_time(DATE_TIME_
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1829,7 +1829,7 @@ void Item_func_date_format::fix_length_a
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuarp mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-01-15 17:17:27.000000000 +0000
-+++ mysql/sql/key.cc 2010-01-31 22:38:33.000000000 +0000
-@@ -125,13 +125,13 @@ void key_copy(uchar *to_key, uchar *from
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@ void key_restore(uchar *to_record, uchar
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@ void key_restore(uchar *to_record, uchar
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@ bool key_cmp_if_same(TABLE *table,const
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@ void key_unpack(String *to,TABLE *table,
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuarp mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-01-15 17:17:28.000000000 +0000
-+++ mysql/sql/log.cc 2010-01-31 22:39:44.000000000 +0000
-@@ -597,11 +597,11 @@ bool Log_to_csv_event_handler::
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2420,7 +2420,7 @@ const char *MYSQL_LOG::generate_name(con
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5091,7 +5091,7 @@ static void print_buffer_to_nt_eventlog(
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuarp mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-01-15 17:17:28.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1070,7 +1070,7 @@ Log_event* Log_event::read_log_event(IO_
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -5443,7 +5443,7 @@ bool User_var_log_event::write(IO_CACHE*
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7167,7 +7167,7 @@ int Rows_log_event::do_add_row_data(ucha
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuarp mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-01-15 17:17:28.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -3317,7 +3317,7 @@ static int init_common_variables(const c
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3329,15 +3329,15 @@ static int init_common_variables(const c
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5014,7 +5014,7 @@ pthread_handler_t handle_connections_soc
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuarp mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-01-15 17:17:28.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -756,7 +756,7 @@ static my_bool my_net_skip_rest(NET *net
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@ my_real_read(NET *net, size_t *complen)
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuarp mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-01-15 17:17:28.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -2353,7 +2353,7 @@ int SQL_SELECT::test_quick_select(THD *t
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3829,7 +3829,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7473,7 +7473,7 @@ check_quick_select(PARAM *param,uint idx
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7542,7 +7542,7 @@ check_quick_keys(PARAM *param, uint idx,
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8457,13 +8457,13 @@ int QUICK_RANGE_SELECT::reset()
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8482,7 +8482,7 @@ int QUICK_RANGE_SELECT::reset()
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8565,7 +8565,7 @@ int QUICK_RANGE_SELECT::get_next()
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8678,13 +8678,13 @@ int QUICK_RANGE_SELECT::get_next_prefix(
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -9293,7 +9293,7 @@ cost_group_min_max(TABLE* table, KEY *in
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9519,7 +9519,7 @@ get_best_group_min_max(PARAM *param, SEL
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10155,9 +10155,9 @@ void cost_group_min_max(TABLE* table, KE
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuarp mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -167,7 +167,7 @@ net_send_ok(THD *thd,
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@ static bool write_eof_packet(THD *thd, N
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuarp mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -283,7 +283,7 @@ unpack_row(Relay_log_info const *rli,
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuarp mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -686,7 +686,7 @@ int Relay_log_info::wait_for_pos(THD* th
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@ int Relay_log_info::wait_for_pos(THD* th
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuarp mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -180,7 +180,7 @@ table_def::compatible_with(Relay_log_inf
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuarp mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1862,7 +1862,7 @@ bool sys_var::check_set(THD *thd, set_va
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -Nuarp mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/slave.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1710,7 +1710,7 @@ bool show_master_info(THD* thd, Master_i
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2327,7 +2327,7 @@ static int exec_relay_log_event(THD* thd
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -3985,7 +3985,7 @@ static IO_CACHE *reopen_relay_log(Relay_
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuarp mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -2428,7 +2428,7 @@ sp_head::show_create_routine(THD *thd, i
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2629,7 +2629,7 @@ sp_head::show_routine_code(THD *thd)
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuarp mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-01-15 17:17:29.000000000 +0000
-+++ mysql/sql/spatial.h 2010-01-31 22:38:34.000000000 +0000
-@@ -180,8 +180,8 @@ struct MBR
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuarp mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -818,7 +818,7 @@ static ulong get_sort(uint count,...)
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuarp mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -280,16 +280,16 @@ bool get_ev_num_info(EV_NUM_INFO *ev_inf
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@ String *field_decimal::avg(String *s, ha
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@ String *field_decimal::std(String *s, ha
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@ bool analyse::change_columns(List<Item>
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuarp mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1004,7 +1004,7 @@ void query_cache_end_of_result(THD *thd)
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2373,7 +2373,7 @@ Query_cache::write_block_data(ulong data
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2428,7 +2428,7 @@ Query_cache::append_result_data(Query_ca
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2456,7 +2456,7 @@ Query_cache::append_result_data(Query_ca
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2544,8 +2544,8 @@ inline ulong Query_cache::get_min_first_
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2577,7 +2577,7 @@ my_bool Query_cache::allocate_data_chain
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2586,7 +2586,7 @@ my_bool Query_cache::allocate_data_chain
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3009,7 +3009,7 @@ Query_cache::allocate_block(ulong len, m
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuarp mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -383,7 +383,7 @@ char *thd_security_context(THD *thd, cha
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -2020,7 +2020,7 @@ bool select_export::send_data(List<Item>
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuarp mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -34,7 +34,7 @@ void my_net_local_init(NET *net)
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuarp mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -670,7 +670,7 @@ static int check_connection(THD *thd)
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuarp mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1095,7 +1095,7 @@ READ_INFO::READ_INFO(File file_par, uint
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuarp mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -5592,7 +5592,7 @@ bool check_stack_overrun(THD *thd, long
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7085,7 +7085,7 @@ bool check_simple_select()
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuarp mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-01-15 17:17:30.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -4556,7 +4556,7 @@ that are reorganised.
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuarp mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-01-31 22:40:15.000000000 +0000
-@@ -486,7 +486,7 @@ static st_plugin_dl *plugin_dl_add(const
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2084,7 +2084,7 @@ static int check_func_set(THD *thd, stru
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuarp mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -249,7 +249,7 @@ static bool send_prep_stmt(Prepared_stat
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuarp mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1253,12 +1253,12 @@ bool change_master(THD* thd, Master_info
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1420,7 +1420,7 @@ bool mysql_show_binlog_events(THD* thd)
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -Nuarp mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -2876,7 +2876,7 @@ make_join_statistics(JOIN *join, TABLE_L
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3790,7 +3790,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3813,7 +3813,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -3972,7 +3972,7 @@ static void optimize_keyuse(JOIN *join,
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4292,7 +4292,7 @@ best_access_path(JOIN *join,
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4459,7 +4459,7 @@ best_access_path(JOIN *join,
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5404,7 +5404,7 @@ static void calc_used_field_length(THD *
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10253,7 +10253,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -14022,7 +14022,7 @@ SORT_FIELD *make_unireg_sortorder(ORDER
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14144,7 +14144,7 @@ join_init_cache(THD *thd,JOIN_TAB *table
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuarp mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -747,7 +747,7 @@ mysqld_show_create(THD *thd, TABLE_LIST
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -758,7 +758,7 @@ mysqld_show_create(THD *thd, TABLE_LIST
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1866,7 +1866,7 @@ void mysqld_list_processes(THD *thd,cons
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1995,7 +1995,7 @@ int fill_schema_processlist(THD* thd, TA
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -6978,7 +6978,7 @@ static bool show_create_trigger_impl(THD
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuarp mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -661,7 +661,7 @@ int String::reserve(uint32 space_needed,
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@ int sortcmp(const String *s,const String
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@ String *copy_if_not_alloced(String *to,S
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@ well_formed_copy_nchars(CHARSET_INFO *to
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -Nuarp mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -3215,7 +3215,7 @@ mysql_prepare_create_table(THD *thd, HA_
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuarp mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-01-15 17:36:29.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -16222,7 +16222,7 @@ yyreduce:
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16242,7 +16242,7 @@ yyreduce:
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuarp mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-01-31 22:38:34.000000000 +0000
-@@ -1805,7 +1805,7 @@ master_file_def:
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@ master_file_def:
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuarp mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -126,7 +126,7 @@ char *sql_strmake_with_convert(const cha
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuarp mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-01-15 17:17:31.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -167,7 +167,7 @@ tz_load(const char *name, TIME_ZONE_INFO
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@ tz_load_from_open_tables(const String *t
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuarp mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-01-15 17:17:32.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -490,7 +490,7 @@ static uchar *pack_screens(List<Create_f
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@ static bool pack_header(uchar *forminfo,
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuarp mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-01-15 17:17:32.000000000 +0000
-+++ mysql/sql-common/client.c 2010-01-31 22:38:34.000000000 +0000
-@@ -728,7 +728,7 @@ cli_safe_read(MYSQL *mysql)
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuarp mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-01-15 17:17:33.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-01-31 22:38:34.000000000 +0000
-@@ -249,7 +249,7 @@ str_to_datetime(const char *str, uint le
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuarp mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-01-15 17:17:33.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1185,7 +1185,7 @@ bool ha_tina::get_write_pos(my_off_t *en
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1421,7 +1421,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_O
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuarp mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-01-15 17:17:33.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -546,7 +546,7 @@ static int parse_url_error(FEDERATED_SHA
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@ bool ha_federated::create_where_from_key
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuarp mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-01-15 17:17:33.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-01-31 22:38:34.000000000 +0000
-@@ -229,7 +229,7 @@ static void init_block(HP_BLOCK *block,
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuarp mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-01-15 17:17:33.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-01-31 22:38:34.000000000 +0000
-@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuarp mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-01-15 17:17:39.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -1511,7 +1511,7 @@ void ha_myisam::start_bulk_insert(ha_row
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuarp mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-01-15 17:17:39.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-01-31 22:38:34.000000000 +0000
-@@ -61,7 +61,7 @@ int _mi_read_cache(IO_CACHE *info, uchar
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuarp mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-01-15 17:17:39.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-01-31 22:38:34.000000000 +0000
-@@ -2170,7 +2170,7 @@ int filecopy(MI_CHECK *param, File to,Fi
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@ int mi_repair_by_sort(MI_CHECK *param, r
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2780,7 +2780,7 @@ int mi_repair_parallel(MI_CHECK *param,
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4329,7 +4329,7 @@ int recreate_table(MI_CHECK *param, MI_I
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuarp mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-01-31 22:38:34.000000000 +0000
-@@ -439,8 +439,8 @@ int mi_create(const char *name,uint keys
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@ int mi_create(const char *name,uint keys
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@ int mi_create(const char *name,uint keys
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuarp mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-01-31 22:38:34.000000000 +0000
-@@ -850,7 +850,7 @@ static int update_dynamic_record(MI_INFO
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuarp mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-01-31 22:38:34.000000000 +0000
-@@ -99,7 +99,7 @@ int mi_extra(MI_INFO *info, enum ha_extr
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuarp mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-01-31 22:38:34.000000000 +0000
-@@ -328,7 +328,7 @@ MI_INFO *mi_open(const char *name, int m
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@ MI_INFO *mi_open(const char *name, int m
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -711,10 +711,10 @@ uchar *mi_alloc_rec_buff(MI_INFO *info,
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuarp mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-01-31 22:38:34.000000000 +0000
-@@ -684,7 +684,7 @@ static uint find_longest_bitstream(uint1
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@ uint _mi_pack_get_block_info(MI_INFO *my
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuarp mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-01-31 22:38:34.000000000 +0000
-@@ -435,7 +435,7 @@ static void create_record(uchar *record,
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuarp mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-01-31 22:38:34.000000000 +0000
-@@ -601,7 +601,7 @@ int main(int argc, char *argv[])
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -Nuarp mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-01-31 22:38:34.000000000 +0000
-@@ -90,7 +90,7 @@ int main(int argc, char **argv)
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuarp mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-01-31 22:38:34.000000000 +0000
-@@ -1239,7 +1239,7 @@ static void check_counts(HUFF_COUNTS *hu
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@ static int save_state_mrg(File file,PACK
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuarp mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-01-31 22:38:34.000000000 +0000
-@@ -325,8 +325,8 @@ int rtree_d_mbr(HA_KEYSEG *keyseg, uchar
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@ int rtree_d_mbr(HA_KEYSEG *keyseg, uchar
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@ int rtree_combine_rect(HA_KEYSEG *keyseg
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@ int rtree_combine_rect(HA_KEYSEG *keyseg
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@ double rtree_overlapping_area(HA_KEYSEG
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@ double rtree_overlapping_area(HA_KEYSEG
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@ safe_end:
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@ safe_end:
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuarp mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-01-31 22:38:34.000000000 +0000
-@@ -131,7 +131,7 @@ int _create_index_by_sort(MI_SORT_PARAM
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl=max(sortbuff_size,MIN_SORT_MEMORY);
-+ memavl=MYSQL_MAX(sortbuff_size,MIN_SORT_MEMORY);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@ pthread_handler_t thr_find_all_keys(void
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_MEMORY);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_MEMORY);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@ static uint NEAR_F read_to_buffer(IO_CAC
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@ static uint NEAR_F read_to_buffer_varlen
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuarp mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-01-15 17:17:40.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-01-31 22:38:34.000000000 +0000
-@@ -930,7 +930,7 @@ int ha_myisammrg::info(uint flag)
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuarp mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-01-15 17:17:45.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-01-31 22:38:34.000000000 +0000
-@@ -30,7 +30,7 @@ Ndb_getInAddr(struct in_addr * dst, cons
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuarp mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-01-15 17:17:48.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-01-31 22:38:34.000000000 +0000
-@@ -212,7 +212,7 @@ Dbtux::printNode(Frag& frag, NdbOut& out
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuarp mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-01-15 17:17:50.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-01-31 22:38:34.000000000 +0000
-@@ -1523,7 +1523,7 @@ NdbBlob::prepareColumn()
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuarp mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-01-15 17:17:52.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-01-31 22:38:34.000000000 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@ operator<<(NdbOut& out, const Range& ran
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@ Range::rowcount() const
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuarp mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-01-15 17:17:53.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-01-31 22:38:34.000000000 +0000
-@@ -65,8 +65,8 @@ strlcat (char *dst, const char *src, siz
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@ arg_printusage (struct getargs *args,
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuarp mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-01-31 22:38:34.000000000 +0000
-@@ -253,7 +253,7 @@ static int my_strnncoll_big5(CHARSET_INF
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@ static int my_strnncollsp_big5(CHARSET_I
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuarp mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-01-31 22:38:34.000000000 +0000
-@@ -80,7 +80,7 @@ static int my_strnncoll_binary(CHARSET_I
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@ static int my_strnncoll_8bit_bin(CHARSET
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@ static int my_strnncollsp_8bit_bin(CHARS
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@ static size_t my_strnxfrm_bin(CHARSET_IN
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@ size_t my_strnxfrm_8bit_bin(CHARSET_INFO
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuarp mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-01-31 22:38:34.000000000 +0000
-@@ -2616,7 +2616,7 @@ int my_strnncoll_gbk(CHARSET_INFO *cs __
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@ static int my_strnncollsp_gbk(CHARSET_IN
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuarp mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-01-31 22:38:34.000000000 +0000
-@@ -368,7 +368,7 @@ static int my_strnncoll_mb_bin(CHARSET_I
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@ static int my_strnncollsp_mb_bin(CHARSET
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@ static size_t my_strnxfrm_mb_bin(CHARSET
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuarp mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-01-31 22:38:34.000000000 +0000
-@@ -159,7 +159,7 @@ int my_strnncollsp_simple(CHARSET_INFO *
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@ size_t my_long10_to_str_8bit(CHARSET_INF
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@ size_t my_longlong10_to_str_8bit(CHARSET
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@ size_t my_well_formed_len_8bit(CHARSET_I
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuarp mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-01-15 17:17:54.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-01-31 22:38:34.000000000 +0000
-@@ -581,7 +581,7 @@ int my_strnncollsp_tis620(CHARSET_INFO *
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@ size_t my_strnxfrm_tis620(CHARSET_INFO *
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuarp mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-01-31 22:38:34.000000000 +0000
-@@ -7567,7 +7567,7 @@ static void my_coll_lexem_print_error(MY
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuarp mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-01-31 22:38:34.000000000 +0000
-@@ -279,7 +279,7 @@ static int my_strnncollsp_ucs2(CHARSET_I
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@ size_t my_well_formed_len_ucs2(CHARSET_I
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@ static int my_strnncollsp_ucs2_bin(CHARS
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@ size_t my_strnxfrm_ucs2_bin(CHARSET_INFO
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuarp mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-01-31 22:38:34.000000000 +0000
-@@ -1937,7 +1937,7 @@ static inline int bincmp(const uchar *s,
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuarp mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/decimal.c 2010-01-31 22:38:34.000000000 +0000
-@@ -403,7 +403,7 @@ int decimal2string(decimal_t *from, char
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@ int decimal2string(decimal_t *from, char
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@ decimal_round(decimal_t *from, decimal_t
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@ decimal_round(decimal_t *from, decimal_t
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@ decimal_round(decimal_t *from, decimal_t
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@ decimal_round(decimal_t *from, decimal_t
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@ int decimal_result_size(decimal_t *from1
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@ static int do_add(decimal_t *from1, deci
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@ static int do_add(decimal_t *from1, deci
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@ static int do_add(decimal_t *from1, deci
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@ static int do_sub(decimal_t *from1, deci
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@ static int do_sub(decimal_t *from1, deci
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@ static int do_sub(decimal_t *from1, deci
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@ static int do_div_mod(decimal_t *from1,
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@ static int do_div_mod(decimal_t *from1,
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@ static int do_div_mod(decimal_t *from1,
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuarp mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-01-31 22:38:34.000000000 +0000
-@@ -141,7 +141,7 @@ size_t my_vsnprintf(char *to, size_t n,
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuarp mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-01-15 17:17:55.000000000 +0000
-+++ mysql/strings/str2int.c 2010-01-31 22:38:34.000000000 +0000
-@@ -82,7 +82,7 @@ char *str2int(register const char *src,
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuarp mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-01-31 22:20:05.000000000 +0000
-+++ mysql/tests/mysql_client_test.c 2010-01-31 22:38:34.000000000 +0000
-@@ -610,7 +610,7 @@ static int my_process_stmt_result(MYSQL_
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuarp mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-01-15 17:17:56.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-01-31 22:38:34.000000000 +0000
-@@ -69,7 +69,7 @@ size_t vio_read_buff(Vio *vio, uchar* bu
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.46.patch b/07110_all_mysql_gcc-4.2_5.1.46.patch
deleted file mode 100644
index 0033e3a..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.46.patch
+++ /dev/null
@@ -1,3444 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-04-25 20:07:20.950488097 +0000
-@@ -1946,7 +1946,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysql.cc 2010-04-25 20:07:20.950488097 +0000
-@@ -3310,9 +3310,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3332,7 +3332,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-04-25 20:07:20.953406902 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4508,7 +4508,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-04-25 20:07:20.957153743 +0000
-@@ -5496,9 +5496,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-04-25 20:07:20.950488097 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-04-25 20:07:20.960487004 +0000
-@@ -659,7 +659,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-04-06 14:03:57.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-04-25 20:07:20.960487004 +0000
-@@ -1202,7 +1202,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-04-06 14:03:59.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-04-25 20:07:20.960487004 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-04-06 14:04:01.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-04-25 20:07:20.960487004 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-04-06 14:04:02.000000000 +0000
-+++ mysql/include/my_global.h 2010-04-25 20:07:20.960487004 +0000
-@@ -572,10 +572,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-04-06 14:04:05.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-04-25 20:07:20.963820366 +0000
-@@ -1573,7 +1573,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3606,7 +3606,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3839,9 +3839,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4159,7 +4159,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4171,7 +4171,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-04-06 14:04:05.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-04-25 20:07:20.963820366 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/array.c 2010-04-25 20:07:20.963820366 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/default.c 2010-04-25 20:07:20.963820366 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-04-25 20:07:20.963820366 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-04-25 20:07:20.963820366 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-04-25 20:07:20.967153626 +0000
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-04-25 20:07:20.967153626 +0000
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-04-25 20:07:20.967153626 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-04-25 20:07:20.967153626 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-04-25 20:07:20.967153626 +0000
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-04-25 20:07:20.967153626 +0000
-@@ -982,7 +982,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-04-25 20:07:20.967153626 +0000
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-04-25 20:07:20.967153626 +0000
-@@ -238,7 +238,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-04-06 14:06:03.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-04-25 20:07:20.967153626 +0000
-@@ -229,7 +229,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-04-06 14:06:04.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-04-25 20:07:20.967153626 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-04-25 20:07:20.967153626 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/sql/field.cc 2010-04-25 20:07:20.972988760 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4561,7 +4561,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6455,13 +6455,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6469,7 +6469,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6727,7 +6727,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7721,7 +7721,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7881,7 +7881,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9782,7 +9782,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-04-25 20:07:20.972988760 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1115,7 +1115,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1378,7 +1378,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-04-25 20:07:20.976321930 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/handler.h 2010-04-25 20:07:20.976321930 +0000
-@@ -1598,15 +1598,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -58,7 +58,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -443,9 +443,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -751,7 +751,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5384,7 +5384,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -7558,7 +7558,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7580,7 +7580,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7598,7 +7598,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1312,7 +1312,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2364,7 +2364,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2375,10 +2375,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2402,9 +2402,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2532,7 +2532,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2576,10 +2576,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2587,8 +2587,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2996,7 +2996,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4886,7 +4886,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4905,7 +4905,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5026,14 +5026,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5057,14 +5057,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -540,7 +540,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2954,7 +2954,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2963,7 +2963,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -1226,7 +1226,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1246,7 +1246,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1938,7 +1938,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3069,11 +3069,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -1161,7 +1161,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3348,7 +3348,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1829,7 +1829,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/key.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/log.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2427,7 +2427,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5106,7 +5106,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-04-25 20:07:20.989655096 +0000
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -5483,7 +5483,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7207,7 +7207,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-04-25 20:07:20.992988421 +0000
-@@ -3319,7 +3319,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3331,15 +3331,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5016,7 +5016,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-04-25 20:07:20.992988421 +0000
-@@ -756,7 +756,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-04-25 20:07:20.996321704 +0000
-@@ -2346,7 +2346,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3822,7 +3822,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7466,7 +7466,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7535,7 +7535,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8450,13 +8450,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8475,7 +8475,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8558,7 +8558,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -8671,13 +8671,13 @@
- last_range= *(cur_range++);
-
- start_key.key= (const uchar*) last_range->min_key;
-- start_key.length= min(last_range->min_length, prefix_length);
-+ start_key.length= MYSQL_MIN(last_range->min_length, prefix_length);
- start_key.keypart_map= last_range->min_keypart_map & keypart_map;
- start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
- (last_range->flag & EQ_RANGE) ?
- HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
- end_key.key= (const uchar*) last_range->max_key;
-- end_key.length= min(last_range->max_length, prefix_length);
-+ end_key.length= MYSQL_MIN(last_range->max_length, prefix_length);
- end_key.keypart_map= last_range->max_keypart_map & keypart_map;
- /*
- We use READ_AFTER_KEY here because if we are reading on a key
-@@ -9286,7 +9286,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9512,7 +9512,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10148,9 +10148,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-04-25 20:07:20.996321704 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -299,7 +299,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -1868,7 +1868,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/slave.cc 2010-04-25 20:07:21.002988206 +0000
-@@ -1728,7 +1728,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2345,7 +2345,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4013,7 +4013,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/spatial.h 2010-04-25 20:07:21.002988206 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-04-25 20:07:21.002988206 +0000
-@@ -2432,7 +2432,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2633,7 +2633,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -823,7 +823,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2373,7 +2373,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2428,7 +2428,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2456,7 +2456,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2544,8 +2544,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2577,7 +2577,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2586,7 +2586,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3009,7 +3009,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -383,7 +383,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -2019,7 +2019,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -670,7 +670,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -1097,7 +1097,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-04-25 20:07:21.012987995 +0000
-@@ -5602,7 +5602,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7097,7 +7097,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-04-25 20:07:21.012987995 +0000
-@@ -4567,7 +4567,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2086,7 +2086,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -1253,12 +1253,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1420,7 +1420,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-04-25 20:07:21.022988689 +0000
-@@ -2941,7 +2941,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3856,7 +3856,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3879,7 +3879,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4038,7 +4038,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4358,7 +4358,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4525,7 +4525,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5475,7 +5475,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10342,7 +10342,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -14147,7 +14147,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14269,7 +14269,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -747,7 +747,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -758,7 +758,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1865,7 +1865,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1996,7 +1996,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -6980,7 +6980,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -661,7 +661,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -3233,7 +3233,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-04-06 14:24:52.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-04-25 20:07:21.039655378 +0000
-@@ -16222,7 +16222,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16242,7 +16242,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-04-25 20:07:21.042990770 +0000
-@@ -1805,7 +1805,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-04-25 20:07:21.042990770 +0000
-@@ -126,7 +126,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -490,7 +490,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/sql-common/client.c 2010-04-25 20:07:21.046321948 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-04-25 20:07:21.046321948 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -1197,7 +1197,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1433,7 +1433,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-04-25 20:07:21.049654675 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-04-06 14:07:08.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-04-25 20:07:21.049654675 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-04-06 14:07:08.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-04-25 20:07:21.049654675 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-04-25 20:07:21.049654675 +0000
-@@ -1519,7 +1519,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-04-25 20:07:21.049654675 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-04-25 20:07:21.052988146 +0000
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2779,7 +2779,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4328,7 +4328,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-04-25 20:07:21.052988146 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-04-25 20:07:21.052988146 +0000
-@@ -877,7 +877,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-04-25 20:07:21.052988146 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-04-25 20:07:21.052988146 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-04-25 20:07:21.052988146 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-04-25 20:07:21.056321316 +0000
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-04-25 20:07:21.056321316 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-04-25 20:07:21.056321316 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-04-25 20:07:21.056321316 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-04-25 20:07:21.056321316 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-04-25 20:08:50.909665886 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-04-25 20:07:21.059654704 +0000
-@@ -964,7 +964,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-04-06 14:07:19.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-04-06 14:07:23.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-04-06 14:07:25.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-04-06 14:07:27.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-04-06 14:07:28.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-04-25 20:07:21.059654704 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-04-25 20:07:21.062988678 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-04-25 20:07:21.062988678 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-04-25 20:07:21.066322554 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-04-25 20:07:21.066322554 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-04-25 20:07:21.066322554 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-04-25 20:07:21.069654767 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-04-25 20:07:21.072987987 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-04-25 20:07:21.072987987 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-04-25 20:07:21.072987987 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/decimal.c 2010-04-25 20:07:21.076321713 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-04-25 20:07:21.076321713 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/str2int.c 2010-04-25 20:07:21.076321713 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-04-25 20:05:57.344286576 +0000
-+++ mysql/tests/mysql_client_test.c 2010-04-25 20:07:21.079655912 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-04-06 14:07:31.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-04-25 20:07:21.079655912 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.49.patch b/07110_all_mysql_gcc-4.2_5.1.49.patch
deleted file mode 100644
index 68adc5d..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.49.patch
+++ /dev/null
@@ -1,3428 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-04-25 20:07:20.950488097 +0000
-@@ -1946,7 +1946,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysql.cc 2010-04-25 20:07:20.950488097 +0000
-@@ -3310,9 +3310,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3332,7 +3332,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-04-25 20:07:20.953406902 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4508,7 +4508,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-04-25 20:07:20.957153743 +0000
-@@ -5496,9 +5496,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-04-06 14:03:48.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-04-25 20:07:20.950488097 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-04-06 14:03:49.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-04-25 20:07:20.960487004 +0000
-@@ -659,7 +659,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -745,7 +745,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -762,7 +762,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-04-06 14:03:57.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-04-25 20:07:20.960487004 +0000
-@@ -1202,7 +1202,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1687,7 +1687,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-04-06 14:03:59.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-04-25 20:07:20.960487004 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-04-06 14:04:01.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-04-25 20:07:20.960487004 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-04-06 14:04:02.000000000 +0000
-+++ mysql/include/my_global.h 2010-04-25 20:07:20.960487004 +0000
-@@ -572,10 +572,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-04-06 14:04:05.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-04-25 20:07:20.963820366 +0000
-@@ -1573,7 +1573,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3606,7 +3606,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3839,9 +3839,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4159,7 +4159,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4171,7 +4171,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-04-06 14:04:05.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-04-25 20:07:20.963820366 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/array.c 2010-04-25 20:07:20.963820366 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/default.c 2010-04-25 20:07:20.963820366 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-04-25 20:07:20.963820366 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-04-06 14:06:01.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-04-25 20:07:20.963820366 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-04-25 20:07:20.967153626 +0000
-@@ -196,7 +196,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-04-25 20:07:20.967153626 +0000
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-04-25 20:07:20.967153626 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-04-25 20:07:20.967153626 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-04-25 20:07:20.967153626 +0000
-@@ -75,7 +75,7 @@
- static int set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-04-25 20:07:20.967153626 +0000
-@@ -982,7 +982,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-04-25 20:07:20.967153626 +0000
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-04-06 14:06:02.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-04-25 20:07:20.967153626 +0000
-@@ -238,7 +238,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-04-06 14:06:03.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-04-25 20:07:20.967153626 +0000
-@@ -229,7 +229,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-04-06 14:06:04.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-04-25 20:07:20.967153626 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-04-25 20:07:20.967153626 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/sql/field.cc 2010-04-25 20:07:20.972988760 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4561,7 +4561,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6455,13 +6455,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6469,7 +6469,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6727,7 +6727,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7721,7 +7721,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7881,7 +7881,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9782,7 +9782,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-04-06 14:06:05.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-04-25 20:07:20.972988760 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1115,7 +1115,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1378,7 +1378,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-04-25 20:07:20.976321930 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/handler.h 2010-04-25 20:07:20.976321930 +0000
-@@ -1598,15 +1598,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -58,7 +58,7 @@
- */
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
-- :item(arg), value(min(arg->max_length, thd->variables.max_sort_length))
-+ :item(arg), value(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length))
- {}
-
- bool Cached_item_str::cmp(void)
-@@ -67,7 +67,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value.alloced_length()));
-+ res->length(MYSQL_MIN(res->length(), value.alloced_length()));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -443,9 +443,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -751,7 +751,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5384,7 +5384,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -7558,7 +7558,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7580,7 +7580,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7598,7 +7598,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-04-06 14:06:06.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-04-25 20:07:20.979654875 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1312,7 +1312,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2364,7 +2364,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2375,10 +2375,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2402,9 +2402,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2532,7 +2532,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2576,10 +2576,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2587,8 +2587,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2996,7 +2996,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4886,7 +4886,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4905,7 +4905,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5026,14 +5026,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5057,14 +5057,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -540,7 +540,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2954,7 +2954,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2963,7 +2963,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -1226,7 +1226,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1246,7 +1246,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1938,7 +1938,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3069,11 +3069,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-04-25 20:07:20.982987686 +0000
-@@ -1161,7 +1161,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3348,7 +3348,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1829,7 +1829,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-04-06 14:07:01.000000000 +0000
-+++ mysql/sql/key.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/log.cc 2010-04-25 20:07:20.986321153 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2427,7 +2427,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5106,7 +5106,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-04-25 20:07:20.989655096 +0000
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -5483,7 +5483,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7207,7 +7207,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-04-25 20:07:20.992988421 +0000
-@@ -3319,7 +3319,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3331,15 +3331,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5016,7 +5016,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-04-25 20:07:20.992988421 +0000
-@@ -756,7 +756,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -941,7 +941,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-04-06 14:07:02.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-04-25 20:07:20.996321704 +0000
-@@ -2346,7 +2346,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3822,7 +3822,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7466,7 +7466,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7535,7 +7535,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8450,13 +8450,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8475,7 +8475,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8558,7 +8558,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9286,7 +9286,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9512,7 +9512,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10148,9 +10148,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-04-25 20:07:20.996321704 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -299,7 +299,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-04-25 20:07:20.999654037 +0000
-@@ -1868,7 +1868,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-04-06 14:07:03.000000000 +0000
-+++ mysql/sql/slave.cc 2010-04-25 20:07:21.002988206 +0000
-@@ -1728,7 +1728,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2345,7 +2345,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4013,7 +4013,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/spatial.h 2010-04-25 20:07:21.002988206 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-04-25 20:07:21.002988206 +0000
-@@ -2432,7 +2432,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2633,7 +2633,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -823,7 +823,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-04-25 20:07:21.006321357 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2373,7 +2373,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2428,7 +2428,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2456,7 +2456,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2544,8 +2544,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2577,7 +2577,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2586,7 +2586,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3009,7 +3009,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -383,7 +383,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -2019,7 +2019,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -670,7 +670,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-04-06 14:07:04.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-04-25 20:07:21.009654734 +0000
-@@ -1097,7 +1097,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-04-25 20:07:21.012987995 +0000
-@@ -5602,7 +5602,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7097,7 +7097,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-04-25 20:07:21.012987995 +0000
-@@ -4567,7 +4567,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2086,7 +2086,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-04-25 20:07:21.016321728 +0000
-@@ -1253,12 +1253,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1420,7 +1420,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-04-25 20:07:21.022988689 +0000
-@@ -2941,7 +2941,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3856,7 +3856,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3879,7 +3879,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4038,7 +4038,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4358,7 +4358,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4525,7 +4525,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5475,7 +5475,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10342,7 +10342,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -14147,7 +14147,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14269,7 +14269,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -747,7 +747,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -758,7 +758,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1865,7 +1865,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -1996,7 +1996,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -6980,7 +6980,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -661,7 +661,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -747,7 +747,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -764,7 +764,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -965,7 +965,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-04-06 14:07:05.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-04-25 20:07:21.026322542 +0000
-@@ -3233,7 +3233,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-04-06 14:24:52.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-04-25 20:07:21.039655378 +0000
-@@ -16222,7 +16222,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16242,7 +16242,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-04-25 20:07:21.042990770 +0000
-@@ -1805,7 +1805,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-04-25 20:07:21.042990770 +0000
-@@ -126,7 +126,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-04-06 14:07:06.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -490,7 +490,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -709,7 +709,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/sql-common/client.c 2010-04-25 20:07:21.046321948 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-04-25 20:07:21.046321948 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-04-25 20:07:21.046321948 +0000
-@@ -1197,7 +1197,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1433,7 +1433,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-04-06 14:07:07.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-04-25 20:07:21.049654675 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1294,7 +1294,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-04-06 14:07:08.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-04-25 20:07:21.049654675 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-04-06 14:07:08.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-04-25 20:07:21.049654675 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-04-25 20:07:21.049654675 +0000
-@@ -1519,7 +1519,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-04-25 20:07:21.049654675 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-04-25 20:07:21.052988146 +0000
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2779,7 +2779,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4328,7 +4328,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-04-06 14:07:14.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-04-25 20:07:21.052988146 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-04-25 20:07:21.052988146 +0000
-@@ -877,7 +877,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-04-25 20:07:21.052988146 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-04-25 20:07:21.052988146 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-04-25 20:07:21.052988146 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-04-25 20:07:21.056321316 +0000
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-04-25 20:07:21.056321316 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (bcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-04-25 20:07:21.056321316 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-04-25 20:07:21.056321316 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-04-25 20:07:21.056321316 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-04-25 20:08:50.909665886 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-04-06 14:07:15.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-04-25 20:07:21.059654704 +0000
-@@ -964,7 +964,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-04-06 14:07:19.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-04-06 14:07:23.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-04-06 14:07:25.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-04-06 14:07:27.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-04-25 20:07:21.059654704 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-04-06 14:07:28.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-04-25 20:07:21.059654704 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-04-25 20:07:21.062988678 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-04-25 20:07:21.062988678 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-04-25 20:07:21.066322554 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-04-25 20:07:21.066322554 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-04-06 14:07:29.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-04-25 20:07:21.066322554 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-04-25 20:07:21.069654767 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-04-25 20:07:21.072987987 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-04-25 20:07:21.072987987 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-04-25 20:07:21.072987987 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/decimal.c 2010-04-25 20:07:21.076321713 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-04-25 20:07:21.076321713 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-04-06 14:07:30.000000000 +0000
-+++ mysql/strings/str2int.c 2010-04-25 20:07:21.076321713 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-04-25 20:05:57.344286576 +0000
-+++ mysql/tests/mysql_client_test.c 2010-04-25 20:07:21.079655912 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-04-06 14:07:31.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-04-25 20:07:21.079655912 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.50.patch b/07110_all_mysql_gcc-4.2_5.1.50.patch
deleted file mode 100644
index 17a9d08..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.50.patch
+++ /dev/null
@@ -1,4070 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -1945,7 +1945,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -3326,9 +3326,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3348,7 +3348,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-08-20 22:20:26.958065154 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4508,7 +4508,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-08-20 22:20:26.958065154 +0000
-@@ -5496,9 +5496,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-08-20 22:20:26.958065154 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-08-20 22:20:26.961398610 +0000
-@@ -660,7 +660,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -746,7 +746,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -763,7 +763,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1209,7 +1209,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1694,7 +1694,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-03 17:24:32.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-20 22:30:48.830833557 +0000
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -Nuar mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/include/my_global.h 2010-08-20 22:31:41.752770815 +0000
-@@ -584,10 +584,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-@@ -1534,6 +1532,8 @@
- /* Define some useful general macros (should be done after all headers). */
- #if !defined(max)
- #define max(a, b) ((a) > (b) ? (a) : (b))
-+#endif
-+#if !defined(min)
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #endif
- /*
-diff -Nuar mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1573,7 +1573,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3621,7 +3621,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3854,9 +3854,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4174,7 +4174,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4186,7 +4186,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-08-20 22:20:26.964732066 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-08-03 17:24:23.000000000 +0000
-+++ mysql/mysys/array.c 2010-08-20 22:20:26.964732066 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/mysys/default.c 2010-08-20 22:20:26.964732066 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-08-20 22:20:26.964732066 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-08-20 22:20:26.964732066 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-08-20 22:20:26.964732066 +0000
-@@ -212,7 +212,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-08-20 22:20:26.964732066 +0000
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuar mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-08-20 22:20:26.964732066 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-08-20 22:20:26.964732066 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-08-20 22:20:26.964732066 +0000
-@@ -75,7 +75,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-08-20 22:20:26.968065522 +0000
-@@ -980,7 +980,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-08-20 22:20:26.968065522 +0000
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_static.h 2010-08-20 22:31:16.785190193 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-08-20 22:20:26.968065522 +0000
-@@ -248,7 +248,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-08-20 22:20:26.968065522 +0000
-@@ -231,7 +231,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar mysql.orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql.orig/sql/debug_sync.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/sql/debug_sync.cc 2010-08-20 22:26:19.817651899 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -Nuar mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/field.cc 2010-08-20 22:26:12.860730523 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2505,7 +2505,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2521,7 +2521,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -4561,7 +4561,7 @@
- #endif
- doubleget(nr,ptr);
-
-- uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
-+ uint to_length=MYSQL_MAX(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6440,13 +6440,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6454,7 +6454,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6712,7 +6712,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7706,7 +7706,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7866,7 +7866,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8062,7 +8062,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9109,7 +9109,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9195,7 +9195,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9323,7 +9323,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9779,7 +9779,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-08-20 22:20:26.971398975 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1117,7 +1117,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1380,7 +1380,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-08-20 22:20:26.974732431 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/handler.h 2010-08-20 22:20:26.974732431 +0000
-@@ -1606,15 +1606,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar mysql.orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql.orig/sql/ha_partition.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_partition.cc 2010-08-20 22:26:27.484599263 +0000
-@@ -5864,7 +5864,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -Nuar mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-08-20 22:21:21.480061665 +0000
-@@ -59,7 +59,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -69,7 +69,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item.cc 2010-08-20 22:25:24.732301765 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -442,9 +442,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -750,7 +750,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5403,7 +5403,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5458,7 +5458,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7539,14 +7539,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7577,7 +7577,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7599,7 +7599,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7617,7 +7617,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-08-20 22:20:26.978065887 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1312,7 +1312,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2364,7 +2364,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2375,10 +2375,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2402,9 +2402,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2532,7 +2532,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2576,10 +2576,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2587,8 +2587,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2998,7 +2998,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4897,7 +4897,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4916,7 +4916,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5037,14 +5037,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5068,14 +5068,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-08-20 22:20:26.981399343 +0000
-@@ -540,7 +540,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2956,7 +2956,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2965,7 +2965,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar mysql.orig/sql/item_func.h mysql/sql/item_func.h
---- mysql.orig/sql/item_func.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_func.h 2010-08-20 22:27:22.543281683 +0000
-@@ -380,7 +380,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -Nuar mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-08-20 22:24:51.184406804 +0000
-@@ -385,7 +385,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -744,7 +744,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1226,7 +1226,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1246,7 +1246,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1938,7 +1938,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3068,11 +3068,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3478,7 +3478,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -Nuar mysql.orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql.orig/sql/item_strfunc.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.h 2010-08-20 22:27:12.919596025 +0000
-@@ -695,7 +695,7 @@
- void fix_length_and_dec()
- {
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- collation.set(args[0]->collation);
- }
- };
-diff -Nuar mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -1161,7 +1161,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3365,7 +3365,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1823,7 +1823,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/key.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/log.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2423,7 +2423,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5145,7 +5145,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-08-20 22:24:38.123928612 +0000
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2664,7 +2664,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5575,7 +5575,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7298,7 +7298,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql.orig/sql/log_event_old.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event_old.cc 2010-08-20 22:26:32.254773908 +0000
-@@ -1420,7 +1420,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -3368,7 +3368,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3380,15 +3380,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5064,7 +5064,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-08-20 22:20:26.994733164 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7467,7 +7467,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7536,7 +7536,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8453,13 +8453,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8478,7 +8478,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8559,7 +8559,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9261,7 +9261,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9487,7 +9487,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10123,9 +10123,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar mysql.orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql.orig/sql/opt_range.h 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.h 2010-08-20 22:27:06.589364267 +0000
-@@ -83,7 +83,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -121,7 +121,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -Nuar mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -299,7 +299,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar mysql.orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql.orig/sql/rpl_utility.h 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.h 2010-08-20 22:26:52.782192108 +0000
-@@ -295,7 +295,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -Nuar mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-08-20 22:24:34.027111945 +0000
-@@ -1863,7 +1863,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4036,7 +4036,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -Nuar mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/slave.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -1728,7 +1728,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2345,7 +2345,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4041,7 +4041,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/spatial.h 2010-08-20 22:20:27.001400076 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -2453,7 +2453,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2654,7 +2654,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2374,7 +2374,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2429,7 +2429,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2457,7 +2457,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2545,8 +2545,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2578,7 +2578,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2587,7 +2587,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3010,7 +3010,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-08-20 22:24:23.626731145 +0000
-@@ -414,7 +414,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -429,7 +429,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2080,7 +2080,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -679,7 +679,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -1093,7 +1093,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -5658,7 +5658,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7161,7 +7161,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -4569,7 +4569,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2102,7 +2102,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-08-20 22:20:27.014733897 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar mysql.orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql.orig/sql/sql_profile.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_profile.cc 2010-08-20 22:26:43.418515961 +0000
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -Nuar mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-08-20 22:24:15.399763250 +0000
-@@ -1267,12 +1267,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1444,7 +1444,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1715,14 +1715,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1731,7 +1731,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-08-20 22:24:03.355988947 +0000
-@@ -2970,7 +2970,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3884,7 +3884,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3907,7 +3907,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4066,7 +4066,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4386,7 +4386,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4553,7 +4553,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5503,7 +5503,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10413,7 +10413,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13554,7 +13554,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13566,7 +13566,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14219,7 +14219,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14341,7 +14341,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-08-20 22:23:46.608709084 +0000
-@@ -759,7 +759,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -770,7 +770,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1877,7 +1877,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2008,7 +2008,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3174,7 +3174,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7018,7 +7018,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-08-20 22:23:39.628453503 +0000
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -966,7 +966,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1152,7 +1152,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -Nuar mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-08-20 22:20:27.024734262 +0000
-@@ -3264,7 +3264,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-08-03 17:42:08.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-08-20 22:20:27.038068083 +0000
-@@ -16221,7 +16221,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16241,7 +16241,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-08-20 22:20:27.041401539 +0000
-@@ -1804,7 +1804,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1814,7 +1814,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -130,7 +130,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -496,7 +496,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -715,7 +715,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/sql-common/client.c 2010-08-20 22:20:27.044734995 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-08-20 22:20:27.044734995 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -1193,7 +1193,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1429,7 +1429,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-08-20 22:20:27.048068451 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_blobCollection.cc mysql/storage/ibmdb2i/db2i_blobCollection.cc
---- mysql.orig/storage/ibmdb2i/db2i_blobCollection.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_blobCollection.cc 2010-08-20 22:28:20.992088156 +0000
-@@ -61,9 +61,9 @@
-
- uint curMaxSize = table->getBlobFieldActualSize(fieldIndex);
-
-- uint defaultAllocSize = min(defaultAllocation, fieldLength);
-+ uint defaultAllocSize = MYSQL_MIN(defaultAllocation, fieldLength);
-
-- return max(defaultAllocSize, curMaxSize);
-+ return MYSQL_MAX(defaultAllocSize, curMaxSize);
-
- }
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_conversion.cc mysql/storage/ibmdb2i/db2i_conversion.cc
---- mysql.orig/storage/ibmdb2i/db2i_conversion.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_conversion.cc 2010-08-20 22:29:33.198064849 +0000
-@@ -528,13 +528,13 @@
- {
- if (field->type() == MYSQL_TYPE_STRING)
- {
-- sprintf(stringBuildBuffer, "BINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "BINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else
- {
- if (fieldLength <= MAX_VARCHAR_LENGTH)
- {
-- sprintf(stringBuildBuffer, "VARBINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARBINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else if (blobMapping == AS_VARCHAR &&
- (field->flags & PART_KEY_FLAG))
-@@ -543,8 +543,8 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-- sprintf(stringBuildBuffer, "BLOB(%d)", max(fieldLength, 1));
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-+ sprintf(stringBuildBuffer, "BLOB(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- mapping.append(stringBuildBuffer);
-@@ -559,24 +559,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- mapping.append(stringBuildBuffer);
- }
-@@ -588,24 +588,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- else if (blobMapping == AS_VARCHAR &&
-@@ -637,30 +637,30 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-
- if (fieldCharSet->mbmaxlen > 1)
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of characters
- }
- }
-
-@@ -721,7 +721,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint truncationAmount = precision - db2Precision;
-
- if (scale >= truncationAmount)
-@@ -1101,7 +1101,7 @@
- if (maxDisplayLength == 0 && db2FieldType == QMY_GRAPHIC)
- maxDb2BytesToStore = 2;
- else
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
-
- if (bytesToStore == 0)
-@@ -1146,7 +1146,7 @@
- else // Else Far East, special UTF8 or non-special UTF8/UCS2
- {
- size_t maxDb2BytesToStore;
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
- temp = getCharacterConversionBuffer(field->field_index, maxDb2BytesToStore);
- rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore,temp,bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
-@@ -1199,7 +1199,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint decimalPlace = precision-scale+1;
- char temp[80];
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_file.cc mysql/storage/ibmdb2i/db2i_file.cc
---- mysql.orig/storage/ibmdb2i/db2i_file.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_file.cc 2010-08-20 22:28:11.148394451 +0000
-@@ -335,14 +335,14 @@
- {
- strncpy(out, in, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
- ++cur;
- }
-
- strncpy(out, test, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
-
- void db2i_table::filenameToTablename(const char* in, char* out, size_t outlen)
-@@ -366,8 +366,8 @@
- part4 = strend(in);
- }
-
-- memcpy(temp, part1, min(outlen, part2 - part1));
-- temp[min(outlen-1, part2-part1)] = 0;
-+ memcpy(temp, part1, MYSQL_MIN(outlen, part2 - part1));
-+ temp[MYSQL_MIN(outlen-1, part2-part1)] = 0;
-
- int32 accumLen = smartFilenameToTableName(temp, out, outlen);
-
-@@ -376,9 +376,9 @@
- strcat(out, "#P#");
- accumLen += 4;
-
-- memset(temp, 0, min(outlen, part2-part1));
-- memcpy(temp, part3, min(outlen, part4-part3));
-- temp[min(outlen-1, part4-part3)] = 0;
-+ memset(temp, 0, MYSQL_MIN(outlen, part2-part1));
-+ memcpy(temp, part3, MYSQL_MIN(outlen, part4-part3));
-+ temp[MYSQL_MIN(outlen-1, part4-part3)] = 0;
-
- accumLen += smartFilenameToTableName(temp, strend(out), outlen-accumLen);
-
-@@ -484,7 +484,7 @@
-
- strncat(generatedName,
- tableName+1,
-- min(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-+ MYSQL_MIN(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-
- char finalName[MAX_DB2_FILENAME_LENGTH+1];
- convertMySQLNameToDB2Name(generatedName, finalName, sizeof(finalName), true, (format==ASCII_SQL));
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_ileBridge.cc mysql/storage/ibmdb2i/db2i_ileBridge.cc
---- mysql.orig/storage/ibmdb2i/db2i_ileBridge.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_ileBridge.cc 2010-08-20 22:29:38.048242404 +0000
-@@ -594,7 +594,7 @@
- {
- Qmy_MSPO0100_output* output = (Qmy_MSPO0100_output*)parmBlock->outParms;
- *rfileHandle = output->ObjHnd;
-- *recLength = max(output->InNxtRowOff, output->OutNxtRowOff);
-+ *recLength = MYSQL_MAX(output->InNxtRowOff, output->OutNxtRowOff);
- }
-
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_misc.h mysql/storage/ibmdb2i/db2i_misc.h
---- mysql.orig/storage/ibmdb2i/db2i_misc.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_misc.h 2010-08-20 22:30:17.773029964 +0000
-@@ -87,7 +87,7 @@
-
- if (delimit)
- output[o++] = '"';
-- output[min(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
-+ output[MYSQL_MIN(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
- // but at least its safe.
- return (o <= outlen-1);
- }
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_safeString.h mysql/storage/ibmdb2i/db2i_safeString.h
---- mysql.orig/storage/ibmdb2i/db2i_safeString.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_safeString.h 2010-08-20 22:30:09.069378013 +0000
-@@ -79,7 +79,7 @@
-
- SafeString& strncat(const char* str, size_t len)
- {
-- uint64 amountToCopy = min((allocSize-1) - curPos, len);
-+ uint64 amountToCopy = MYSQL_MIN((allocSize-1) - curPos, len);
- memcpy(buf + curPos, str, amountToCopy);
- curPos += amountToCopy;
- buf[curPos] = 0;
-diff -Nuar mysql.orig/storage/ibmdb2i/ha_ibmdb2i.cc mysql/storage/ibmdb2i/ha_ibmdb2i.cc
---- mysql.orig/storage/ibmdb2i/ha_ibmdb2i.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.cc 2010-08-20 22:30:03.609178129 +0000
-@@ -2644,9 +2644,9 @@
- rowsToRead = 1;
- }
-
-- rowsToRead = min(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+ rowsToRead = MYSQL_MIN(stats.records+1,MYSQL_MIN(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-
-- uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
- multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
- activeReadBuf = &multiRowReadBuf;
-
-@@ -2682,9 +2682,9 @@
-
- if (unlikely(rc)) DBUG_RETURN(rc);
-
-- rowsToWrite = min(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-+ rowsToWrite = MYSQL_MIN(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-
-- uint bufSize = min((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
- multiRowWriteBuf.allocBuf(format->writeRowLen, format->writeRowNullOffset, bufSize);
- activeWriteBuf = &multiRowWriteBuf;
-
-@@ -2768,8 +2768,8 @@
- else
- {
- char unknownIndex[MAX_DB2_FILENAME_LENGTH+1];
-- convFromEbcdic(lastDupKeyNamePtr, unknownIndex, min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-- unknownIndex[min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
-+ convFromEbcdic(lastDupKeyNamePtr, unknownIndex, MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-+ unknownIndex[MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
- getErrTxt(DB2I_ERR_UNKNOWN_IDX, unknownIndex);
- }
- }
-@@ -3141,7 +3141,7 @@
- if (forceSingleRowRead)
- rowsToBuffer = 1;
- else
-- rowsToBuffer = min(rowsToBuffer, activeReadBuf->getRowCapacity());
-+ rowsToBuffer = MYSQL_MIN(rowsToBuffer, activeReadBuf->getRowCapacity());
-
- activeReadBuf->newReadRequest(activeHandle,
- orientation,
-@@ -3279,7 +3279,7 @@
- double dataPageCount = stats.data_file_length/IO_SIZE;
-
- cost = (rows * dataPageCount / totalRecords) +
-- min(idxPageCnt, (log_2(idxPageCnt) * ranges +
-+ MYSQL_MIN(idxPageCnt, (log_2(idxPageCnt) * ranges +
- rows * (log_2(idxPageCnt) + log_2(rows) - log_2(totalRecords))));
- }
- }
-diff -Nuar mysql.orig/storage/ibmdb2i/ha_ibmdb2i.h mysql/storage/ibmdb2i/ha_ibmdb2i.h
---- mysql.orig/storage/ibmdb2i/ha_ibmdb2i.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.h 2010-08-20 22:30:22.989887605 +0000
-@@ -502,7 +502,7 @@
- ha_rows getIndexReadEstimate(uint index)
- {
- if (indexReadSizeEstimates)
-- return max(indexReadSizeEstimates[index], 1);
-+ return MYSQL_MAX(indexReadSizeEstimates[index], 1);
-
- return 10000; // Assume index scan if no estimate exists.
- }
-diff -Nuar mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-08-20 22:20:27.048068451 +0000
-@@ -1519,7 +1519,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-08-20 22:20:27.048068451 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-08-20 22:20:27.048068451 +0000
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2779,7 +2779,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4328,7 +4328,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -880,7 +880,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-08-20 22:20:27.051401907 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-08-20 22:20:27.051401907 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-08-20 22:20:27.051401907 +0000
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-08-20 22:20:27.051401907 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-08-20 22:20:27.051401907 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-08-20 22:20:27.054735360 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-08-20 22:20:27.054735360 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-08-20 22:20:27.054735360 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-08-20 22:20:27.054735360 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-08-20 22:20:27.054735360 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-08-20 22:20:27.058068816 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-08-20 22:20:27.058068816 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-08-20 22:20:27.061402272 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-08-20 22:20:27.064735728 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-08-20 22:20:27.064735728 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-08-20 22:20:27.064735728 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-08-20 22:20:27.068069184 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-08-20 22:20:27.068069184 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-08-20 22:20:27.071402637 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/strings/decimal.c 2010-08-20 22:20:27.071402637 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2173,11 +2173,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2301,7 +2301,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2339,7 +2339,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-08-20 22:20:27.071402637 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/strings/str2int.c 2010-08-20 22:20:27.071402637 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-08-20 22:18:38.644098669 +0000
-+++ mysql/tests/mysql_client_test.c 2010-08-20 22:20:27.074736093 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-08-20 22:20:27.074736093 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.51.patch b/07110_all_mysql_gcc-4.2_5.1.51.patch
deleted file mode 100644
index d6f2e64..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.51.patch
+++ /dev/null
@@ -1,4061 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -1945,7 +1945,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -3326,9 +3326,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3348,7 +3348,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-08-20 22:20:26.958065154 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4508,7 +4508,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-08-20 22:20:26.958065154 +0000
-@@ -5496,9 +5496,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-08-20 22:20:26.958065154 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-08-20 22:20:26.961398610 +0000
-@@ -660,7 +660,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -746,7 +746,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -763,7 +763,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1209,7 +1209,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1694,7 +1694,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-03 17:24:32.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-20 22:30:48.830833557 +0000
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -Nuar mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/include/my_global.h 2010-08-20 22:31:41.752770815 +0000
-@@ -584,10 +584,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-@@ -1534,6 +1532,8 @@
- /* Define some useful general macros (should be done after all headers). */
- #if !defined(max)
- #define max(a, b) ((a) > (b) ? (a) : (b))
-+#endif
-+#if !defined(min)
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #endif
- /*
-diff -Nuar mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1573,7 +1573,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3621,7 +3621,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3854,9 +3854,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4174,7 +4174,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4186,7 +4186,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-08-20 22:20:26.964732066 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-08-03 17:24:23.000000000 +0000
-+++ mysql/mysys/array.c 2010-08-20 22:20:26.964732066 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/mysys/default.c 2010-08-20 22:20:26.964732066 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-08-20 22:20:26.964732066 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-08-20 22:20:26.964732066 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-08-20 22:20:26.964732066 +0000
-@@ -212,7 +212,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-08-20 22:20:26.964732066 +0000
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuar mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-08-20 22:20:26.964732066 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-08-20 22:20:26.964732066 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-08-20 22:20:26.964732066 +0000
-@@ -75,7 +75,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-08-20 22:20:26.968065522 +0000
-@@ -980,7 +980,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-08-20 22:20:26.968065522 +0000
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_static.h 2010-08-20 22:31:16.785190193 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-08-20 22:20:26.968065522 +0000
-@@ -248,7 +248,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-08-20 22:20:26.968065522 +0000
-@@ -231,7 +231,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar mysql.orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql.orig/sql/debug_sync.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/sql/debug_sync.cc 2010-08-20 22:26:19.817651899 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -Nuar mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/field.cc 2010-08-20 22:26:12.860730523 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2505,7 +2505,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2521,7 +2521,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6440,13 +6440,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6454,7 +6454,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6712,7 +6712,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7706,7 +7706,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7866,7 +7866,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8062,7 +8062,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9109,7 +9109,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9195,7 +9195,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9323,7 +9323,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9779,7 +9779,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-08-20 22:20:26.971398975 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1117,7 +1117,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1380,7 +1380,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-08-20 22:20:26.974732431 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/handler.h 2010-08-20 22:20:26.974732431 +0000
-@@ -1606,15 +1606,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar mysql.orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql.orig/sql/ha_partition.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_partition.cc 2010-08-20 22:26:27.484599263 +0000
-@@ -5864,7 +5864,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -Nuar mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-08-20 22:21:21.480061665 +0000
-@@ -59,7 +59,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -69,7 +69,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item.cc 2010-08-20 22:25:24.732301765 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -442,9 +442,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -750,7 +750,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5403,7 +5403,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5458,7 +5458,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7539,14 +7539,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7577,7 +7577,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7599,7 +7599,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7617,7 +7617,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-08-20 22:20:26.978065887 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1312,7 +1312,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2364,7 +2364,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2375,10 +2375,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2402,9 +2402,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2532,7 +2532,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2576,10 +2576,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2587,8 +2587,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2998,7 +2998,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4897,7 +4897,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4916,7 +4916,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5037,14 +5037,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5068,14 +5068,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-08-20 22:20:26.981399343 +0000
-@@ -540,7 +540,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1134,10 +1134,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1247,9 +1247,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1297,7 +1297,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1306,7 +1306,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1320,7 +1320,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- max_length=args[0]->max_length - args[0]->decimals + decimals;
- uint tmp=float_length(decimals);
-@@ -1442,8 +1442,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1961,7 +1961,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1971,7 +1971,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -1988,13 +1988,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2095,7 +2095,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2956,7 +2956,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2965,7 +2965,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar mysql.orig/sql/item_func.h mysql/sql/item_func.h
---- mysql.orig/sql/item_func.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_func.h 2010-08-20 22:27:22.543281683 +0000
-@@ -380,7 +380,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -Nuar mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-08-20 22:24:51.184406804 +0000
-@@ -385,7 +385,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -744,7 +744,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1226,7 +1226,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1246,7 +1246,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1938,7 +1938,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3068,11 +3068,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3478,7 +3478,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -Nuar mysql.orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql.orig/sql/item_strfunc.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.h 2010-08-20 22:27:12.919596025 +0000
-@@ -695,7 +695,7 @@
- void fix_length_and_dec()
- {
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- collation.set(args[0]->collation);
- }
- };
-diff -Nuar mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -1161,7 +1161,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1224,16 +1224,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1424,13 +1424,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3365,7 +3365,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1823,7 +1823,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/key.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/log.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2423,7 +2423,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5145,7 +5145,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-08-20 22:24:38.123928612 +0000
-@@ -1070,7 +1070,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2664,7 +2664,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5575,7 +5575,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7298,7 +7298,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql.orig/sql/log_event_old.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event_old.cc 2010-08-20 22:26:32.254773908 +0000
-@@ -1420,7 +1420,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -3368,7 +3368,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3380,15 +3380,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5064,7 +5064,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-08-20 22:20:26.994733164 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7467,7 +7467,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7536,7 +7536,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8453,13 +8453,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8478,7 +8478,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8559,7 +8559,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9261,7 +9261,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9487,7 +9487,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10123,9 +10123,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar mysql.orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql.orig/sql/opt_range.h 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.h 2010-08-20 22:27:06.589364267 +0000
-@@ -83,7 +83,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -121,7 +121,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -Nuar mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -299,7 +299,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar mysql.orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql.orig/sql/rpl_utility.h 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.h 2010-08-20 22:26:52.782192108 +0000
-@@ -295,7 +295,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -Nuar mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-08-20 22:24:34.027111945 +0000
-@@ -1863,7 +1863,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4036,7 +4036,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -Nuar mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/slave.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -1728,7 +1728,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2345,7 +2345,7 @@
- exec_res= 0;
- end_trans(thd, ROLLBACK);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4041,7 +4041,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/spatial.h 2010-08-20 22:20:27.001400076 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -2453,7 +2453,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2654,7 +2654,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2374,7 +2374,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2429,7 +2429,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2457,7 +2457,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2545,8 +2545,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2578,7 +2578,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2587,7 +2587,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3010,7 +3010,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-08-20 22:24:23.626731145 +0000
-@@ -414,7 +414,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -429,7 +429,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2080,7 +2080,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -679,7 +679,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -1093,7 +1093,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -5658,7 +5658,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7161,7 +7161,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -4569,7 +4569,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -486,7 +486,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2102,7 +2102,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-08-20 22:20:27.014733897 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar mysql.orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql.orig/sql/sql_profile.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_profile.cc 2010-08-20 22:26:43.418515961 +0000
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -Nuar mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-08-20 22:24:15.399763250 +0000
-@@ -1267,12 +1267,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1444,7 +1444,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1715,14 +1715,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1731,7 +1731,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-08-20 22:24:03.355988947 +0000
-@@ -2970,7 +2970,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3884,7 +3884,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3907,7 +3907,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4066,7 +4066,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4386,7 +4386,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4553,7 +4553,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5503,7 +5503,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10413,7 +10413,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13554,7 +13554,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13566,7 +13566,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14219,7 +14219,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14341,7 +14341,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-08-20 22:23:46.608709084 +0000
-@@ -759,7 +759,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -770,7 +770,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1877,7 +1877,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2008,7 +2008,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3174,7 +3174,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7018,7 +7018,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-08-20 22:23:39.628453503 +0000
-@@ -662,7 +662,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -748,7 +748,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -765,7 +765,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -966,7 +966,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1152,7 +1152,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -Nuar mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-08-20 22:20:27.024734262 +0000
-@@ -3264,7 +3264,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-08-03 17:42:08.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-08-20 22:20:27.038068083 +0000
-@@ -16221,7 +16221,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16241,7 +16241,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-08-20 22:20:27.041401539 +0000
-@@ -1804,7 +1804,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1814,7 +1814,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -130,7 +130,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -496,7 +496,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -715,7 +715,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/sql-common/client.c 2010-08-20 22:20:27.044734995 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-08-20 22:20:27.044734995 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -1193,7 +1193,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1429,7 +1429,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-08-20 22:20:27.048068451 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_blobCollection.cc mysql/storage/ibmdb2i/db2i_blobCollection.cc
---- mysql.orig/storage/ibmdb2i/db2i_blobCollection.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_blobCollection.cc 2010-08-20 22:28:20.992088156 +0000
-@@ -61,9 +61,9 @@
-
- uint curMaxSize = table->getBlobFieldActualSize(fieldIndex);
-
-- uint defaultAllocSize = min(defaultAllocation, fieldLength);
-+ uint defaultAllocSize = MYSQL_MIN(defaultAllocation, fieldLength);
-
-- return max(defaultAllocSize, curMaxSize);
-+ return MYSQL_MAX(defaultAllocSize, curMaxSize);
-
- }
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_conversion.cc mysql/storage/ibmdb2i/db2i_conversion.cc
---- mysql.orig/storage/ibmdb2i/db2i_conversion.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_conversion.cc 2010-08-20 22:29:33.198064849 +0000
-@@ -528,13 +528,13 @@
- {
- if (field->type() == MYSQL_TYPE_STRING)
- {
-- sprintf(stringBuildBuffer, "BINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "BINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else
- {
- if (fieldLength <= MAX_VARCHAR_LENGTH)
- {
-- sprintf(stringBuildBuffer, "VARBINARY(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARBINARY(%d)", MYSQL_MAX(fieldLength, 1));
- }
- else if (blobMapping == AS_VARCHAR &&
- (field->flags & PART_KEY_FLAG))
-@@ -543,8 +543,8 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-- sprintf(stringBuildBuffer, "BLOB(%d)", max(fieldLength, 1));
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-+ sprintf(stringBuildBuffer, "BLOB(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- mapping.append(stringBuildBuffer);
-@@ -559,24 +559,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "CHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- mapping.append(stringBuildBuffer);
- }
-@@ -588,24 +588,24 @@
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1));
-+ sprintf(stringBuildBuffer, "VARCHAR(%d)", MYSQL_MAX(fieldLength, 1));
- }
- }
- else if (blobMapping == AS_VARCHAR &&
-@@ -637,30 +637,30 @@
- }
- else
- {
-- fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
-+ fieldLength = MYSQL_MIN(MAX_BLOB_LENGTH, fieldLength);
-
- if (fieldCharSet->mbmaxlen > 1)
- {
- if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 13488;
- }
- else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
- strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of bytes
- db2Ccsid = 1208;
- }
- else
- {
-- sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "DBCLOB(%d)", MYSQL_MAX(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
- db2Ccsid = 1200;
- }
- }
- else
- {
-- sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of characters
-+ sprintf(stringBuildBuffer, "CLOB(%d)", MYSQL_MAX(fieldLength, 1)); // Number of characters
- }
- }
-
-@@ -721,7 +721,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint truncationAmount = precision - db2Precision;
-
- if (scale >= truncationAmount)
-@@ -1101,7 +1101,7 @@
- if (maxDisplayLength == 0 && db2FieldType == QMY_GRAPHIC)
- maxDb2BytesToStore = 2;
- else
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
-
- if (bytesToStore == 0)
-@@ -1146,7 +1146,7 @@
- else // Else Far East, special UTF8 or non-special UTF8/UCS2
- {
- size_t maxDb2BytesToStore;
-- maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
-+ maxDb2BytesToStore = MYSQL_MIN(((bytesToStore * 2) / fieldCharSet->mbminlen),
- ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
- temp = getCharacterConversionBuffer(field->field_index, maxDb2BytesToStore);
- rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore,temp,bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
-@@ -1199,7 +1199,7 @@
- {
- uint precision= ((Field_new_decimal*)field)->precision;
- uint scale= field->decimals();
-- uint db2Precision = min(precision, MAX_DEC_PRECISION);
-+ uint db2Precision = MYSQL_MIN(precision, MAX_DEC_PRECISION);
- uint decimalPlace = precision-scale+1;
- char temp[80];
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_file.cc mysql/storage/ibmdb2i/db2i_file.cc
---- mysql.orig/storage/ibmdb2i/db2i_file.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_file.cc 2010-08-20 22:28:11.148394451 +0000
-@@ -335,14 +335,14 @@
- {
- strncpy(out, in, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
- ++cur;
- }
-
- strncpy(out, test, outlen);
- my_free(test, MYF(0));
-- return min(outlen, strlen(out));
-+ return MYSQL_MIN(outlen, strlen(out));
- }
-
- void db2i_table::filenameToTablename(const char* in, char* out, size_t outlen)
-@@ -366,8 +366,8 @@
- part4 = strend(in);
- }
-
-- memcpy(temp, part1, min(outlen, part2 - part1));
-- temp[min(outlen-1, part2-part1)] = 0;
-+ memcpy(temp, part1, MYSQL_MIN(outlen, part2 - part1));
-+ temp[MYSQL_MIN(outlen-1, part2-part1)] = 0;
-
- int32 accumLen = smartFilenameToTableName(temp, out, outlen);
-
-@@ -376,9 +376,9 @@
- strcat(out, "#P#");
- accumLen += 4;
-
-- memset(temp, 0, min(outlen, part2-part1));
-- memcpy(temp, part3, min(outlen, part4-part3));
-- temp[min(outlen-1, part4-part3)] = 0;
-+ memset(temp, 0, MYSQL_MIN(outlen, part2-part1));
-+ memcpy(temp, part3, MYSQL_MIN(outlen, part4-part3));
-+ temp[MYSQL_MIN(outlen-1, part4-part3)] = 0;
-
- accumLen += smartFilenameToTableName(temp, strend(out), outlen-accumLen);
-
-@@ -484,7 +484,7 @@
-
- strncat(generatedName,
- tableName+1,
-- min(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-+ MYSQL_MIN(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
-
- char finalName[MAX_DB2_FILENAME_LENGTH+1];
- convertMySQLNameToDB2Name(generatedName, finalName, sizeof(finalName), true, (format==ASCII_SQL));
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_ileBridge.cc mysql/storage/ibmdb2i/db2i_ileBridge.cc
---- mysql.orig/storage/ibmdb2i/db2i_ileBridge.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_ileBridge.cc 2010-08-20 22:29:38.048242404 +0000
-@@ -594,7 +594,7 @@
- {
- Qmy_MSPO0100_output* output = (Qmy_MSPO0100_output*)parmBlock->outParms;
- *rfileHandle = output->ObjHnd;
-- *recLength = max(output->InNxtRowOff, output->OutNxtRowOff);
-+ *recLength = MYSQL_MAX(output->InNxtRowOff, output->OutNxtRowOff);
- }
-
-
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_misc.h mysql/storage/ibmdb2i/db2i_misc.h
---- mysql.orig/storage/ibmdb2i/db2i_misc.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_misc.h 2010-08-20 22:30:17.773029964 +0000
-@@ -87,7 +87,7 @@
-
- if (delimit)
- output[o++] = '"';
-- output[min(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
-+ output[MYSQL_MIN(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
- // but at least its safe.
- return (o <= outlen-1);
- }
-diff -Nuar mysql.orig/storage/ibmdb2i/db2i_safeString.h mysql/storage/ibmdb2i/db2i_safeString.h
---- mysql.orig/storage/ibmdb2i/db2i_safeString.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/db2i_safeString.h 2010-08-20 22:30:09.069378013 +0000
-@@ -79,7 +79,7 @@
-
- SafeString& strncat(const char* str, size_t len)
- {
-- uint64 amountToCopy = min((allocSize-1) - curPos, len);
-+ uint64 amountToCopy = MYSQL_MIN((allocSize-1) - curPos, len);
- memcpy(buf + curPos, str, amountToCopy);
- curPos += amountToCopy;
- buf[curPos] = 0;
-diff -Nuar mysql.orig/storage/ibmdb2i/ha_ibmdb2i.cc mysql/storage/ibmdb2i/ha_ibmdb2i.cc
---- mysql.orig/storage/ibmdb2i/ha_ibmdb2i.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.cc 2010-08-20 22:30:03.609178129 +0000
-@@ -2644,9 +2644,9 @@
- rowsToRead = 1;
- }
-
-- rowsToRead = min(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-+ rowsToRead = MYSQL_MIN(stats.records+1,MYSQL_MIN(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
-
-- uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
- multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
- activeReadBuf = &multiRowReadBuf;
-
-@@ -2682,9 +2682,9 @@
-
- if (unlikely(rc)) DBUG_RETURN(rc);
-
-- rowsToWrite = min(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-+ rowsToWrite = MYSQL_MIN(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
-
-- uint bufSize = min((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
-+ uint bufSize = MYSQL_MIN((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
- multiRowWriteBuf.allocBuf(format->writeRowLen, format->writeRowNullOffset, bufSize);
- activeWriteBuf = &multiRowWriteBuf;
-
-@@ -2768,8 +2768,8 @@
- else
- {
- char unknownIndex[MAX_DB2_FILENAME_LENGTH+1];
-- convFromEbcdic(lastDupKeyNamePtr, unknownIndex, min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-- unknownIndex[min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
-+ convFromEbcdic(lastDupKeyNamePtr, unknownIndex, MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
-+ unknownIndex[MYSQL_MIN(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
- getErrTxt(DB2I_ERR_UNKNOWN_IDX, unknownIndex);
- }
- }
-@@ -3141,7 +3141,7 @@
- if (forceSingleRowRead)
- rowsToBuffer = 1;
- else
-- rowsToBuffer = min(rowsToBuffer, activeReadBuf->getRowCapacity());
-+ rowsToBuffer = MYSQL_MIN(rowsToBuffer, activeReadBuf->getRowCapacity());
-
- activeReadBuf->newReadRequest(activeHandle,
- orientation,
-@@ -3279,7 +3279,7 @@
- double dataPageCount = stats.data_file_length/IO_SIZE;
-
- cost = (rows * dataPageCount / totalRecords) +
-- min(idxPageCnt, (log_2(idxPageCnt) * ranges +
-+ MYSQL_MIN(idxPageCnt, (log_2(idxPageCnt) * ranges +
- rows * (log_2(idxPageCnt) + log_2(rows) - log_2(totalRecords))));
- }
- }
-diff -Nuar mysql.orig/storage/ibmdb2i/ha_ibmdb2i.h mysql/storage/ibmdb2i/ha_ibmdb2i.h
---- mysql.orig/storage/ibmdb2i/ha_ibmdb2i.h 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/storage/ibmdb2i/ha_ibmdb2i.h 2010-08-20 22:30:22.989887605 +0000
-@@ -502,7 +502,7 @@
- ha_rows getIndexReadEstimate(uint index)
- {
- if (indexReadSizeEstimates)
-- return max(indexReadSizeEstimates[index], 1);
-+ return MYSQL_MAX(indexReadSizeEstimates[index], 1);
-
- return 10000; // Assume index scan if no estimate exists.
- }
-diff -Nuar mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-08-20 22:20:27.048068451 +0000
-@@ -1519,7 +1519,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-08-20 22:20:27.048068451 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-08-20 22:20:27.048068451 +0000
-@@ -2170,7 +2170,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2326,7 +2326,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2779,7 +2779,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4328,7 +4328,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -880,7 +880,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-08-20 22:20:27.051401907 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-08-20 22:20:27.051401907 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-08-20 22:20:27.051401907 +0000
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-08-20 22:20:27.051401907 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-08-20 22:20:27.051401907 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-08-20 22:20:27.054735360 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-08-20 22:20:27.054735360 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-08-20 22:20:27.054735360 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-08-20 22:20:27.054735360 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-08-20 22:20:27.054735360 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-08-20 22:20:27.058068816 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-08-20 22:20:27.058068816 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-08-20 22:20:27.061402272 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-08-20 22:20:27.064735728 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-08-20 22:20:27.064735728 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-08-20 22:20:27.064735728 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-08-20 22:20:27.068069184 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-08-20 22:20:27.068069184 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-08-20 22:20:27.071402637 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/strings/decimal.c 2010-08-20 22:20:27.071402637 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2173,11 +2173,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2301,7 +2301,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2339,7 +2339,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-08-20 22:20:27.071402637 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/strings/str2int.c 2010-08-20 22:20:27.071402637 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-08-20 22:18:38.644098669 +0000
-+++ mysql/tests/mysql_client_test.c 2010-08-20 22:20:27.074736093 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-08-20 22:20:27.074736093 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.56.patch b/07110_all_mysql_gcc-4.2_5.1.56.patch
deleted file mode 100644
index b3aac08..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.56.patch
+++ /dev/null
@@ -1,3729 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqlbinlog.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -1945,7 +1945,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql.cc 2010-08-20 22:20:26.954731698 +0000
-@@ -3336,9 +3336,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3358,7 +3358,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysqldump.c 2010-08-20 22:20:26.958065154 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4517,7 +4517,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/client/mysqltest.cc 2010-08-20 22:20:26.958065154 +0000
-@@ -5652,9 +5652,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/client/mysql_upgrade.c 2010-08-20 22:20:26.958065154 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/client/sql_string.cc 2010-08-20 22:20:26.961398610 +0000
-@@ -660,7 +660,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -746,7 +746,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -763,7 +763,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/dbug/dbug.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-03 17:24:32.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2010-08-20 22:30:48.830833557 +0000
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -Nuar mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2010-08-20 22:20:26.961398610 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/include/my_global.h 2010-08-20 22:31:41.752770815 +0000
-@@ -584,10 +584,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-@@ -1535,6 +1533,8 @@
- /* Define some useful general macros (should be done after all headers). */
- #if !defined(max)
- #define max(a, b) ((a) > (b) ? (a) : (b))
-+#endif
-+#if !defined(min)
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #endif
- /*
-diff -Nuar mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysql/libmysql.c 2010-08-20 22:20:26.961398610 +0000
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/libmysqld/lib_sql.cc 2010-08-20 22:20:26.964732066 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2010-08-03 17:24:23.000000000 +0000
-+++ mysql/mysys/array.c 2010-08-20 22:20:26.964732066 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/mysys/default.c 2010-08-20 22:20:26.964732066 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_format.c 2010-08-20 22:20:26.964732066 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/mysys/mf_iocache.c 2010-08-20 22:20:26.964732066 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_alloc.c 2010-08-20 22:20:26.964732066 +0000
-@@ -212,7 +212,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_bitmap.c 2010-08-20 22:20:26.964732066 +0000
-@@ -365,7 +365,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- *map2->last_word_ptr&= ~map2->last_word_mask; /*Clear last bits in map2*/
- while (to < end)
- *to++ &= *from++;
-diff -Nuar mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_compress.c 2010-08-20 22:20:26.964732066 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_conio.c 2010-08-20 22:20:26.964732066 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_file.c 2010-08-20 22:20:26.964732066 +0000
-@@ -75,7 +75,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_getopt.c 2010-08-20 22:20:26.968065522 +0000
-@@ -983,7 +983,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar mysql.orig/mysys/my_handler.c mysql/mysys/my_handler.c
---- mysql.orig/mysys/my_handler.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_handler.c 2010-08-20 22:20:26.968065522 +0000
-@@ -38,7 +38,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -166,7 +166,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/mysys/my_static.h 2010-08-20 22:31:16.785190193 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/mysys/safemalloc.c 2010-08-20 22:20:26.968065522 +0000
-@@ -248,7 +248,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/mysys/stacktrace.c 2010-08-20 22:20:26.968065522 +0000
-@@ -324,7 +324,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2010-08-20 22:20:26.968065522 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar mysql.orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql.orig/sql/debug_sync.cc 2010-08-03 17:24:21.000000000 +0000
-+++ mysql/sql/debug_sync.cc 2010-08-20 22:26:19.817651899 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -Nuar mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/field.cc 2010-08-20 22:26:12.860730523 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2505,7 +2505,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2521,7 +2521,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6440,13 +6440,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6454,7 +6454,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6712,7 +6712,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7706,7 +7706,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7866,7 +7866,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8062,7 +8062,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9109,7 +9109,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9195,7 +9195,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9323,7 +9323,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9780,7 +9780,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/sql/filesort.cc 2010-08-20 22:20:26.971398975 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1117,7 +1117,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1380,7 +1380,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2010-08-20 22:20:26.974732431 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/handler.h 2010-08-20 22:20:26.974732431 +0000
-@@ -1606,15 +1606,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar mysql.orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql.orig/sql/ha_partition.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/sql/ha_partition.cc 2010-08-20 22:26:27.484599263 +0000
-@@ -5966,7 +5966,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -Nuar mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_buff.cc 2010-08-20 22:21:21.480061665 +0000
-@@ -59,7 +59,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -69,7 +69,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item.cc 2010-08-20 22:25:24.732301765 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -442,9 +442,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -750,7 +750,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5400,7 +5400,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5455,7 +5455,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7545,14 +7545,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7583,7 +7583,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7605,7 +7605,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7623,7 +7623,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_cmpfunc.cc 2010-08-20 22:20:26.978065887 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4981,7 +4981,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -5000,7 +5000,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5121,14 +5121,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5152,14 +5152,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_func.cc 2010-08-20 22:20:26.981399343 +0000
-@@ -547,7 +547,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1141,10 +1141,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1254,9 +1254,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1304,7 +1304,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1313,7 +1313,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1327,7 +1327,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1458,8 +1458,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1977,7 +1977,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1987,7 +1987,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2004,13 +2004,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2111,7 +2111,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2986,7 +2986,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2995,7 +2995,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar mysql.orig/sql/item_func.h mysql/sql/item_func.h
---- mysql.orig/sql/item_func.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_func.h 2010-08-20 22:27:22.543281683 +0000
-@@ -420,7 +420,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -Nuar mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.cc 2010-08-20 22:24:51.184406804 +0000
-@@ -388,7 +388,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -747,7 +747,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1248,7 +1248,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1268,7 +1268,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1959,7 +1959,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3111,11 +3111,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3522,7 +3522,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -Nuar mysql.orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql.orig/sql/item_strfunc.h 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_strfunc.h 2010-08-20 22:27:12.919596025 +0000
-@@ -705,7 +705,7 @@
- void fix_length_and_dec()
- {
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 + 2;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- collation.set(args[0]->collation);
- }
- };
-diff -Nuar mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/item_sum.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -1143,7 +1143,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1206,16 +1206,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1406,13 +1406,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3349,7 +3349,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/item_timefunc.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1823,7 +1823,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2010-08-03 17:24:28.000000000 +0000
-+++ mysql/sql/key.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/log.cc 2010-08-20 22:20:26.984732799 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2429,7 +2429,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5236,7 +5236,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event.cc 2010-08-20 22:24:38.123928612 +0000
-@@ -1075,7 +1075,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2671,7 +2671,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5588,7 +5588,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7315,7 +7315,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql.orig/sql/log_event_old.cc 2010-08-03 17:24:29.000000000 +0000
-+++ mysql/sql/log_event_old.cc 2010-08-20 22:26:32.254773908 +0000
-@@ -1420,7 +1420,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql/mysqld.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -3377,7 +3377,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3389,15 +3389,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5079,7 +5079,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/net_serv.cc 2010-08-20 22:20:26.991399708 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.cc 2010-08-20 22:20:26.994733164 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar mysql.orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql.orig/sql/opt_range.h 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/opt_range.h 2010-08-20 22:27:06.589364267 +0000
-@@ -83,7 +83,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -121,7 +121,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -Nuar mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/sql/protocol.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_record.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -285,7 +285,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_rli.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.cc 2010-08-20 22:20:26.998066620 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar mysql.orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql.orig/sql/rpl_utility.h 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/rpl_utility.h 2010-08-20 22:26:52.782192108 +0000
-@@ -295,7 +295,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -Nuar mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/sql/set_var.cc 2010-08-20 22:24:34.027111945 +0000
-@@ -1835,7 +1835,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4020,7 +4020,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -Nuar mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/slave.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -1737,7 +1737,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2354,7 +2354,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4050,7 +4050,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/spatial.h 2010-08-20 22:20:27.001400076 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sp_head.cc 2010-08-20 22:20:27.001400076 +0000
-@@ -2453,7 +2453,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2654,7 +2654,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_acl.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_analyse.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_cache.cc 2010-08-20 22:20:27.004733529 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2425,7 +2425,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2480,7 +2480,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2508,7 +2508,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2596,8 +2596,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2629,7 +2629,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2638,7 +2638,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3061,7 +3061,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_class.cc 2010-08-20 22:24:23.626731145 +0000
-@@ -416,7 +416,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -431,7 +431,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2082,7 +2082,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_client.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_connect.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -679,7 +679,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar mysql.orig/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql.orig/sql/sql_load.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_load.cc 2010-08-20 22:20:27.008066985 +0000
-@@ -1109,7 +1109,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -Nuar mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_parse.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -5708,7 +5708,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7212,7 +7212,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_partition.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_plugin.cc 2010-08-20 22:20:27.011400441 +0000
-@@ -508,7 +508,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2124,7 +2124,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_prepare.cc 2010-08-20 22:20:27.014733897 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar mysql.orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql.orig/sql/sql_profile.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_profile.cc 2010-08-20 22:26:43.418515961 +0000
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -Nuar mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_repl.cc 2010-08-20 22:24:15.399763250 +0000
-@@ -1297,12 +1297,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1474,7 +1474,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1745,14 +1745,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1761,7 +1761,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -Nuar mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_select.cc 2010-08-20 22:24:03.355988947 +0000
-@@ -2998,7 +2998,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3934,7 +3934,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3957,7 +3957,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4120,7 +4120,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4440,7 +4440,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4607,7 +4607,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5557,7 +5557,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10473,7 +10473,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13645,7 +13645,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13657,7 +13657,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14355,7 +14355,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14477,7 +14477,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/sql/sql_show.cc 2010-08-20 22:23:46.608709084 +0000
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1871,7 +1871,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2002,7 +2002,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3168,7 +3168,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7042,7 +7042,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_string.cc 2010-08-20 22:23:39.628453503 +0000
-@@ -695,7 +695,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -781,7 +781,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -798,7 +798,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -999,7 +999,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1185,7 +1185,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -Nuar mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2010-08-03 17:24:19.000000000 +0000
-+++ mysql/sql/sql_table.cc 2010-08-20 22:20:27.024734262 +0000
-@@ -3264,7 +3264,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2010-08-03 17:42:08.000000000 +0000
-+++ mysql/sql/sql_yacc.cc 2010-08-20 22:20:27.038068083 +0000
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/sql/sql_yacc.yy 2010-08-20 22:20:27.041401539 +0000
-@@ -1805,7 +1805,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/thr_malloc.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -130,7 +130,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/tztime.cc 2010-08-20 22:20:27.041401539 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/sql/unireg.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -496,7 +496,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -715,7 +715,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2010-08-03 17:24:24.000000000 +0000
-+++ mysql/sql-common/client.c 2010-08-20 22:20:27.044734995 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/sql-common/my_time.c 2010-08-20 22:20:27.044734995 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/csv/ha_tina.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -1193,7 +1193,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1429,7 +1429,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/federated/ha_federated.cc 2010-08-20 22:20:27.044734995 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/heap/hp_test2.c 2010-08-20 22:20:27.048068451 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2010-08-20 22:20:27.048068451 +0000
-@@ -1527,7 +1527,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_cache.c 2010-08-20 22:20:27.048068451 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_check.c 2010-08-20 22:20:27.048068451 +0000
-@@ -2172,7 +2172,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2328,7 +2328,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2781,7 +2781,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4330,7 +4330,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_create.c 2010-08-20 22:20:27.048068451 +0000
-@@ -437,8 +437,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -527,7 +527,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -565,7 +565,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -880,7 +880,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_extra.c 2010-08-20 22:20:27.051401907 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_open.c 2010-08-20 22:20:27.051401907 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2010-08-20 22:20:27.051401907 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test1.c 2010-08-20 22:20:27.051401907 +0000
-@@ -435,7 +435,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/mi_test2.c 2010-08-20 22:20:27.051401907 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisamlog.c 2010-08-20 22:20:27.051401907 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/storage/myisam/myisampack.c 2010-08-20 22:20:27.054735360 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2010-08-03 17:24:33.000000000 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2010-08-20 22:20:27.054735360 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2010-08-03 17:24:34.000000000 +0000
-+++ mysql/storage/myisam/sort.c 2010-08-20 22:20:27.054735360 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2010-08-03 17:24:27.000000000 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2010-08-20 22:20:27.054735360 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-03 17:24:31.000000000 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2010-08-20 22:20:27.054735360 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2010-08-20 22:20:27.054735360 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-big5.c 2010-08-20 22:20:27.058068816 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-bin.c 2010-08-20 22:20:27.058068816 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-gbk.c 2010-08-20 22:20:27.061402272 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-mb.c 2010-08-20 22:20:27.064735728 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-simple.c 2010-08-20 22:20:27.064735728 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-tis620.c 2010-08-20 22:20:27.064735728 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-uca.c 2010-08-20 22:20:27.068069184 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-ucs2.c 2010-08-20 22:20:27.068069184 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2010-08-03 17:24:25.000000000 +0000
-+++ mysql/strings/ctype-utf8.c 2010-08-20 22:20:27.071402637 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2010-08-03 17:24:26.000000000 +0000
-+++ mysql/strings/decimal.c 2010-08-20 22:20:27.071402637 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2173,11 +2173,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2301,7 +2301,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2339,7 +2339,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2010-08-03 17:24:30.000000000 +0000
-+++ mysql/strings/my_vsnprintf.c 2010-08-20 22:20:27.071402637 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2010-08-03 17:24:35.000000000 +0000
-+++ mysql/strings/str2int.c 2010-08-20 22:20:27.071402637 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2010-08-20 22:18:38.644098669 +0000
-+++ mysql/tests/mysql_client_test.c 2010-08-20 22:20:27.074736093 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2010-08-03 17:24:36.000000000 +0000
-+++ mysql/vio/viosocket.c 2010-08-20 22:20:27.074736093 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.57.patch b/07110_all_mysql_gcc-4.2_5.1.57.patch
deleted file mode 100644
index 24bb194..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.57.patch
+++ /dev/null
@@ -1,3696 +0,0 @@
-
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -urN mysql-old/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-old/client/mysqlbinlog.cc 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/mysqlbinlog.cc 2011-05-10 17:56:01.266682376 +0000
-@@ -1953,7 +1953,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -urN mysql-old/client/mysql.cc mysql/client/mysql.cc
---- mysql-old/client/mysql.cc 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/mysql.cc 2011-05-10 17:56:01.270015709 +0000
-@@ -3336,9 +3336,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3358,7 +3358,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -urN mysql-old/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-old/client/mysqldump.c 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/mysqldump.c 2011-05-10 17:56:01.273349042 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4523,7 +4523,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -urN mysql-old/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-old/client/mysqltest.cc 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/mysqltest.cc 2011-05-10 17:56:01.293349043 +0000
-@@ -5652,9 +5652,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -urN mysql-old/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-old/client/mysql_upgrade.c 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/mysql_upgrade.c 2011-05-10 17:56:01.296682376 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -urN mysql-old/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-old/client/sql_string.cc 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/client/sql_string.cc 2011-05-10 17:56:01.296682376 +0000
-@@ -660,7 +660,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -746,7 +746,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -763,7 +763,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -urN mysql-old/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-old/dbug/dbug.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/dbug/dbug.c 2011-05-10 17:56:01.296682376 +0000
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -urN mysql-old/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-old/extra/yassl/src/ssl.cpp 2011-05-10 17:45:45.696682376 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2011-05-10 17:56:01.300015709 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -urN mysql-old/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql-old/extra/yassl/taocrypt/include/pwdbased.hpp 2011-05-10 17:45:45.696682376 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2011-05-10 17:56:01.300015709 +0000
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -urN mysql-old/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-old/extra/yassl/taocrypt/src/dh.cpp 2011-05-10 17:45:45.696682376 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2011-05-10 17:56:01.300015709 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -urN mysql-old/include/my_global.h mysql/include/my_global.h
---- mysql-old/include/my_global.h 2011-05-10 17:45:45.726682376 +0000
-+++ mysql/include/my_global.h 2011-05-10 17:56:01.300015709 +0000
-@@ -584,10 +584,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-@@ -1535,6 +1533,8 @@
- /* Define some useful general macros (should be done after all headers). */
- #if !defined(max)
- #define max(a, b) ((a) > (b) ? (a) : (b))
-+#endif
-+#if !defined(min)
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #endif
- /*
-diff -urN mysql-old/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-old/libmysql/libmysql.c 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/libmysql/libmysql.c 2011-05-10 17:56:01.303349042 +0000
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -urN mysql-old/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-old/libmysqld/lib_sql.cc 2011-05-10 17:45:45.620015710 +0000
-+++ mysql/libmysqld/lib_sql.cc 2011-05-10 17:56:01.303349042 +0000
-@@ -824,7 +824,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -urN mysql-old/mysys/array.c mysql/mysys/array.c
---- mysql-old/mysys/array.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/array.c 2011-05-10 17:56:01.306682376 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -urN mysql-old/mysys/default.c mysql/mysys/default.c
---- mysql-old/mysys/default.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/default.c 2011-05-10 17:56:01.306682376 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -urN mysql-old/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-old/mysys/mf_format.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/mf_format.c 2011-05-10 17:56:01.306682376 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -urN mysql-old/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-old/mysys/mf_iocache.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/mf_iocache.c 2011-05-10 17:56:01.306682376 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -urN mysql-old/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-old/mysys/my_alloc.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/my_alloc.c 2011-05-10 17:56:01.310015710 +0000
-@@ -212,7 +212,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -urN mysql-old/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-old/mysys/my_bitmap.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/my_bitmap.c 2011-05-10 17:56:01.310015710 +0000
-@@ -423,7 +423,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -urN mysql-old/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-old/mysys/my_compress.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/my_compress.c 2011-05-10 17:56:01.310015710 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -urN mysql-old/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-old/mysys/my_conio.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/my_conio.c 2011-05-10 17:56:01.310015710 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -urN mysql-old/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-old/mysys/my_file.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/mysys/my_file.c 2011-05-10 17:56:01.310015710 +0000
-@@ -75,7 +75,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -urN mysql-old/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-old/mysys/my_getopt.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/my_getopt.c 2011-05-10 17:56:01.310015710 +0000
-@@ -983,7 +983,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -urN mysql-old/mysys/my_static.h mysql/mysys/my_static.h
---- mysql-old/mysys/my_static.h 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/mysys/my_static.h 2011-05-10 17:56:01.310015710 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -urN mysql-old/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-old/mysys/safemalloc.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/safemalloc.c 2011-05-10 17:56:01.313349044 +0000
-@@ -248,7 +248,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -urN mysql-old/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-old/mysys/stacktrace.c 2011-05-10 17:45:45.700015709 +0000
-+++ mysql/mysys/stacktrace.c 2011-05-10 17:56:01.313349044 +0000
-@@ -324,7 +324,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -urN mysql-old/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-old/server-tools/instance-manager/buffer.cc 2011-05-10 17:45:45.436682376 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2011-05-10 17:56:01.313349044 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -urN mysql-old/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-old/server-tools/instance-manager/listener.cc 2011-05-10 17:45:45.436682376 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2011-05-10 17:56:01.313349044 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -urN mysql-old/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql-old/sql/debug_sync.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/debug_sync.cc 2011-05-10 17:56:01.313349044 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -urN mysql-old/sql/field.cc mysql/sql/field.cc
---- mysql-old/sql/field.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/field.cc 2011-05-10 17:56:01.316682377 +0000
-@@ -54,7 +54,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2072,7 +2072,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2080,7 +2080,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2505,7 +2505,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2521,7 +2521,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3091,7 +3091,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3303,7 +3303,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3520,7 +3520,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3739,7 +3739,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3980,7 +3980,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4203,7 +4203,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6440,13 +6440,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6454,7 +6454,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6712,7 +6712,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7706,7 +7706,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7866,7 +7866,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8062,7 +8062,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9109,7 +9109,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9195,7 +9195,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9323,7 +9323,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9780,7 +9780,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -urN mysql-old/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-old/sql/filesort.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/filesort.cc 2011-05-10 17:56:01.320015710 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1117,7 +1117,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1380,7 +1380,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -urN mysql-old/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-old/sql/ha_ndbcluster.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2011-05-10 17:56:01.323349043 +0000
-@@ -800,7 +800,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -urN mysql-old/sql/handler.h mysql/sql/handler.h
---- mysql-old/sql/handler.h 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/sql/handler.h 2011-05-10 17:56:01.330015709 +0000
-@@ -1605,15 +1605,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -urN mysql-old/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql-old/sql/ha_partition.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/ha_partition.cc 2011-05-10 17:56:01.330015709 +0000
-@@ -5968,7 +5968,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -urN mysql-old/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-old/sql/item_buff.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/item_buff.cc 2011-05-10 17:56:01.333349042 +0000
-@@ -59,7 +59,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -69,7 +69,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -urN mysql-old/sql/item.cc mysql/sql/item.cc
---- mysql-old/sql/item.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/item.cc 2011-05-10 17:56:01.336682376 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -442,9 +442,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -750,7 +750,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5414,7 +5414,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5469,7 +5469,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7559,14 +7559,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7597,7 +7597,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7619,7 +7619,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7637,7 +7637,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -urN mysql-old/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-old/sql/item_cmpfunc.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/item_cmpfunc.cc 2011-05-10 17:56:01.340015710 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4981,7 +4981,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -5000,7 +5000,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5121,14 +5121,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5152,14 +5152,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -urN mysql-old/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-old/sql/item_func.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/item_func.cc 2011-05-10 17:56:01.346682377 +0000
-@@ -550,7 +550,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1144,10 +1144,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1257,9 +1257,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1307,7 +1307,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1316,7 +1316,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1330,7 +1330,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1461,8 +1461,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1981,7 +1981,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1991,7 +1991,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2008,13 +2008,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2115,7 +2115,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2990,7 +2990,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2999,7 +2999,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -urN mysql-old/sql/item_func.h mysql/sql/item_func.h
---- mysql-old/sql/item_func.h 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/sql/item_func.h 2011-05-10 17:56:01.346682377 +0000
-@@ -420,7 +420,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -urN mysql-old/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-old/sql/item_strfunc.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/item_strfunc.cc 2011-05-10 17:56:01.350015710 +0000
-@@ -388,7 +388,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -749,7 +749,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1250,7 +1250,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1270,7 +1270,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1961,7 +1961,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3113,11 +3113,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3580,7 +3580,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -urN mysql-old/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-old/sql/item_sum.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/item_sum.cc 2011-05-10 17:56:01.353349043 +0000
-@@ -1143,7 +1143,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1206,16 +1206,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1406,13 +1406,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3349,7 +3349,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -urN mysql-old/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-old/sql/item_timefunc.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/item_timefunc.cc 2011-05-10 17:56:01.356682376 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1823,7 +1823,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -urN mysql-old/sql/key.cc mysql/sql/key.cc
---- mysql-old/sql/key.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/key.cc 2011-05-10 17:56:01.356682376 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -urN mysql-old/sql/log.cc mysql/sql/log.cc
---- mysql-old/sql/log.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/log.cc 2011-05-10 17:56:01.360015709 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2429,7 +2429,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5236,7 +5236,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -urN mysql-old/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-old/sql/log_event.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/log_event.cc 2011-05-10 17:56:01.456682377 +0000
-@@ -1075,7 +1075,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2671,7 +2671,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5588,7 +5588,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7315,7 +7315,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-old/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql-old/sql/log_event_old.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/log_event_old.cc 2011-05-10 17:56:01.460015710 +0000
-@@ -1420,7 +1420,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-old/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-old/sql/mysqld.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/mysqld.cc 2011-05-10 17:56:01.463349043 +0000
-@@ -3383,7 +3383,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3395,15 +3395,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5085,7 +5085,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -urN mysql-old/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-old/sql/net_serv.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/net_serv.cc 2011-05-10 17:56:01.466682376 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -urN mysql-old/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-old/sql/opt_range.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/opt_range.cc 2011-05-10 17:56:01.470015709 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -urN mysql-old/sql/opt_range.h mysql/sql/opt_range.h
---- mysql-old/sql/opt_range.h 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/sql/opt_range.h 2011-05-10 17:56:01.476682376 +0000
-@@ -83,7 +83,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -121,7 +121,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -urN mysql-old/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-old/sql/protocol.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/protocol.cc 2011-05-10 17:56:01.476682376 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -urN mysql-old/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-old/sql/rpl_record.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/rpl_record.cc 2011-05-10 17:56:01.476682376 +0000
-@@ -285,7 +285,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -urN mysql-old/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-old/sql/rpl_rli.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/rpl_rli.cc 2011-05-10 17:56:01.476682376 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -urN mysql-old/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-old/sql/rpl_utility.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/rpl_utility.cc 2011-05-10 17:56:01.480015710 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -urN mysql-old/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql-old/sql/rpl_utility.h 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/sql/rpl_utility.h 2011-05-10 17:56:01.480015710 +0000
-@@ -295,7 +295,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -urN mysql-old/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-old/sql/set_var.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/set_var.cc 2011-05-10 17:56:01.480015710 +0000
-@@ -1845,7 +1845,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4030,7 +4030,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -urN mysql-old/sql/slave.cc mysql/sql/slave.cc
---- mysql-old/sql/slave.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/slave.cc 2011-05-10 17:56:01.483349044 +0000
-@@ -1737,7 +1737,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2354,7 +2354,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4050,7 +4050,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -urN mysql-old/sql/spatial.h mysql/sql/spatial.h
---- mysql-old/sql/spatial.h 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/sql/spatial.h 2011-05-10 17:56:01.486682377 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -urN mysql-old/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-old/sql/sp_head.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sp_head.cc 2011-05-10 17:56:01.486682377 +0000
-@@ -2453,7 +2453,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2654,7 +2654,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -urN mysql-old/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-old/sql/sql_acl.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/sql_acl.cc 2011-05-10 17:56:01.490015710 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -urN mysql-old/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-old/sql/sql_analyse.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_analyse.cc 2011-05-10 17:56:01.493349043 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -urN mysql-old/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-old/sql/sql_cache.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_cache.cc 2011-05-10 17:56:01.493349043 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2425,7 +2425,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2480,7 +2480,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2508,7 +2508,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2596,8 +2596,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2629,7 +2629,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2638,7 +2638,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3061,7 +3061,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -urN mysql-old/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-old/sql/sql_class.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/sql_class.cc 2011-05-10 17:56:01.500015709 +0000
-@@ -416,7 +416,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -431,7 +431,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2082,7 +2082,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -urN mysql-old/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-old/sql/sql_client.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_client.cc 2011-05-10 17:56:01.500015709 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -urN mysql-old/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-old/sql/sql_connect.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/sql_connect.cc 2011-05-10 17:56:01.503349042 +0000
-@@ -789,7 +789,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -urN mysql-old/sql/sql_load.cc mysql/sql/sql_load.cc
---- mysql-old/sql/sql_load.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_load.cc 2011-05-10 17:56:01.503349042 +0000
-@@ -1109,7 +1109,7 @@
-
-
- /* Set of a stack for unget if long terminators */
-- uint length=max(field_term_length,line_term_length)+1;
-+ uint length=MYSQL_MAX(field_term_length,line_term_length)+1;
- set_if_bigger(length,line_start.length());
- stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
-
-diff -urN mysql-old/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-old/sql/sql_parse.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/sql_parse.cc 2011-05-10 17:56:01.510015710 +0000
-@@ -5722,7 +5722,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7226,7 +7226,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -urN mysql-old/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-old/sql/sql_partition.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/sql_partition.cc 2011-05-10 17:56:01.513349044 +0000
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -urN mysql-old/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-old/sql/sql_plugin.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_plugin.cc 2011-05-10 17:56:01.516682377 +0000
-@@ -508,7 +508,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2124,7 +2124,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -urN mysql-old/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-old/sql/sql_prepare.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/sql_prepare.cc 2011-05-10 17:56:01.520015710 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -urN mysql-old/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql-old/sql/sql_profile.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/sql_profile.cc 2011-05-10 17:56:01.520015710 +0000
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -urN mysql-old/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-old/sql/sql_repl.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_repl.cc 2011-05-10 17:56:01.523349043 +0000
-@@ -1297,12 +1297,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1474,7 +1474,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1745,14 +1745,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1761,7 +1761,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -urN mysql-old/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-old/sql/sql_select.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/sql_select.cc 2011-05-10 17:56:01.526682376 +0000
-@@ -3002,7 +3002,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3938,7 +3938,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3961,7 +3961,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4124,7 +4124,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4444,7 +4444,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4611,7 +4611,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5561,7 +5561,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10477,7 +10477,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13649,7 +13649,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13661,7 +13661,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14359,7 +14359,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14481,7 +14481,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -urN mysql-old/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-old/sql/sql_show.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_show.cc 2011-05-10 17:56:01.596682375 +0000
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1871,7 +1871,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2002,7 +2002,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3168,7 +3168,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7044,7 +7044,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -urN mysql-old/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-old/sql/sql_string.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/sql_string.cc 2011-05-10 17:56:01.616682376 +0000
-@@ -695,7 +695,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -781,7 +781,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -798,7 +798,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -999,7 +999,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1185,7 +1185,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -urN mysql-old/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-old/sql/sql_table.cc 2011-05-10 17:45:45.626682377 +0000
-+++ mysql/sql/sql_table.cc 2011-05-10 17:56:01.620015709 +0000
-@@ -3274,7 +3274,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -urN mysql-old/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-old/sql/sql_yacc.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/sql_yacc.cc 2011-05-10 17:56:01.630015710 +0000
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -urN mysql-old/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql-old/sql/sql_yacc.yy 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/sql_yacc.yy 2011-05-10 17:56:01.650015709 +0000
-@@ -1805,7 +1805,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -urN mysql-old/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-old/sql/thr_malloc.cc 2011-05-10 17:45:45.633349043 +0000
-+++ mysql/sql/thr_malloc.cc 2011-05-10 17:56:01.656682376 +0000
-@@ -130,7 +130,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -urN mysql-old/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-old/sql/tztime.cc 2011-05-10 17:45:45.636682376 +0000
-+++ mysql/sql/tztime.cc 2011-05-10 17:56:01.656682376 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -urN mysql-old/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-old/sql/unireg.cc 2011-05-10 17:45:45.630015710 +0000
-+++ mysql/sql/unireg.cc 2011-05-10 17:56:01.660015710 +0000
-@@ -496,7 +496,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -715,7 +715,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -urN mysql-old/sql-common/client.c mysql/sql-common/client.c
---- mysql-old/sql-common/client.c 2011-05-10 17:45:45.710015710 +0000
-+++ mysql/sql-common/client.c 2011-05-10 17:56:01.660015710 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -urN mysql-old/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-old/sql-common/my_time.c 2011-05-10 17:45:45.710015710 +0000
-+++ mysql/sql-common/my_time.c 2011-05-10 17:56:01.660015710 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -urN mysql-old/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-old/storage/csv/ha_tina.cc 2011-05-10 17:45:45.693349043 +0000
-+++ mysql/storage/csv/ha_tina.cc 2011-05-10 17:56:01.663349044 +0000
-@@ -1193,7 +1193,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1429,7 +1429,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -urN mysql-old/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-old/storage/federated/ha_federated.cc 2011-05-10 17:45:45.690015710 +0000
-+++ mysql/storage/federated/ha_federated.cc 2011-05-10 17:56:01.663349044 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -urN mysql-old/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-old/storage/heap/hp_create.c 2011-05-10 17:45:45.690015710 +0000
-+++ mysql/storage/heap/hp_create.c 2011-05-10 17:56:01.666682377 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -urN mysql-old/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-old/storage/heap/hp_test2.c 2011-05-10 17:45:45.690015710 +0000
-+++ mysql/storage/heap/hp_test2.c 2011-05-10 17:56:01.723349044 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -urN mysql-old/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-old/storage/myisam/ha_myisam.cc 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2011-05-10 17:56:01.723349044 +0000
-@@ -1527,7 +1527,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -urN mysql-old/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-old/storage/myisam/mi_cache.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_cache.c 2011-05-10 17:56:01.723349044 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -urN mysql-old/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-old/storage/myisam/mi_check.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_check.c 2011-05-10 17:56:01.726682377 +0000
-@@ -2173,7 +2173,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2329,7 +2329,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2782,7 +2782,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -4331,7 +4331,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -urN mysql-old/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-old/storage/myisam/mi_create.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_create.c 2011-05-10 17:56:01.726682377 +0000
-@@ -437,8 +437,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -527,7 +527,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -565,7 +565,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -urN mysql-old/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-old/storage/myisam/mi_dynrec.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2011-05-10 17:56:01.730015710 +0000
-@@ -880,7 +880,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -urN mysql-old/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-old/storage/myisam/mi_extra.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_extra.c 2011-05-10 17:56:01.730015710 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -urN mysql-old/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-old/storage/myisam/mi_open.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_open.c 2011-05-10 17:56:01.730015710 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -urN mysql-old/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-old/storage/myisam/mi_packrec.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2011-05-10 17:56:01.733349043 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -urN mysql-old/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-old/storage/myisam/mi_test1.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_test1.c 2011-05-10 17:56:01.733349043 +0000
-@@ -436,7 +436,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -urN mysql-old/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-old/storage/myisam/mi_test2.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/mi_test2.c 2011-05-10 17:56:01.733349043 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -urN mysql-old/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-old/storage/myisam/myisamlog.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/myisamlog.c 2011-05-10 17:56:01.733349043 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -urN mysql-old/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-old/storage/myisam/myisampack.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/myisampack.c 2011-05-10 17:56:01.736682376 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -urN mysql-old/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-old/storage/myisam/rt_mbr.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2011-05-10 17:56:01.736682376 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -urN mysql-old/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-old/storage/myisam/sort.c 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisam/sort.c 2011-05-10 17:56:01.736682376 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -urN mysql-old/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-old/storage/myisammrg/ha_myisammrg.cc 2011-05-10 17:45:45.670015709 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2011-05-10 17:56:01.740015709 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -urN mysql-old/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-old/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-05-10 17:45:45.666682376 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-05-10 17:56:01.740015709 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -urN mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-old/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-05-10 17:45:45.656682377 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-05-10 17:56:01.740015709 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -urN mysql-old/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-old/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-05-10 17:45:45.653349044 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-05-10 17:56:01.740015709 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -urN mysql-old/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-old/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-05-10 17:45:45.650015710 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-05-10 17:56:01.743349042 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -urN mysql-old/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-old/storage/ndb/test/src/getarg.c 2011-05-10 17:45:45.650015710 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2011-05-10 17:56:01.743349042 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -urN mysql-old/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-old/strings/ctype-big5.c 2011-05-10 17:45:45.706682376 +0000
-+++ mysql/strings/ctype-big5.c 2011-05-10 17:56:01.743349042 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-old/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-old/strings/ctype-bin.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-bin.c 2011-05-10 17:56:01.750015710 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-old/strings/ctype-gbk.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-gbk.c 2011-05-10 17:56:01.753349044 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-old/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-old/strings/ctype-mb.c 2011-05-10 17:45:45.706682376 +0000
-+++ mysql/strings/ctype-mb.c 2011-05-10 17:56:01.760015710 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-old/strings/ctype-simple.c 2011-05-10 17:45:45.706682376 +0000
-+++ mysql/strings/ctype-simple.c 2011-05-10 17:56:01.760015710 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -urN mysql-old/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-old/strings/ctype-tis620.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-tis620.c 2011-05-10 17:56:01.760015710 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -urN mysql-old/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-old/strings/ctype-uca.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-uca.c 2011-05-10 17:56:01.763349043 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -urN mysql-old/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-old/strings/ctype-ucs2.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-ucs2.c 2011-05-10 17:56:01.773349042 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-old/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-old/strings/ctype-utf8.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/ctype-utf8.c 2011-05-10 17:56:01.776682376 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -urN mysql-old/strings/decimal.c mysql/strings/decimal.c
---- mysql-old/strings/decimal.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/decimal.c 2011-05-10 17:56:01.780015710 +0000
-@@ -403,7 +403,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -426,7 +426,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1517,8 +1517,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1529,7 +1529,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1631,7 +1631,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1650,7 +1650,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1699,11 +1699,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1718,7 +1718,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1743,7 +1743,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1772,14 +1772,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... max(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1800,7 +1800,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1875,7 +1875,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1910,7 +1910,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2173,11 +2173,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2301,7 +2301,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2339,7 +2339,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -urN mysql-old/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-old/strings/my_vsnprintf.c 2011-05-10 17:45:45.703349042 +0000
-+++ mysql/strings/my_vsnprintf.c 2011-05-10 17:56:01.846682377 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -urN mysql-old/strings/str2int.c mysql/strings/str2int.c
---- mysql-old/strings/str2int.c 2011-05-10 17:45:45.706682376 +0000
-+++ mysql/strings/str2int.c 2011-05-10 17:56:01.846682377 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -urN mysql-old/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql-old/tests/mysql_client_test.c 2011-05-10 17:45:45.620015710 +0000
-+++ mysql/tests/mysql_client_test.c 2011-05-10 17:56:01.850015711 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -urN mysql-old/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-old/vio/viosocket.c 2011-05-10 17:45:45.640015709 +0000
-+++ mysql/vio/viosocket.c 2011-05-10 17:56:01.856682377 +0000
-@@ -69,7 +69,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.58.patch b/07110_all_mysql_gcc-4.2_5.1.58.patch
deleted file mode 100644
index a4f56e2..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.58.patch
+++ /dev/null
@@ -1,3859 +0,0 @@
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -urN mysql-orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-orig/client/mysqlbinlog.cc 2011-07-21 02:15:51.904095298 +0000
-+++ mysql/client/mysqlbinlog.cc 2011-07-21 02:16:28.801095322 +0000
-@@ -1954,7 +1954,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -urN mysql-orig/client/mysql.cc mysql/client/mysql.cc
---- mysql-orig/client/mysql.cc 2011-07-21 02:15:51.903095298 +0000
-+++ mysql/client/mysql.cc 2011-07-21 02:16:28.803095322 +0000
-@@ -3336,9 +3336,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3358,7 +3358,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -urN mysql-orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-orig/client/mysqldump.c 2011-07-21 02:15:51.904095298 +0000
-+++ mysql/client/mysqldump.c 2011-07-21 02:16:28.806095322 +0000
-@@ -830,7 +830,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4523,7 +4523,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -urN mysql-orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-orig/client/mysqltest.cc 2011-07-21 02:15:51.903095298 +0000
-+++ mysql/client/mysqltest.cc 2011-07-21 02:16:28.810095322 +0000
-@@ -5654,9 +5654,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -urN mysql-orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-orig/client/mysql_upgrade.c 2011-07-21 02:15:51.903095298 +0000
-+++ mysql/client/mysql_upgrade.c 2011-07-21 02:16:28.814095322 +0000
-@@ -528,7 +528,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -urN mysql-orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-orig/client/sql_string.cc 2011-07-21 02:15:51.904095298 +0000
-+++ mysql/client/sql_string.cc 2011-07-21 02:16:28.815095322 +0000
-@@ -660,7 +660,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -746,7 +746,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -763,7 +763,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -urN mysql-orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-orig/dbug/dbug.c 2011-07-21 02:15:51.908095298 +0000
-+++ mysql/dbug/dbug.c 2011-07-21 02:16:28.816095322 +0000
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -urN mysql-orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-orig/extra/yassl/src/ssl.cpp 2011-07-21 02:15:52.091095298 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2011-07-21 02:16:28.818095322 +0000
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -urN mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp 2011-07-21 02:15:52.089095298 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2011-07-21 02:16:28.818095322 +0000
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -urN mysql-orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-orig/extra/yassl/taocrypt/src/dh.cpp 2011-07-21 02:15:52.090095298 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2011-07-21 02:16:28.818095322 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -urN mysql-orig/include/my_global.h mysql/include/my_global.h
---- mysql-orig/include/my_global.h 2011-07-21 02:15:51.905095298 +0000
-+++ mysql/include/my_global.h 2011-07-21 02:17:54.425095383 +0000
-@@ -584,10 +584,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -urN mysql-orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-orig/libmysql/libmysql.c 2011-07-21 02:15:52.076095298 +0000
-+++ mysql/libmysql/libmysql.c 2011-07-21 02:16:28.821095322 +0000
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -urN mysql-orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-orig/libmysqld/lib_sql.cc 2011-07-21 02:15:51.924095298 +0000
-+++ mysql/libmysqld/lib_sql.cc 2011-07-21 02:16:28.822095322 +0000
-@@ -848,7 +848,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -urN mysql-orig/mysys/array.c mysql/mysys/array.c
---- mysql-orig/mysys/array.c 2011-07-21 02:15:51.940095298 +0000
-+++ mysql/mysys/array.c 2011-07-21 02:16:28.823095322 +0000
-@@ -47,7 +47,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -341,7 +341,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -urN mysql-orig/mysys/default.c mysql/mysys/default.c
---- mysql-orig/mysys/default.c 2011-07-21 02:15:51.942095298 +0000
-+++ mysql/mysys/default.c 2011-07-21 02:16:28.823095322 +0000
-@@ -793,7 +793,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -urN mysql-orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-orig/mysys/mf_format.c 2011-07-21 02:15:51.942095298 +0000
-+++ mysql/mysys/mf_format.c 2011-07-21 02:16:28.824095322 +0000
-@@ -83,7 +83,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -urN mysql-orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-orig/mysys/mf_iocache.c 2011-07-21 02:15:51.941095298 +0000
-+++ mysql/mysys/mf_iocache.c 2011-07-21 02:16:28.825095322 +0000
-@@ -1097,7 +1097,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1256,7 +1256,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1365,7 +1365,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1399,7 +1399,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -urN mysql-orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-orig/mysys/my_alloc.c 2011-07-21 02:15:51.941095298 +0000
-+++ mysql/mysys/my_alloc.c 2011-07-21 02:16:28.826095322 +0000
-@@ -212,7 +212,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -urN mysql-orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-orig/mysys/my_bitmap.c 2011-07-21 02:15:51.942095298 +0000
-+++ mysql/mysys/my_bitmap.c 2011-07-21 02:16:28.826095322 +0000
-@@ -423,7 +423,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -urN mysql-orig/mysys/my_compare.c mysql/mysys/my_compare.c
---- mysql-orig/mysys/my_compare.c 2011-07-21 02:15:51.942095298 +0000
-+++ mysql/mysys/my_compare.c 2011-07-21 02:16:28.827095322 +0000
-@@ -30,7 +30,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -158,7 +158,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -urN mysql-orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-orig/mysys/my_compress.c 2011-07-21 02:15:51.943095298 +0000
-+++ mysql/mysys/my_compress.c 2011-07-21 02:16:28.827095322 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -urN mysql-orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-orig/mysys/my_conio.c 2011-07-21 02:15:51.941095298 +0000
-+++ mysql/mysys/my_conio.c 2011-07-21 02:16:28.829095322 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -urN mysql-orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-orig/mysys/my_file.c 2011-07-21 02:15:51.940095298 +0000
-+++ mysql/mysys/my_file.c 2011-07-21 02:16:28.829095322 +0000
-@@ -75,7 +75,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -97,7 +97,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -107,9 +107,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -urN mysql-orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-orig/mysys/my_getopt.c 2011-07-21 02:15:51.943095298 +0000
-+++ mysql/mysys/my_getopt.c 2011-07-21 02:16:28.830095322 +0000
-@@ -983,7 +983,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -urN mysql-orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql-orig/mysys/my_static.h 2011-07-21 02:15:51.941095298 +0000
-+++ mysql/mysys/my_static.h 2011-07-21 02:16:28.830095322 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -urN mysql-orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-orig/mysys/safemalloc.c 2011-07-21 02:15:51.941095298 +0000
-+++ mysql/mysys/safemalloc.c 2011-07-21 02:16:28.831095322 +0000
-@@ -248,7 +248,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -urN mysql-orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-orig/mysys/stacktrace.c 2011-07-21 02:15:51.943095298 +0000
-+++ mysql/mysys/stacktrace.c 2011-07-21 02:16:28.831095322 +0000
-@@ -96,7 +96,7 @@
- /* Read up to the maximum number of bytes. */
- while (total)
- {
-- count= min(sizeof(buf), total);
-+ count= MYSQL_MIN(sizeof(buf), total);
-
- if ((nbytes= pread(fd, buf, count, offset)) < 0)
- {
-@@ -324,7 +324,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -urN mysql-orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-orig/server-tools/instance-manager/buffer.cc 2011-07-21 02:15:51.929095298 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2011-07-21 02:16:28.832095322 +0000
-@@ -83,8 +83,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -urN mysql-orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-orig/server-tools/instance-manager/listener.cc 2011-07-21 02:15:51.927095298 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2011-07-21 02:16:28.832095322 +0000
-@@ -103,7 +103,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -urN mysql-orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql-orig/sql/debug_sync.cc 2011-07-21 02:15:51.955095298 +0000
-+++ mysql/sql/debug_sync.cc 2011-07-21 02:16:28.834095322 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -urN mysql-orig/sql/field.cc mysql/sql/field.cc
---- mysql-orig/sql/field.cc 2011-07-21 02:15:51.956095298 +0000
-+++ mysql/sql/field.cc 2011-07-21 02:16:28.838095322 +0000
-@@ -53,7 +53,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2071,7 +2071,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2079,7 +2079,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2504,7 +2504,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2520,7 +2520,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3090,7 +3090,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3302,7 +3302,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3519,7 +3519,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3738,7 +3738,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3979,7 +3979,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4202,7 +4202,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6441,13 +6441,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6455,7 +6455,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6713,7 +6713,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7707,7 +7707,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7867,7 +7867,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8063,7 +8063,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9110,7 +9110,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9196,7 +9196,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9324,7 +9324,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9781,7 +9781,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -urN mysql-orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-orig/sql/filesort.cc 2011-07-21 02:15:51.950095298 +0000
-+++ mysql/sql/filesort.cc 2011-07-21 02:16:28.841095322 +0000
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1117,7 +1117,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1380,7 +1380,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -urN mysql-orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-orig/sql/ha_ndbcluster.cc 2011-07-21 02:15:51.962095298 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2011-07-21 02:16:28.845095322 +0000
-@@ -799,7 +799,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -urN mysql-orig/sql/handler.h mysql/sql/handler.h
---- mysql-orig/sql/handler.h 2011-07-21 02:15:51.955095298 +0000
-+++ mysql/sql/handler.h 2011-07-21 02:16:28.847095322 +0000
-@@ -1606,15 +1606,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -urN mysql-orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql-orig/sql/ha_partition.cc 2011-07-21 02:15:51.953095298 +0000
-+++ mysql/sql/ha_partition.cc 2011-07-21 02:16:28.850095322 +0000
-@@ -6131,7 +6131,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -urN mysql-orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-orig/sql/item_buff.cc 2011-07-21 02:15:51.951095298 +0000
-+++ mysql/sql/item_buff.cc 2011-07-21 02:16:28.852095322 +0000
-@@ -59,7 +59,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -69,7 +69,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -urN mysql-orig/sql/item.cc mysql/sql/item.cc
---- mysql-orig/sql/item.cc 2011-07-21 02:15:51.961095298 +0000
-+++ mysql/sql/item.cc 2011-07-21 02:16:28.854095322 +0000
-@@ -74,7 +74,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -442,9 +442,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -750,7 +750,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5414,7 +5414,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5469,7 +5469,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7559,14 +7559,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7597,7 +7597,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7619,7 +7619,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7637,7 +7637,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -urN mysql-orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-orig/sql/item_cmpfunc.cc 2011-07-21 02:15:51.954095298 +0000
-+++ mysql/sql/item_cmpfunc.cc 2011-07-21 02:16:28.857095322 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4979,7 +4979,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4998,7 +4998,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5119,14 +5119,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5150,14 +5150,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -urN mysql-orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-orig/sql/item_func.cc 2011-07-21 02:15:51.957095298 +0000
-+++ mysql/sql/item_func.cc 2011-07-21 02:16:28.860095322 +0000
-@@ -549,7 +549,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1143,10 +1143,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1256,9 +1256,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1306,7 +1306,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1315,7 +1315,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1329,7 +1329,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1460,8 +1460,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1983,7 +1983,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1993,7 +1993,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2010,13 +2010,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2117,7 +2117,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2989,7 +2989,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2998,7 +2998,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -urN mysql-orig/sql/item_func.h mysql/sql/item_func.h
---- mysql-orig/sql/item_func.h 2011-07-21 02:15:51.954095298 +0000
-+++ mysql/sql/item_func.h 2011-07-21 02:16:28.861095322 +0000
-@@ -420,7 +420,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -urN mysql-orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-orig/sql/item_strfunc.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/item_strfunc.cc 2011-07-21 02:16:28.863095322 +0000
-@@ -387,7 +387,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -748,7 +748,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1249,7 +1249,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1269,7 +1269,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1960,7 +1960,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3112,11 +3112,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3580,7 +3580,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -urN mysql-orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql-orig/sql/item_strfunc.h 2011-07-21 02:15:51.951095298 +0000
-+++ mysql/sql/item_strfunc.h 2011-07-21 02:16:28.864095322 +0000
-@@ -707,7 +707,7 @@
- collation.set(args[0]->collation);
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
- 2 * collation.collation->mbmaxlen;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- }
- };
-
-diff -urN mysql-orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-orig/sql/item_sum.cc 2011-07-21 02:15:51.955095298 +0000
-+++ mysql/sql/item_sum.cc 2011-07-21 02:16:28.865095322 +0000
-@@ -1139,7 +1139,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1202,16 +1202,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1402,13 +1402,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3345,7 +3345,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -urN mysql-orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-orig/sql/item_timefunc.cc 2011-07-21 02:15:51.961095298 +0000
-+++ mysql/sql/item_timefunc.cc 2011-07-21 02:16:28.867095322 +0000
-@@ -308,14 +308,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -324,7 +324,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -341,15 +341,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -360,14 +360,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -375,7 +375,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -427,7 +427,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -439,7 +439,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -451,7 +451,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -596,7 +596,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1828,7 +1828,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -urN mysql-orig/sql/key.cc mysql/sql/key.cc
---- mysql-orig/sql/key.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/key.cc 2011-07-21 02:16:28.868095322 +0000
-@@ -125,13 +125,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -215,7 +215,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -224,7 +224,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -285,7 +285,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -351,7 +351,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -urN mysql-orig/sql/log.cc mysql/sql/log.cc
---- mysql-orig/sql/log.cc 2011-07-21 02:15:51.950095298 +0000
-+++ mysql/sql/log.cc 2011-07-21 02:16:28.870095322 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2429,7 +2429,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5237,7 +5237,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -urN mysql-orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-orig/sql/log_event.cc 2011-07-21 02:15:51.955095298 +0000
-+++ mysql/sql/log_event.cc 2011-07-21 02:16:28.873095322 +0000
-@@ -1075,7 +1075,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2671,7 +2671,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5588,7 +5588,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7315,7 +7315,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql-orig/sql/log_event_old.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/log_event_old.cc 2011-07-21 02:16:28.876095322 +0000
-@@ -1420,7 +1420,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -urN mysql-orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-orig/sql/mysqld.cc 2011-07-21 02:15:51.952095298 +0000
-+++ mysql/sql/mysqld.cc 2011-07-21 02:16:28.880095322 +0000
-@@ -3394,7 +3394,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3406,15 +3406,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5096,7 +5096,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -urN mysql-orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-orig/sql/net_serv.cc 2011-07-21 02:15:51.953095298 +0000
-+++ mysql/sql/net_serv.cc 2011-07-21 02:16:28.883095322 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -urN mysql-orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-orig/sql/opt_range.cc 2011-07-21 02:15:51.956095298 +0000
-+++ mysql/sql/opt_range.cc 2011-07-21 02:16:28.886095322 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -urN mysql-orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql-orig/sql/opt_range.h 2011-07-21 02:15:51.950095298 +0000
-+++ mysql/sql/opt_range.h 2011-07-21 02:16:28.889095322 +0000
-@@ -83,7 +83,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -121,7 +121,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -urN mysql-orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-orig/sql/protocol.cc 2011-07-21 02:15:51.960095298 +0000
-+++ mysql/sql/protocol.cc 2011-07-21 02:16:28.890095322 +0000
-@@ -167,7 +167,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -262,7 +262,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -urN mysql-orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-orig/sql/rpl_record.cc 2011-07-21 02:15:51.954095298 +0000
-+++ mysql/sql/rpl_record.cc 2011-07-21 02:16:28.890095322 +0000
-@@ -285,7 +285,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -urN mysql-orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-orig/sql/rpl_rli.cc 2011-07-21 02:15:51.960095298 +0000
-+++ mysql/sql/rpl_rli.cc 2011-07-21 02:16:28.891095322 +0000
-@@ -686,7 +686,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -696,7 +696,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -urN mysql-orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-orig/sql/rpl_utility.cc 2011-07-21 02:15:51.951095298 +0000
-+++ mysql/sql/rpl_utility.cc 2011-07-21 02:16:28.892095322 +0000
-@@ -180,7 +180,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -urN mysql-orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql-orig/sql/rpl_utility.h 2011-07-21 02:15:51.951095298 +0000
-+++ mysql/sql/rpl_utility.h 2011-07-21 02:16:28.892095322 +0000
-@@ -295,7 +295,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -urN mysql-orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-orig/sql/set_var.cc 2011-07-21 02:15:51.952095298 +0000
-+++ mysql/sql/set_var.cc 2011-07-21 02:16:28.894095322 +0000
-@@ -1845,7 +1845,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4030,7 +4030,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -urN mysql-orig/sql/slave.cc mysql/sql/slave.cc
---- mysql-orig/sql/slave.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/slave.cc 2011-07-21 02:16:28.896095322 +0000
-@@ -1737,7 +1737,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2354,7 +2354,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4050,7 +4050,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -urN mysql-orig/sql/spatial.h mysql/sql/spatial.h
---- mysql-orig/sql/spatial.h 2011-07-21 02:15:51.949095298 +0000
-+++ mysql/sql/spatial.h 2011-07-21 02:16:28.929095322 +0000
-@@ -180,8 +180,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -urN mysql-orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-orig/sql/sp_head.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/sp_head.cc 2011-07-21 02:16:28.932095322 +0000
-@@ -2454,7 +2454,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2655,7 +2655,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -urN mysql-orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-orig/sql/sql_acl.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/sql_acl.cc 2011-07-21 02:16:28.935095322 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -urN mysql-orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-orig/sql/sql_analyse.cc 2011-07-21 02:15:51.955095298 +0000
-+++ mysql/sql/sql_analyse.cc 2011-07-21 02:16:28.937095322 +0000
-@@ -280,16 +280,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1043,7 +1043,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1068,7 +1068,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1185,7 +1185,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -urN mysql-orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-orig/sql/sql_cache.cc 2011-07-21 02:15:51.953095298 +0000
-+++ mysql/sql/sql_cache.cc 2011-07-21 02:16:28.938095322 +0000
-@@ -1004,7 +1004,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2425,7 +2425,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2480,7 +2480,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2508,7 +2508,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2596,8 +2596,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2629,7 +2629,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2638,7 +2638,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3061,7 +3061,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -urN mysql-orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-orig/sql/sql_class.cc 2011-07-21 02:15:51.962095298 +0000
-+++ mysql/sql/sql_class.cc 2011-07-21 02:16:28.941095322 +0000
-@@ -415,7 +415,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -430,7 +430,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2100,7 +2100,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -urN mysql-orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-orig/sql/sql_client.cc 2011-07-21 02:15:51.956095298 +0000
-+++ mysql/sql/sql_client.cc 2011-07-21 02:16:28.942095322 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -urN mysql-orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-orig/sql/sql_connect.cc 2011-07-21 02:15:51.950095298 +0000
-+++ mysql/sql/sql_connect.cc 2011-07-21 02:16:28.943095322 +0000
-@@ -843,7 +843,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -urN mysql-orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-orig/sql/sql_parse.cc 2011-07-21 02:15:51.954095298 +0000
-+++ mysql/sql/sql_parse.cc 2011-07-21 02:16:28.946095322 +0000
-@@ -5721,7 +5721,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7225,7 +7225,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -urN mysql-orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-orig/sql/sql_partition.cc 2011-07-21 02:15:51.956095298 +0000
-+++ mysql/sql/sql_partition.cc 2011-07-21 02:16:28.951095322 +0000
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -urN mysql-orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-orig/sql/sql_plugin.cc 2011-07-21 02:15:51.957095298 +0000
-+++ mysql/sql/sql_plugin.cc 2011-07-21 02:16:28.953095322 +0000
-@@ -510,7 +510,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2129,7 +2129,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -urN mysql-orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-orig/sql/sql_prepare.cc 2011-07-21 02:15:51.949095298 +0000
-+++ mysql/sql/sql_prepare.cc 2011-07-21 02:16:28.956095322 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -urN mysql-orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql-orig/sql/sql_profile.cc 2011-07-21 02:15:51.951095298 +0000
-+++ mysql/sql/sql_profile.cc 2011-07-21 02:16:28.957095322 +0000
-@@ -252,7 +252,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -urN mysql-orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-orig/sql/sql_repl.cc 2011-07-21 02:15:51.957095298 +0000
-+++ mysql/sql/sql_repl.cc 2011-07-21 02:16:28.958095322 +0000
-@@ -1297,12 +1297,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1474,7 +1474,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1745,14 +1745,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1761,7 +1761,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -urN mysql-orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-orig/sql/sql_select.cc 2011-07-21 02:15:51.945095298 +0000
-+++ mysql/sql/sql_select.cc 2011-07-21 02:16:28.965095322 +0000
-@@ -3006,7 +3006,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3942,7 +3942,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3965,7 +3965,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4128,7 +4128,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4448,7 +4448,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4615,7 +4615,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5565,7 +5565,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10481,7 +10481,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13693,7 +13693,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13705,7 +13705,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14403,7 +14403,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14525,7 +14525,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -urN mysql-orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-orig/sql/sql_show.cc 2011-07-21 02:15:51.944095298 +0000
-+++ mysql/sql/sql_show.cc 2011-07-21 02:16:28.971095322 +0000
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1871,7 +1871,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2002,7 +2002,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3267,7 +3267,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7084,7 +7084,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -urN mysql-orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-orig/sql/sql_string.cc 2011-07-21 02:15:51.962095298 +0000
-+++ mysql/sql/sql_string.cc 2011-07-21 02:16:28.973095322 +0000
-@@ -695,7 +695,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -781,7 +781,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -798,7 +798,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -999,7 +999,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1185,7 +1185,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -urN mysql-orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-orig/sql/sql_table.cc 2011-07-21 02:15:51.956095298 +0000
-+++ mysql/sql/sql_table.cc 2011-07-21 02:16:28.976095322 +0000
-@@ -3275,7 +3275,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -urN mysql-orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-orig/sql/sql_yacc.cc 2011-07-21 02:15:51.958095298 +0000
-+++ mysql/sql/sql_yacc.cc 2011-07-21 02:16:28.990095322 +0000
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -urN mysql-orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql-orig/sql/sql_yacc.yy 2011-07-21 02:15:51.950095298 +0000
-+++ mysql/sql/sql_yacc.yy 2011-07-21 02:16:29.003095322 +0000
-@@ -1805,7 +1805,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1815,7 +1815,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -urN mysql-orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-orig/sql/thr_malloc.cc 2011-07-21 02:15:51.959095298 +0000
-+++ mysql/sql/thr_malloc.cc 2011-07-21 02:16:29.006095322 +0000
-@@ -130,7 +130,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -urN mysql-orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-orig/sql/tztime.cc 2011-07-21 02:15:51.960095298 +0000
-+++ mysql/sql/tztime.cc 2011-07-21 02:16:29.007095322 +0000
-@@ -167,7 +167,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -396,7 +396,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1823,7 +1823,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -urN mysql-orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-orig/sql/unireg.cc 2011-07-21 02:15:51.954095298 +0000
-+++ mysql/sql/unireg.cc 2011-07-21 02:16:29.008095322 +0000
-@@ -496,7 +496,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -716,7 +716,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -urN mysql-orig/sql-common/client.c mysql/sql-common/client.c
---- mysql-orig/sql-common/client.c 2011-07-21 02:15:51.926095298 +0000
-+++ mysql/sql-common/client.c 2011-07-21 02:16:29.009095322 +0000
-@@ -728,7 +728,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2102,7 +2102,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -urN mysql-orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-orig/sql-common/my_time.c 2011-07-21 02:15:51.926095298 +0000
-+++ mysql/sql-common/my_time.c 2011-07-21 02:16:29.011095322 +0000
-@@ -249,7 +249,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -urN mysql-orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-orig/storage/csv/ha_tina.cc 2011-07-21 02:15:52.017095298 +0000
-+++ mysql/storage/csv/ha_tina.cc 2011-07-21 02:16:29.011095322 +0000
-@@ -1193,7 +1193,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1429,7 +1429,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -urN mysql-orig/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql-orig/storage/example/ha_example.h 2011-07-21 02:15:52.016095298 +0000
-+++ mysql/storage/example/ha_example.h 2011-07-21 02:16:29.012095322 +0000
-@@ -110,14 +110,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -128,7 +128,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -139,7 +139,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -urN mysql-orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-orig/storage/federated/ha_federated.cc 2011-07-21 02:15:52.075095298 +0000
-+++ mysql/storage/federated/ha_federated.cc 2011-07-21 02:16:29.014095322 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -urN mysql-orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-orig/storage/heap/hp_create.c 2011-07-21 02:15:52.018095298 +0000
-+++ mysql/storage/heap/hp_create.c 2011-07-21 02:16:29.015095322 +0000
-@@ -229,7 +229,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -urN mysql-orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-orig/storage/heap/hp_test2.c 2011-07-21 02:15:52.017095298 +0000
-+++ mysql/storage/heap/hp_test2.c 2011-07-21 02:16:29.015095322 +0000
-@@ -136,7 +136,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -217,7 +217,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -urN mysql-orig/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql-orig/storage/innobase/include/ut0byte.h 2011-07-21 02:15:52.008095298 +0000
-+++ mysql/storage/innobase/include/ut0byte.h 2011-07-21 02:16:29.016095322 +0000
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -urN mysql-orig/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql-orig/storage/innodb_plugin/dict/dict0dict.c 2011-07-21 02:15:52.022095298 +0000
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2011-07-21 02:16:29.017095322 +0000
-@@ -4858,7 +4858,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4868,7 +4868,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -urN mysql-orig/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql-orig/storage/innodb_plugin/include/dict0dict.h 2011-07-21 02:15:52.024095298 +0000
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2011-07-21 02:16:29.019095322 +0000
-@@ -1123,7 +1123,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -urN mysql-orig/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql-orig/storage/myisam/ft_boolean_search.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/ft_boolean_search.c 2011-07-21 02:16:29.020095322 +0000
-@@ -46,9 +46,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -urN mysql-orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-orig/storage/myisam/ha_myisam.cc 2011-07-21 02:15:52.018095298 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2011-07-21 02:16:29.021095322 +0000
-@@ -1528,7 +1528,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -urN mysql-orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-orig/storage/myisam/mi_cache.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/mi_cache.c 2011-07-21 02:16:29.022095322 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -urN mysql-orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-orig/storage/myisam/mi_check.c 2011-07-21 02:15:52.020095298 +0000
-+++ mysql/storage/myisam/mi_check.c 2011-07-21 02:16:29.023095322 +0000
-@@ -2173,7 +2173,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2329,7 +2329,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2418,7 +2418,7 @@
- (see _create_index_by_sort)
- */
- sort_info.max_records= 10 *
-- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
-+ MYSQL_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
- sort_param.key_length;
- }
-
-@@ -2782,7 +2782,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3980,7 +3980,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-@@ -4331,7 +4331,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -urN mysql-orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-orig/storage/myisam/mi_create.c 2011-07-21 02:15:52.020095298 +0000
-+++ mysql/storage/myisam/mi_create.c 2011-07-21 02:16:29.025095322 +0000
-@@ -437,8 +437,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -527,7 +527,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -565,7 +565,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -urN mysql-orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-orig/storage/myisam/mi_dynrec.c 2011-07-21 02:15:52.021095298 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2011-07-21 02:16:29.026095322 +0000
-@@ -880,7 +880,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -urN mysql-orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-orig/storage/myisam/mi_extra.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/mi_extra.c 2011-07-21 02:16:29.027095322 +0000
-@@ -99,7 +99,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -urN mysql-orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-orig/storage/myisam/mi_open.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/mi_open.c 2011-07-21 02:16:29.027095322 +0000
-@@ -328,7 +328,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -501,7 +501,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -714,10 +714,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -urN mysql-orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-orig/storage/myisam/mi_packrec.c 2011-07-21 02:15:52.020095298 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2011-07-21 02:16:29.028095322 +0000
-@@ -684,7 +684,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1399,7 +1399,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -urN mysql-orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-orig/storage/myisam/mi_test1.c 2011-07-21 02:15:52.020095298 +0000
-+++ mysql/storage/myisam/mi_test1.c 2011-07-21 02:16:29.029095322 +0000
-@@ -436,7 +436,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -urN mysql-orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-orig/storage/myisam/mi_test2.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/mi_test2.c 2011-07-21 02:16:29.030095322 +0000
-@@ -601,7 +601,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -urN mysql-orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-orig/storage/myisam/myisamlog.c 2011-07-21 02:15:52.021095298 +0000
-+++ mysql/storage/myisam/myisamlog.c 2011-07-21 02:16:29.030095322 +0000
-@@ -90,7 +90,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -urN mysql-orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-orig/storage/myisam/myisampack.c 2011-07-21 02:15:52.020095298 +0000
-+++ mysql/storage/myisam/myisampack.c 2011-07-21 02:16:29.032095322 +0000
-@@ -1239,7 +1239,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3001,7 +3001,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -urN mysql-orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-orig/storage/myisam/rt_mbr.c 2011-07-21 02:15:52.019095298 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2011-07-21 02:16:29.069095324 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -urN mysql-orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-orig/storage/myisam/sort.c 2011-07-21 02:15:52.021095298 +0000
-+++ mysql/storage/myisam/sort.c 2011-07-21 02:16:29.070095324 +0000
-@@ -129,7 +129,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -346,7 +346,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -820,7 +820,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -841,7 +841,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -urN mysql-orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-orig/storage/myisammrg/ha_myisammrg.cc 2011-07-21 02:15:52.016095298 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2011-07-21 02:16:29.071095324 +0000
-@@ -964,7 +964,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -urN mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-07-21 02:15:51.992095298 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-07-21 02:16:29.072095324 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -urN mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-07-21 02:15:51.979095298 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-07-21 02:16:29.072095324 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -urN mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-07-21 02:15:51.974095298 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-07-21 02:16:29.074095324 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -urN mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-07-21 02:15:52.000095298 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-07-21 02:16:29.075095324 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -urN mysql-orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-orig/storage/ndb/test/src/getarg.c 2011-07-21 02:15:51.998095298 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2011-07-21 02:16:29.075095324 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -urN mysql-orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-orig/strings/ctype-big5.c 2011-07-21 02:15:51.933095298 +0000
-+++ mysql/strings/ctype-big5.c 2011-07-21 02:16:29.078095324 +0000
-@@ -253,7 +253,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -266,7 +266,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-orig/strings/ctype-bin.c 2011-07-21 02:15:51.933095298 +0000
-+++ mysql/strings/ctype-bin.c 2011-07-21 02:16:29.081095324 +0000
-@@ -80,7 +80,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -131,7 +131,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -175,7 +175,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -404,7 +404,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -417,7 +417,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-orig/strings/ctype-gbk.c 2011-07-21 02:15:51.935095298 +0000
-+++ mysql/strings/ctype-gbk.c 2011-07-21 02:16:29.085095324 +0000
-@@ -2616,7 +2616,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2627,7 +2627,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -urN mysql-orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-orig/strings/ctype-mb.c 2011-07-21 02:15:51.935095298 +0000
-+++ mysql/strings/ctype-mb.c 2011-07-21 02:16:29.089095324 +0000
-@@ -368,7 +368,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -412,7 +412,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -451,7 +451,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-orig/strings/ctype-simple.c 2011-07-21 02:15:51.930095298 +0000
-+++ mysql/strings/ctype-simple.c 2011-07-21 02:16:29.144095324 +0000
-@@ -159,7 +159,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -873,7 +873,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -927,7 +927,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1158,7 +1158,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -urN mysql-orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-orig/strings/ctype-tis620.c 2011-07-21 02:15:51.934095298 +0000
-+++ mysql/strings/ctype-tis620.c 2011-07-21 02:16:29.171095324 +0000
-@@ -581,7 +581,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -638,7 +638,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -urN mysql-orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-orig/strings/ctype-uca.c 2011-07-21 02:15:51.932095298 +0000
-+++ mysql/strings/ctype-uca.c 2011-07-21 02:16:29.186095324 +0000
-@@ -7567,7 +7567,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -urN mysql-orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-orig/strings/ctype-ucs2.c 2011-07-21 02:15:51.936095298 +0000
-+++ mysql/strings/ctype-ucs2.c 2011-07-21 02:16:29.225095324 +0000
-@@ -279,7 +279,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1331,7 +1331,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1425,7 +1425,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1472,7 +1472,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -urN mysql-orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-orig/strings/ctype-utf8.c 2011-07-21 02:15:51.932095298 +0000
-+++ mysql/strings/ctype-utf8.c 2011-07-21 02:16:29.249095324 +0000
-@@ -1937,7 +1937,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -urN mysql-orig/strings/decimal.c mysql/strings/decimal.c
---- mysql-orig/strings/decimal.c 2011-07-21 02:15:51.936095298 +0000
-+++ mysql/strings/decimal.c 2011-07-21 02:16:29.251095324 +0000
-@@ -404,7 +404,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -427,7 +427,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1518,8 +1518,8 @@
-
- if (to != from || intg1>intg0)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg1+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg1+MYSQL_MAX(frac1, frac0);
-
- while (buf0 < p0)
- *(--p1) = *(--p0);
-@@ -1530,7 +1530,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1632,7 +1632,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1651,7 +1651,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1700,11 +1700,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1719,7 +1719,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1744,7 +1744,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1755,7 +1755,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN(frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1773,14 +1773,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1801,7 +1801,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1876,7 +1876,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1887,7 +1887,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1911,7 +1911,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2174,11 +2174,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2302,7 +2302,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2340,7 +2340,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -urN mysql-orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-orig/strings/my_vsnprintf.c 2011-07-21 02:15:51.931095298 +0000
-+++ mysql/strings/my_vsnprintf.c 2011-07-21 02:16:29.252095324 +0000
-@@ -141,7 +141,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -urN mysql-orig/strings/str2int.c mysql/strings/str2int.c
---- mysql-orig/strings/str2int.c 2011-07-21 02:15:51.932095298 +0000
-+++ mysql/strings/str2int.c 2011-07-21 02:16:29.253095324 +0000
-@@ -82,7 +82,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -urN mysql-orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql-orig/tests/mysql_client_test.c 2011-07-21 02:15:51.909095298 +0000
-+++ mysql/tests/mysql_client_test.c 2011-07-21 02:16:29.259095324 +0000
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -urN mysql-orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-orig/vio/viosocket.c 2011-07-21 02:15:51.908095298 +0000
-+++ mysql/vio/viosocket.c 2011-07-21 02:16:29.262095324 +0000
-@@ -71,7 +71,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.60.patch b/07110_all_mysql_gcc-4.2_5.1.60.patch
deleted file mode 100644
index c7bb844..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.60.patch
+++ /dev/null
@@ -1,3859 +0,0 @@
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/client/mysqlbinlog.cc 2011-11-18 15:43:16.995773774 -0800
-@@ -1954,7 +1954,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/client/mysql.cc 2011-11-18 15:43:16.997773806 -0800
-@@ -3334,9 +3334,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3356,7 +3356,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/client/mysqldump.c 2011-11-18 15:43:16.999773837 -0800
-@@ -833,7 +833,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4526,7 +4526,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/client/mysqltest.cc 2011-11-18 15:43:17.002773882 -0800
-@@ -5666,9 +5666,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/client/mysql_upgrade.c 2011-11-18 15:43:17.003773897 -0800
-@@ -533,7 +533,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/client/sql_string.cc 2011-11-18 15:43:17.003773897 -0800
-@@ -664,7 +664,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -750,7 +750,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -767,7 +767,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2011-10-29 11:09:48.000000000 -0700
-+++ mysql/dbug/dbug.c 2011-11-18 15:43:17.004773912 -0800
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/extra/yassl/src/ssl.cpp 2011-11-18 15:43:17.004773912 -0800
-@@ -38,6 +38,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -113,7 +114,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp 2011-10-29 11:09:53.000000000 -0700
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2011-11-18 15:43:17.005773927 -0800
-@@ -67,7 +67,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2011-10-29 11:09:51.000000000 -0700
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2011-11-18 15:43:17.005773927 -0800
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/include/my_global.h 2011-11-18 15:43:17.005773927 -0800
-@@ -586,10 +586,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/libmysql/libmysql.c 2011-11-18 15:43:17.006773942 -0800
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/libmysqld/lib_sql.cc 2011-11-18 15:43:17.007773958 -0800
-@@ -848,7 +848,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/array.c 2011-11-18 15:43:17.007773958 -0800
-@@ -50,7 +50,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -344,7 +344,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/default.c 2011-11-18 15:43:17.008773974 -0800
-@@ -796,7 +796,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/mf_format.c 2011-11-18 15:43:17.008773974 -0800
-@@ -86,7 +86,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/mf_iocache.c 2011-11-18 15:43:17.008773974 -0800
-@@ -1099,7 +1099,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1258,7 +1258,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1367,7 +1367,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1401,7 +1401,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/my_alloc.c 2011-11-18 15:43:17.009773990 -0800
-@@ -214,7 +214,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/my_bitmap.c 2011-11-18 15:43:17.009773990 -0800
-@@ -425,7 +425,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compare.c mysql/mysys/my_compare.c
---- mysql.orig/mysys/my_compare.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/my_compare.c 2011-11-18 15:43:17.010774005 -0800
-@@ -30,7 +30,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -158,7 +158,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/mysys/my_compress.c 2011-11-18 15:43:17.010774005 -0800
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/mysys/my_conio.c 2011-11-18 15:43:17.010774005 -0800
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/my_file.c 2011-11-18 15:43:17.010774005 -0800
-@@ -77,7 +77,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -99,7 +99,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -109,9 +109,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/my_getopt.c 2011-11-18 15:43:17.011774020 -0800
-@@ -985,7 +985,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/mysys/my_static.h 2011-11-18 15:43:17.011774020 -0800
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/safemalloc.c 2011-11-18 15:43:17.011774020 -0800
-@@ -250,7 +250,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/mysys/stacktrace.c 2011-11-18 15:43:17.012774035 -0800
-@@ -98,7 +98,7 @@
- /* Read up to the maximum number of bytes. */
- while (total)
- {
-- count= min(sizeof(buf), total);
-+ count= MYSQL_MIN(sizeof(buf), total);
-
- if ((nbytes= pread(fd, buf, count, offset)) < 0)
- {
-@@ -326,7 +326,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) &
- ~(ulong) 0xFFFF);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/server-tools/instance-manager/buffer.cc 2011-11-18 15:43:17.012774035 -0800
-@@ -86,8 +86,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/server-tools/instance-manager/listener.cc 2011-11-18 15:43:17.012774035 -0800
-@@ -106,7 +106,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql.orig/sql/debug_sync.cc 2011-10-29 11:09:48.000000000 -0700
-+++ mysql/sql/debug_sync.cc 2011-11-18 15:43:17.013774050 -0800
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/field.cc 2011-11-18 15:43:17.015774080 -0800
-@@ -55,7 +55,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2073,7 +2073,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2081,7 +2081,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2506,7 +2506,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2522,7 +2522,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3092,7 +3092,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3304,7 +3304,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3521,7 +3521,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3740,7 +3740,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3981,7 +3981,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4204,7 +4204,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6443,13 +6443,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6457,7 +6457,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6715,7 +6715,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7709,7 +7709,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7869,7 +7869,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8065,7 +8065,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9783,7 +9783,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/filesort.cc 2011-11-18 15:43:17.015774080 -0800
-@@ -193,7 +193,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -215,12 +215,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
- if ((table_sort.sort_keys=
- (uchar **) make_char_array((char **) table_sort.sort_keys,
- param.keys, param.rec_length, MYF(0))))
-@@ -1109,7 +1109,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1372,7 +1372,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/ha_ndbcluster.cc 2011-11-18 15:43:17.017774112 -0800
-@@ -799,7 +799,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/handler.h 2011-11-18 15:43:17.018774127 -0800
-@@ -1607,15 +1607,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql.orig/sql/ha_partition.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/ha_partition.cc 2011-11-18 15:43:17.019774142 -0800
-@@ -6138,7 +6138,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_buff.cc 2011-11-18 15:43:17.020774157 -0800
-@@ -61,7 +61,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -71,7 +71,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item.cc 2011-11-18 15:43:17.021774172 -0800
-@@ -76,7 +76,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -444,9 +444,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -752,7 +752,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5416,7 +5416,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5471,7 +5471,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7561,14 +7561,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7599,7 +7599,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7621,7 +7621,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7639,7 +7639,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_cmpfunc.cc 2011-11-18 15:43:17.022774187 -0800
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4979,7 +4979,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4998,7 +4998,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5119,14 +5119,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5150,14 +5150,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_func.cc 2011-11-18 15:43:17.025774233 -0800
-@@ -549,7 +549,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1143,10 +1143,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1256,9 +1256,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1306,7 +1306,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1315,7 +1315,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1329,7 +1329,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1460,8 +1460,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1983,7 +1983,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1993,7 +1993,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2010,13 +2010,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2117,7 +2117,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2989,7 +2989,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2998,7 +2998,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.h mysql/sql/item_func.h
---- mysql.orig/sql/item_func.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_func.h 2011-11-18 15:43:17.026774249 -0800
-@@ -421,7 +421,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_strfunc.cc 2011-11-18 15:43:17.028774280 -0800
-@@ -389,7 +389,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -750,7 +750,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1251,7 +1251,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1271,7 +1271,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1962,7 +1962,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3114,11 +3114,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3582,7 +3582,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql.orig/sql/item_strfunc.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_strfunc.h 2011-11-18 15:43:17.029774295 -0800
-@@ -709,7 +709,7 @@
- collation.set(args[0]->collation);
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
- 2 * collation.collation->mbmaxlen;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- }
- };
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_sum.cc 2011-11-18 15:43:17.031774325 -0800
-@@ -1139,7 +1139,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1202,16 +1202,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1402,13 +1402,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3345,7 +3345,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/item_timefunc.cc 2011-11-18 15:43:17.032774340 -0800
-@@ -310,14 +310,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -326,7 +326,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -343,15 +343,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -362,14 +362,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -377,7 +377,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -429,7 +429,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -441,7 +441,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -453,7 +453,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -598,7 +598,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1830,7 +1830,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/key.cc 2011-11-18 15:43:17.033774355 -0800
-@@ -128,13 +128,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -218,7 +218,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -227,7 +227,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -288,7 +288,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -354,7 +354,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/log.cc 2011-11-18 15:43:17.034774370 -0800
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2429,7 +2429,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5237,7 +5237,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/log_event.cc 2011-11-18 15:43:17.036774401 -0800
-@@ -1082,7 +1082,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2678,7 +2678,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5595,7 +5595,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7322,7 +7322,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql.orig/sql/log_event_old.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/log_event_old.cc 2011-11-18 15:43:17.037774417 -0800
-@@ -1434,7 +1434,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/mysqld.cc 2011-11-18 15:43:17.039774448 -0800
-@@ -3397,7 +3397,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3409,15 +3409,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -5099,7 +5099,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/net_serv.cc 2011-11-18 15:43:17.039774448 -0800
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/opt_range.cc 2011-11-18 15:43:17.041774478 -0800
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql.orig/sql/opt_range.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/opt_range.h 2011-11-18 15:43:17.042774493 -0800
-@@ -85,7 +85,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -123,7 +123,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/protocol.cc 2011-11-18 15:43:17.042774493 -0800
-@@ -168,7 +168,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -263,7 +263,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/rpl_record.cc 2011-11-18 15:43:17.043774508 -0800
-@@ -287,7 +287,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/rpl_rli.cc 2011-11-18 15:43:17.043774508 -0800
-@@ -688,7 +688,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -698,7 +698,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/rpl_utility.cc 2011-11-18 15:43:17.044774523 -0800
-@@ -182,7 +182,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql.orig/sql/rpl_utility.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/rpl_utility.h 2011-11-18 15:43:17.044774523 -0800
-@@ -297,7 +297,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/set_var.cc 2011-11-18 15:43:17.045774539 -0800
-@@ -1847,7 +1847,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4032,7 +4032,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/slave.cc 2011-11-18 15:43:17.046774555 -0800
-@@ -1743,7 +1743,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2360,7 +2360,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4057,7 +4057,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/spatial.h 2011-11-18 15:43:17.047774570 -0800
-@@ -182,8 +182,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/sp_head.cc 2011-11-18 15:43:17.047774570 -0800
-@@ -2481,7 +2481,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2682,7 +2682,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_acl.cc 2011-11-18 15:43:17.048774585 -0800
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_analyse.cc 2011-11-18 15:43:17.049774600 -0800
-@@ -282,16 +282,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1045,7 +1045,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1070,7 +1070,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1187,7 +1187,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/sql_cache.cc 2011-11-18 15:43:17.050774615 -0800
-@@ -1006,7 +1006,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2451,7 +2451,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2506,7 +2506,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2534,7 +2534,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2622,8 +2622,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2655,7 +2655,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2664,7 +2664,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3087,7 +3087,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_class.cc 2011-11-18 15:43:17.051774630 -0800
-@@ -417,7 +417,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -432,7 +432,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2101,7 +2101,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2011-10-29 11:09:53.000000000 -0700
-+++ mysql/sql/sql_client.cc 2011-11-18 15:43:17.051774630 -0800
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_connect.cc 2011-11-18 15:43:17.052774645 -0800
-@@ -845,7 +845,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/sql_parse.cc 2011-11-18 15:43:17.053774660 -0800
-@@ -5756,7 +5756,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7286,7 +7286,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_partition.cc 2011-11-18 15:43:17.055774692 -0800
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_plugin.cc 2011-11-18 15:43:17.056774708 -0800
-@@ -512,7 +512,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2131,7 +2131,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_prepare.cc 2011-11-18 15:43:17.057774723 -0800
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql.orig/sql/sql_profile.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_profile.cc 2011-11-18 15:43:17.058774738 -0800
-@@ -254,7 +254,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_repl.cc 2011-11-18 15:43:17.058774738 -0800
-@@ -1299,12 +1299,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1476,7 +1476,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1747,14 +1747,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1763,7 +1763,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/sql_select.cc 2011-11-18 15:43:17.061774783 -0800
-@@ -3016,7 +3016,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3952,7 +3952,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3975,7 +3975,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4138,7 +4138,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4458,7 +4458,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4625,7 +4625,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5575,7 +5575,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10491,7 +10491,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13703,7 +13703,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13715,7 +13715,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14413,7 +14413,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14535,7 +14535,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_show.cc 2011-11-18 15:43:17.063774813 -0800
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1871,7 +1871,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2002,7 +2002,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3267,7 +3267,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7084,7 +7084,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_string.cc 2011-11-18 15:43:17.064774828 -0800
-@@ -699,7 +699,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -785,7 +785,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -802,7 +802,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -1003,7 +1003,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1189,7 +1189,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/sql_table.cc 2011-11-18 15:43:17.065774844 -0800
-@@ -3276,7 +3276,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2011-10-29 11:16:20.000000000 -0700
-+++ mysql/sql/sql_yacc.cc 2011-11-18 15:43:17.071774936 -0800
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/sql/sql_yacc.yy 2011-11-18 15:43:17.075774996 -0800
-@@ -1807,7 +1807,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1817,7 +1817,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/thr_malloc.cc 2011-11-18 15:43:17.076775012 -0800
-@@ -132,7 +132,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/tztime.cc 2011-11-18 15:43:17.076775012 -0800
-@@ -169,7 +169,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -398,7 +398,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1825,7 +1825,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql/unireg.cc 2011-11-18 15:43:17.077775028 -0800
-@@ -498,7 +498,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -718,7 +718,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql-common/client.c 2011-11-18 15:43:17.077775028 -0800
-@@ -730,7 +730,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2104,7 +2104,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/sql-common/my_time.c 2011-11-18 15:43:17.078775044 -0800
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/csv/ha_tina.cc 2011-11-18 15:43:17.079775059 -0800
-@@ -1195,7 +1195,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1431,7 +1431,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql.orig/storage/example/ha_example.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/example/ha_example.h 2011-11-18 15:43:17.079775059 -0800
-@@ -112,14 +112,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -130,7 +130,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -141,7 +141,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/federated/ha_federated.cc 2011-11-18 15:43:17.080775074 -0800
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/storage/heap/hp_create.c 2011-11-18 15:43:17.080775074 -0800
-@@ -230,7 +230,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/heap/hp_test2.c 2011-11-18 15:43:17.081775089 -0800
-@@ -138,7 +138,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -219,7 +219,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql.orig/storage/innobase/include/ut0byte.h 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/innobase/include/ut0byte.h 2011-11-18 15:43:17.081775089 -0800
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql.orig/storage/innodb_plugin/dict/dict0dict.c 2011-10-29 11:09:48.000000000 -0700
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2011-11-18 15:43:17.082775104 -0800
-@@ -4860,7 +4860,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4870,7 +4870,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql.orig/storage/innodb_plugin/include/dict0dict.h 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2011-11-18 15:43:17.082775104 -0800
-@@ -1123,7 +1123,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql.orig/storage/myisam/ft_boolean_search.c 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/storage/myisam/ft_boolean_search.c 2011-11-18 15:43:17.083775119 -0800
-@@ -49,9 +49,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/storage/myisam/ha_myisam.cc 2011-11-18 15:43:17.083775119 -0800
-@@ -1546,7 +1546,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/storage/myisam/mi_cache.c 2011-11-18 15:43:17.084775134 -0800
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/storage/myisam/mi_check.c 2011-11-18 15:43:17.085775150 -0800
-@@ -2175,7 +2175,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2331,7 +2331,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2420,7 +2420,7 @@
- (see _create_index_by_sort)
- */
- sort_info.max_records= 10 *
-- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
-+ MYSQL_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
- sort_param.key_length;
- }
-
-@@ -2784,7 +2784,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3982,7 +3982,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-@@ -4333,7 +4333,7 @@
-
- VOID(mi_close(*org_info));
- bzero((char*) &create_info,sizeof(create_info));
-- create_info.max_rows=max(max_records,share.base.records);
-+ create_info.max_rows=MYSQL_MAX(max_records,share.base.records);
- create_info.reloc_rows=share.base.reloc;
- create_info.old_options=(share.options |
- (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_create.c 2011-11-18 15:43:17.085775150 -0800
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_dynrec.c 2011-11-18 15:43:17.086775166 -0800
-@@ -882,7 +882,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_extra.c 2011-11-18 15:43:17.086775166 -0800
-@@ -101,7 +101,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_open.c 2011-11-18 15:43:17.087775181 -0800
-@@ -330,7 +330,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -503,7 +503,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -716,10 +716,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_packrec.c 2011-11-18 15:43:17.087775181 -0800
-@@ -687,7 +687,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1402,7 +1402,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_test1.c 2011-11-18 15:43:17.087775181 -0800
-@@ -438,7 +438,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/mi_test2.c 2011-11-18 15:43:17.088775196 -0800
-@@ -603,7 +603,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/myisamlog.c 2011-11-18 15:43:17.089775211 -0800
-@@ -92,7 +92,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/myisampack.c 2011-11-18 15:43:17.089775211 -0800
-@@ -1240,7 +1240,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3002,7 +3002,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2011-10-29 11:09:53.000000000 -0700
-+++ mysql/storage/myisam/rt_mbr.c 2011-11-18 15:43:17.090775226 -0800
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisam/sort.c 2011-11-18 15:43:17.090775226 -0800
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2011-11-18 15:43:17.091775241 -0800
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-11-18 15:43:17.091775241 -0800
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-10-29 11:09:51.000000000 -0700
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2011-11-18 15:43:17.091775241 -0800
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-10-29 11:09:52.000000000 -0700
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2011-11-18 15:43:17.092775256 -0800
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-10-29 11:09:53.000000000 -0700
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2011-11-18 15:43:17.092775256 -0800
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2011-10-29 11:09:51.000000000 -0700
-+++ mysql/storage/ndb/test/src/getarg.c 2011-11-18 15:43:17.092775256 -0800
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-big5.c 2011-11-18 15:43:17.094775287 -0800
-@@ -254,7 +254,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -267,7 +267,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-bin.c 2011-11-18 15:43:17.094775287 -0800
-@@ -82,7 +82,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -133,7 +133,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -177,7 +177,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -406,7 +406,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -419,7 +419,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-gbk.c 2011-11-18 15:43:17.096775319 -0800
-@@ -2617,7 +2617,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2628,7 +2628,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-mb.c 2011-11-18 15:43:17.097775334 -0800
-@@ -369,7 +369,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -413,7 +413,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -452,7 +452,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-simple.c 2011-11-18 15:43:17.098775349 -0800
-@@ -161,7 +161,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -875,7 +875,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -929,7 +929,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1160,7 +1160,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-tis620.c 2011-11-18 15:43:17.098775349 -0800
-@@ -583,7 +583,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -640,7 +640,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-uca.c 2011-11-18 15:43:17.100775379 -0800
-@@ -7569,7 +7569,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-ucs2.c 2011-11-18 15:43:17.101775394 -0800
-@@ -280,7 +280,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1332,7 +1332,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1426,7 +1426,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1473,7 +1473,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/ctype-utf8.c 2011-11-18 15:43:17.102775409 -0800
-@@ -1939,7 +1939,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2011-10-29 11:09:47.000000000 -0700
-+++ mysql/strings/decimal.c 2011-11-18 15:44:22.403773051 -0800
-@@ -405,7 +405,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -428,7 +428,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1531,8 +1531,8 @@
-
- if (to != from)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg0+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg0+MYSQL_MAX(frac1, frac0);
-
- DBUG_ASSERT(p0 - buf0 <= len);
- DBUG_ASSERT(p1 - buf1 <= len);
-@@ -1543,7 +1543,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1645,7 +1645,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1664,7 +1664,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1713,11 +1713,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1732,7 +1732,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1757,7 +1757,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1768,7 +1768,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN(frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1786,14 +1786,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1814,7 +1814,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1889,7 +1889,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1900,7 +1900,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1924,7 +1924,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2187,11 +2187,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2315,7 +2315,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2353,7 +2353,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/my_vsnprintf.c 2011-11-18 15:43:17.103775424 -0800
-@@ -143,7 +143,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/strings/str2int.c 2011-11-18 15:43:17.103775424 -0800
-@@ -84,7 +84,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2011-11-18 13:00:01.595513776 -0800
-+++ mysql/tests/mysql_client_test.c 2011-11-18 15:43:17.106775471 -0800
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2011-10-29 11:09:49.000000000 -0700
-+++ mysql/vio/viosocket.c 2011-11-18 15:43:17.107775487 -0800
-@@ -72,7 +72,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.62.patch b/07110_all_mysql_gcc-4.2_5.1.62.patch
deleted file mode 100644
index 2ab4150..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.62.patch
+++ /dev/null
@@ -1,3850 +0,0 @@
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql.orig/client/mysqlbinlog.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/client/mysqlbinlog.cc 2012-03-31 22:08:57.703628635 -0700
-@@ -1954,7 +1954,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql.cc mysql/client/mysql.cc
---- mysql.orig/client/mysql.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/client/mysql.cc 2012-03-31 22:08:57.705628671 -0700
-@@ -3334,9 +3334,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3356,7 +3356,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql.orig/client/mysqldump.c 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/client/mysqldump.c 2012-03-31 22:08:57.707628699 -0700
-@@ -840,7 +840,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4727,7 +4727,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql.orig/client/mysqltest.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/client/mysqltest.cc 2012-03-31 22:08:57.709628727 -0700
-@@ -5666,9 +5666,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql.orig/client/mysql_upgrade.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/client/mysql_upgrade.c 2012-03-31 22:08:57.710628744 -0700
-@@ -533,7 +533,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql.orig/client/sql_string.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/client/sql_string.cc 2012-03-31 22:08:57.710628744 -0700
-@@ -665,7 +665,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -751,7 +751,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -768,7 +768,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql.orig/dbug/dbug.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/dbug/dbug.c 2012-03-31 22:08:57.711628761 -0700
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql.orig/extra/yassl/src/ssl.cpp 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/extra/yassl/src/ssl.cpp 2012-03-31 22:08:57.711628761 -0700
-@@ -39,6 +39,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -114,7 +115,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql.orig/extra/yassl/taocrypt/include/pwdbased.hpp 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2012-03-31 22:08:57.712628777 -0700
-@@ -68,7 +68,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql.orig/extra/yassl/taocrypt/src/dh.cpp 2012-03-02 06:39:23.000000000 -0800
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2012-03-31 22:08:57.712628777 -0700
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/include/my_global.h mysql/include/my_global.h
---- mysql.orig/include/my_global.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/include/my_global.h 2012-03-31 22:08:57.713628793 -0700
-@@ -586,10 +586,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql.orig/libmysql/libmysql.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/libmysql/libmysql.c 2012-03-31 22:08:57.715628824 -0700
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql.orig/libmysqld/lib_sql.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/libmysqld/lib_sql.cc 2012-03-31 22:08:57.716628840 -0700
-@@ -848,7 +848,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/array.c mysql/mysys/array.c
---- mysql.orig/mysys/array.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/mysys/array.c 2012-03-31 22:08:57.717628856 -0700
-@@ -50,7 +50,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -344,7 +344,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/default.c mysql/mysys/default.c
---- mysql.orig/mysys/default.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/default.c 2012-03-31 22:08:57.717628856 -0700
-@@ -796,7 +796,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql.orig/mysys/mf_format.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/mf_format.c 2012-03-31 22:08:57.718628872 -0700
-@@ -86,7 +86,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql.orig/mysys/mf_iocache.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/mf_iocache.c 2012-03-31 22:08:57.719628888 -0700
-@@ -1099,7 +1099,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1258,7 +1258,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1367,7 +1367,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1401,7 +1401,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql.orig/mysys/my_alloc.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/my_alloc.c 2012-03-31 22:08:57.720628904 -0700
-@@ -214,7 +214,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql.orig/mysys/my_bitmap.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/my_bitmap.c 2012-03-31 22:08:57.720628904 -0700
-@@ -425,7 +425,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compare.c mysql/mysys/my_compare.c
---- mysql.orig/mysys/my_compare.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/mysys/my_compare.c 2012-03-31 22:08:57.720628904 -0700
-@@ -30,7 +30,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -158,7 +158,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql.orig/mysys/my_compress.c 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/mysys/my_compress.c 2012-03-31 22:08:57.720628904 -0700
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql.orig/mysys/my_conio.c 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/mysys/my_conio.c 2012-03-31 22:08:57.721628919 -0700
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql.orig/mysys/my_file.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/my_file.c 2012-03-31 22:08:57.721628919 -0700
-@@ -77,7 +77,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -99,7 +99,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -109,9 +109,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql.orig/mysys/my_getopt.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/my_getopt.c 2012-03-31 22:08:57.722628934 -0700
-@@ -985,7 +985,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql.orig/mysys/my_static.h 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/mysys/my_static.h 2012-03-31 22:08:57.723628950 -0700
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql.orig/mysys/safemalloc.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/mysys/safemalloc.c 2012-03-31 22:08:57.723628950 -0700
-@@ -250,7 +250,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql.orig/mysys/stacktrace.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/mysys/stacktrace.c 2012-03-31 22:08:57.724628966 -0700
-@@ -98,7 +98,7 @@
- /* Read up to the maximum number of bytes. */
- while (total)
- {
-- count= min(sizeof(buf), total);
-+ count= MYSQL_MIN(sizeof(buf), total);
-
- if ((nbytes= pread(fd, buf, count, offset)) < 0)
- {
-@@ -328,7 +328,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) & ~(ulong) 0xFFFF);
- my_safe_printf_stderr("Cannot determine thread, fp=%p, "
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql.orig/server-tools/instance-manager/buffer.cc 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/server-tools/instance-manager/buffer.cc 2012-03-31 22:08:57.725628982 -0700
-@@ -86,8 +86,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql.orig/server-tools/instance-manager/listener.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/server-tools/instance-manager/listener.cc 2012-03-31 22:08:57.725628982 -0700
-@@ -106,7 +106,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql.orig/sql/debug_sync.cc 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/sql/debug_sync.cc 2012-03-31 22:08:57.726628998 -0700
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/field.cc mysql/sql/field.cc
---- mysql.orig/sql/field.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/field.cc 2012-03-31 22:08:57.729629046 -0700
-@@ -55,7 +55,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2073,7 +2073,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2081,7 +2081,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2506,7 +2506,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2522,7 +2522,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3092,7 +3092,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3304,7 +3304,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3521,7 +3521,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3740,7 +3740,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3981,7 +3981,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4204,7 +4204,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6443,13 +6443,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6457,7 +6457,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6715,7 +6715,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7709,7 +7709,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7869,7 +7869,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8065,7 +8065,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9783,7 +9783,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql.orig/sql/filesort.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/sql/filesort.cc 2012-03-31 22:09:57.110571120 -0700
-@@ -194,7 +194,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -216,12 +216,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
-
- if (table_sort.sort_keys &&
- table_sort.sort_keys_size != char_array_size(param.keys,
-@@ -1133,7 +1133,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1396,7 +1396,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql.orig/sql/ha_ndbcluster.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/ha_ndbcluster.cc 2012-03-31 22:08:57.731629078 -0700
-@@ -799,7 +799,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/handler.h mysql/sql/handler.h
---- mysql.orig/sql/handler.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/handler.h 2012-03-31 22:08:57.732629094 -0700
-@@ -1607,15 +1607,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql.orig/sql/ha_partition.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/ha_partition.cc 2012-03-31 22:08:57.733629110 -0700
-@@ -6138,7 +6138,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql.orig/sql/item_buff.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/item_buff.cc 2012-03-31 22:08:57.733629110 -0700
-@@ -61,7 +61,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -71,7 +71,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item.cc mysql/sql/item.cc
---- mysql.orig/sql/item.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/item.cc 2012-03-31 22:08:57.734629126 -0700
-@@ -76,7 +76,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -444,9 +444,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -752,7 +752,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5416,7 +5416,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5471,7 +5471,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7561,14 +7561,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7599,7 +7599,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7621,7 +7621,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7639,7 +7639,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql.orig/sql/item_cmpfunc.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/item_cmpfunc.cc 2012-03-31 22:08:57.736629157 -0700
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4979,7 +4979,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4998,7 +4998,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5119,14 +5119,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5150,14 +5150,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql.orig/sql/item_func.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/item_func.cc 2012-03-31 22:08:57.740629220 -0700
-@@ -549,7 +549,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1143,10 +1143,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1256,9 +1256,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1306,7 +1306,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1315,7 +1315,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1329,7 +1329,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1460,8 +1460,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1983,7 +1983,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1993,7 +1993,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2010,13 +2010,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2117,7 +2117,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2989,7 +2989,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2998,7 +2998,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_func.h mysql/sql/item_func.h
---- mysql.orig/sql/item_func.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/item_func.h 2012-03-31 22:08:57.741629236 -0700
-@@ -421,7 +421,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql.orig/sql/item_strfunc.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/item_strfunc.cc 2012-03-31 22:08:57.742629252 -0700
-@@ -389,7 +389,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -750,7 +750,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1251,7 +1251,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1271,7 +1271,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1962,7 +1962,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3114,11 +3114,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3582,7 +3582,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql.orig/sql/item_strfunc.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/item_strfunc.h 2012-03-31 22:08:57.742629252 -0700
-@@ -709,7 +709,7 @@
- collation.set(args[0]->collation);
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
- 2 * collation.collation->mbmaxlen;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- }
- };
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql.orig/sql/item_sum.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/item_sum.cc 2012-03-31 22:08:57.743629268 -0700
-@@ -1139,7 +1139,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1202,16 +1202,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1402,13 +1402,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3345,7 +3345,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql.orig/sql/item_timefunc.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/item_timefunc.cc 2012-03-31 22:08:57.744629284 -0700
-@@ -310,14 +310,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -326,7 +326,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -343,15 +343,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -362,14 +362,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -377,7 +377,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -429,7 +429,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -441,7 +441,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -453,7 +453,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -598,7 +598,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1830,7 +1830,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/key.cc mysql/sql/key.cc
---- mysql.orig/sql/key.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/key.cc 2012-03-31 22:08:57.744629284 -0700
-@@ -128,13 +128,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -218,7 +218,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -227,7 +227,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -288,7 +288,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -354,7 +354,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log.cc mysql/sql/log.cc
---- mysql.orig/sql/log.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/log.cc 2012-03-31 22:08:57.746629316 -0700
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2429,7 +2429,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5237,7 +5237,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql.orig/sql/log_event.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/log_event.cc 2012-03-31 22:08:57.750629380 -0700
-@@ -1082,7 +1082,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2678,7 +2678,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5595,7 +5595,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7322,7 +7322,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql.orig/sql/log_event_old.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/log_event_old.cc 2012-03-31 22:08:57.750629380 -0700
-@@ -1434,7 +1434,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql.orig/sql/mysqld.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/mysqld.cc 2012-03-31 22:08:57.753629426 -0700
-@@ -3243,7 +3243,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3255,15 +3255,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4949,7 +4949,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql.orig/sql/net_serv.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/net_serv.cc 2012-03-31 22:08:57.754629442 -0700
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql.orig/sql/opt_range.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/opt_range.cc 2012-03-31 22:08:57.758629506 -0700
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql.orig/sql/opt_range.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/opt_range.h 2012-03-31 22:08:57.762629570 -0700
-@@ -85,7 +85,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -123,7 +123,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql.orig/sql/protocol.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/protocol.cc 2012-03-31 22:08:57.763629586 -0700
-@@ -168,7 +168,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -263,7 +263,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql.orig/sql/rpl_record.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/rpl_record.cc 2012-03-31 22:08:57.764629602 -0700
-@@ -287,7 +287,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql.orig/sql/rpl_rli.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/rpl_rli.cc 2012-03-31 22:08:57.764629602 -0700
-@@ -688,7 +688,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -698,7 +698,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql.orig/sql/rpl_utility.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/rpl_utility.cc 2012-03-31 22:08:57.765629618 -0700
-@@ -182,7 +182,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql.orig/sql/rpl_utility.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/rpl_utility.h 2012-03-31 22:08:57.765629618 -0700
-@@ -297,7 +297,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql.orig/sql/set_var.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/set_var.cc 2012-03-31 22:08:57.767629648 -0700
-@@ -1847,7 +1847,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4032,7 +4032,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/slave.cc mysql/sql/slave.cc
---- mysql.orig/sql/slave.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/sql/slave.cc 2012-03-31 22:08:57.768629664 -0700
-@@ -1743,7 +1743,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2360,7 +2360,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4057,7 +4057,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/spatial.h mysql/sql/spatial.h
---- mysql.orig/sql/spatial.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/spatial.h 2012-03-31 22:08:57.769629680 -0700
-@@ -182,8 +182,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql.orig/sql/sp_head.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/sql/sp_head.cc 2012-03-31 22:08:57.770629696 -0700
-@@ -2481,7 +2481,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2682,7 +2682,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql.orig/sql/sql_acl.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_acl.cc 2012-03-31 22:08:57.772629728 -0700
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql.orig/sql/sql_analyse.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_analyse.cc 2012-03-31 22:08:57.773629744 -0700
-@@ -282,16 +282,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1045,7 +1045,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1070,7 +1070,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1187,7 +1187,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql.orig/sql/sql_cache.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_cache.cc 2012-03-31 22:08:57.775629776 -0700
-@@ -1006,7 +1006,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2451,7 +2451,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2506,7 +2506,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2534,7 +2534,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2622,8 +2622,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2655,7 +2655,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2664,7 +2664,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3087,7 +3087,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql.orig/sql/sql_class.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/sql/sql_class.cc 2012-03-31 22:08:57.777629808 -0700
-@@ -417,7 +417,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -432,7 +432,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2101,7 +2101,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql.orig/sql/sql_client.cc 2012-03-02 06:39:25.000000000 -0800
-+++ mysql/sql/sql_client.cc 2012-03-31 22:08:57.777629808 -0700
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql.orig/sql/sql_connect.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_connect.cc 2012-03-31 22:08:57.778629824 -0700
-@@ -845,7 +845,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql.orig/sql/sql_parse.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_parse.cc 2012-03-31 22:08:57.779629840 -0700
-@@ -5756,7 +5756,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7286,7 +7286,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql.orig/sql/sql_partition.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_partition.cc 2012-03-31 22:08:57.781629871 -0700
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql.orig/sql/sql_plugin.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_plugin.cc 2012-03-31 22:08:57.783629902 -0700
-@@ -512,7 +512,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2131,7 +2131,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql.orig/sql/sql_prepare.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_prepare.cc 2012-03-31 22:08:57.784629918 -0700
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql.orig/sql/sql_profile.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_profile.cc 2012-03-31 22:08:57.785629934 -0700
-@@ -254,7 +254,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql.orig/sql/sql_repl.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/sql_repl.cc 2012-03-31 22:08:57.786629950 -0700
-@@ -1299,12 +1299,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1476,7 +1476,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1747,14 +1747,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1763,7 +1763,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql.orig/sql/sql_select.cc 2012-03-02 06:39:18.000000000 -0800
-+++ mysql/sql/sql_select.cc 2012-03-31 22:08:57.790630014 -0700
-@@ -3016,7 +3016,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3952,7 +3952,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3975,7 +3975,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4138,7 +4138,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4458,7 +4458,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4625,7 +4625,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5575,7 +5575,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10481,7 +10481,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13696,7 +13696,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13708,7 +13708,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14406,7 +14406,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14528,7 +14528,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql.orig/sql/sql_show.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_show.cc 2012-03-31 22:08:57.791630030 -0700
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1875,7 +1875,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2006,7 +2006,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3271,7 +3271,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7088,7 +7088,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql.orig/sql/sql_string.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_string.cc 2012-03-31 22:08:57.792630046 -0700
-@@ -700,7 +700,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -786,7 +786,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -803,7 +803,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -1004,7 +1004,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1190,7 +1190,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql.orig/sql/sql_table.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_table.cc 2012-03-31 22:08:57.793630062 -0700
-@@ -3276,7 +3276,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql.orig/sql/sql_yacc.cc 2012-03-02 06:46:17.000000000 -0800
-+++ mysql/sql/sql_yacc.cc 2012-03-31 22:08:57.799630156 -0700
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql.orig/sql/sql_yacc.yy 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql/sql_yacc.yy 2012-03-31 22:08:57.802630204 -0700
-@@ -1807,7 +1807,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1817,7 +1817,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql.orig/sql/thr_malloc.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/thr_malloc.cc 2012-03-31 22:08:57.803630220 -0700
-@@ -132,7 +132,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql.orig/sql/tztime.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/tztime.cc 2012-03-31 22:08:57.803630220 -0700
-@@ -169,7 +169,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -398,7 +398,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1825,7 +1825,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql.orig/sql/unireg.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/sql/unireg.cc 2012-03-31 22:08:57.804630236 -0700
-@@ -498,7 +498,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -718,7 +718,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/client.c mysql/sql-common/client.c
---- mysql.orig/sql-common/client.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/sql-common/client.c 2012-03-31 22:08:57.805630252 -0700
-@@ -730,7 +730,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2104,7 +2104,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql.orig/sql-common/my_time.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/sql-common/my_time.c 2012-03-31 22:08:57.806630268 -0700
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql.orig/storage/csv/ha_tina.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/csv/ha_tina.cc 2012-03-31 22:08:57.807630284 -0700
-@@ -1195,7 +1195,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1431,7 +1431,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql.orig/storage/example/ha_example.h 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/example/ha_example.h 2012-03-31 22:08:57.808630300 -0700
-@@ -112,14 +112,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -130,7 +130,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -141,7 +141,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql.orig/storage/federated/ha_federated.cc 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/federated/ha_federated.cc 2012-03-31 22:08:57.808630300 -0700
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql.orig/storage/heap/hp_create.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/heap/hp_create.c 2012-03-31 22:08:57.809630316 -0700
-@@ -230,7 +230,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql.orig/storage/heap/hp_test2.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/heap/hp_test2.c 2012-03-31 22:08:57.810630332 -0700
-@@ -138,7 +138,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -219,7 +219,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql.orig/storage/innobase/include/ut0byte.h 2012-03-02 06:39:22.000000000 -0800
-+++ mysql/storage/innobase/include/ut0byte.h 2012-03-31 22:08:57.810630332 -0700
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql.orig/storage/innodb_plugin/dict/dict0dict.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2012-03-31 22:08:57.812630362 -0700
-@@ -4860,7 +4860,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4870,7 +4870,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql.orig/storage/innodb_plugin/include/dict0dict.h 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2012-03-31 22:08:57.813630378 -0700
-@@ -1123,7 +1123,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql.orig/storage/myisam/ft_boolean_search.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/myisam/ft_boolean_search.c 2012-03-31 22:08:57.814630394 -0700
-@@ -48,9 +48,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql.orig/storage/myisam/ha_myisam.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/ha_myisam.cc 2012-03-31 22:08:57.815630410 -0700
-@@ -1546,7 +1546,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql.orig/storage/myisam/mi_cache.c 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/storage/myisam/mi_cache.c 2012-03-31 22:08:57.815630410 -0700
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql.orig/storage/myisam/mi_check.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/myisam/mi_check.c 2012-03-31 22:10:42.503291186 -0700
-@@ -2175,7 +2175,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2331,7 +2331,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2420,7 +2420,7 @@
- (see _create_index_by_sort)
- */
- sort_info.max_records= 10 *
-- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
-+ MYSQL_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
- sort_param.key_length;
- }
-
-@@ -2784,7 +2784,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3982,7 +3982,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql.orig/storage/myisam/mi_create.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_create.c 2012-03-31 22:08:57.818630458 -0700
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql.orig/storage/myisam/mi_dynrec.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_dynrec.c 2012-03-31 22:08:57.819630474 -0700
-@@ -882,7 +882,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql.orig/storage/myisam/mi_extra.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_extra.c 2012-03-31 22:08:57.820630490 -0700
-@@ -101,7 +101,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql.orig/storage/myisam/mi_open.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_open.c 2012-03-31 22:08:57.820630490 -0700
-@@ -330,7 +330,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -503,7 +503,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -716,10 +716,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql.orig/storage/myisam/mi_packrec.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/storage/myisam/mi_packrec.c 2012-03-31 22:08:57.821630506 -0700
-@@ -686,7 +686,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1401,7 +1401,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql.orig/storage/myisam/mi_test1.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_test1.c 2012-03-31 22:08:57.822630521 -0700
-@@ -438,7 +438,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql.orig/storage/myisam/mi_test2.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/mi_test2.c 2012-03-31 22:08:57.823630537 -0700
-@@ -603,7 +603,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql.orig/storage/myisam/myisamlog.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/myisamlog.c 2012-03-31 22:08:57.824630553 -0700
-@@ -92,7 +92,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql.orig/storage/myisam/myisampack.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/myisampack.c 2012-03-31 22:08:57.825630569 -0700
-@@ -1240,7 +1240,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3002,7 +3002,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql.orig/storage/myisam/rt_mbr.c 2012-03-02 06:39:25.000000000 -0800
-+++ mysql/storage/myisam/rt_mbr.c 2012-03-31 22:08:57.826630585 -0700
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql.orig/storage/myisam/sort.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisam/sort.c 2012-03-31 22:08:57.827630601 -0700
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql.orig/storage/myisammrg/ha_myisammrg.cc 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2012-03-31 22:08:57.827630601 -0700
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql.orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-03-31 22:08:57.828630617 -0700
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql.orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-03-02 06:39:23.000000000 -0800
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-03-31 22:08:57.828630617 -0700
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql.orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-03-02 06:39:24.000000000 -0800
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-03-31 22:08:57.828630617 -0700
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql.orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-03-02 06:39:26.000000000 -0800
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-03-31 22:08:57.829630633 -0700
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql.orig/storage/ndb/test/src/getarg.c 2012-03-02 06:39:23.000000000 -0800
-+++ mysql/storage/ndb/test/src/getarg.c 2012-03-31 22:08:57.830630648 -0700
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql.orig/strings/ctype-big5.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/strings/ctype-big5.c 2012-03-31 22:08:57.833630696 -0700
-@@ -254,7 +254,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -267,7 +267,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql.orig/strings/ctype-bin.c 2012-03-02 06:39:20.000000000 -0800
-+++ mysql/strings/ctype-bin.c 2012-03-31 22:08:57.833630696 -0700
-@@ -82,7 +82,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -133,7 +133,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -177,7 +177,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -406,7 +406,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -419,7 +419,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql.orig/strings/ctype-gbk.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/ctype-gbk.c 2012-03-31 22:08:57.837630759 -0700
-@@ -2617,7 +2617,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2628,7 +2628,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql.orig/strings/ctype-mb.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/ctype-mb.c 2012-03-31 22:08:57.838630775 -0700
-@@ -369,7 +369,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -413,7 +413,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -452,7 +452,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql.orig/strings/ctype-simple.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/ctype-simple.c 2012-03-31 22:08:57.838630775 -0700
-@@ -161,7 +161,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -875,7 +875,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -929,7 +929,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1160,7 +1160,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql.orig/strings/ctype-tis620.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/ctype-tis620.c 2012-03-31 22:08:57.839630791 -0700
-@@ -583,7 +583,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -640,7 +640,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql.orig/strings/ctype-uca.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/ctype-uca.c 2012-03-31 22:08:57.840630807 -0700
-@@ -7569,7 +7569,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql.orig/strings/ctype-ucs2.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/strings/ctype-ucs2.c 2012-03-31 22:08:57.841630823 -0700
-@@ -280,7 +280,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1332,7 +1332,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1426,7 +1426,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1473,7 +1473,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql.orig/strings/ctype-utf8.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/strings/ctype-utf8.c 2012-03-31 22:08:57.842630839 -0700
-@@ -2114,7 +2114,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/decimal.c mysql/strings/decimal.c
---- mysql.orig/strings/decimal.c 2012-03-02 06:39:19.000000000 -0800
-+++ mysql/strings/decimal.c 2012-03-31 22:08:57.843630855 -0700
-@@ -405,7 +405,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -428,7 +428,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1531,8 +1531,8 @@
-
- if (to != from)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg0+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg0+MYSQL_MAX(frac1, frac0);
-
- DBUG_ASSERT(p0 - buf0 <= len);
- DBUG_ASSERT(p1 - buf1 <= len);
-@@ -1543,7 +1543,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1645,7 +1645,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1664,7 +1664,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1713,11 +1713,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1732,7 +1732,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1757,7 +1757,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1768,7 +1768,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN(frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1786,14 +1786,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1814,7 +1814,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1889,7 +1889,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1900,7 +1900,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1924,7 +1924,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2187,11 +2187,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2315,7 +2315,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2353,7 +2353,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql.orig/strings/my_vsnprintf.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/my_vsnprintf.c 2012-03-31 22:08:57.843630855 -0700
-@@ -143,7 +143,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/strings/str2int.c mysql/strings/str2int.c
---- mysql.orig/strings/str2int.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/strings/str2int.c 2012-03-31 22:08:57.843630855 -0700
-@@ -84,7 +84,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/tests/mysql_client_test.c mysql/tests/mysql_client_test.c
---- mysql.orig/tests/mysql_client_test.c 2012-03-31 13:43:40.305204380 -0700
-+++ mysql/tests/mysql_client_test.c 2012-03-31 22:08:57.845630886 -0700
-@@ -610,7 +610,7 @@
- return row_count;
- }
-
-- field_count= min(mysql_num_fields(result), MAX_RES_FIELDS);
-+ field_count= MYSQL_MIN(mysql_num_fields(result), MAX_RES_FIELDS);
-
- bzero((char*) buffer, sizeof(buffer));
- bzero((char*) length, sizeof(length));
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql.orig/vio/viosocket.c 2012-03-02 06:39:21.000000000 -0800
-+++ mysql/vio/viosocket.c 2012-03-31 22:08:57.846630902 -0700
-@@ -72,7 +72,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.65.patch b/07110_all_mysql_gcc-4.2_5.1.65.patch
deleted file mode 100644
index 9755a95..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.65.patch
+++ /dev/null
@@ -1,3838 +0,0 @@
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -ur mysql-orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-orig/client/mysqlbinlog.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqlbinlog.cc 2012-08-14 01:14:59.292197574 +0000
-@@ -1978,7 +1978,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -ur mysql-orig/client/mysql.cc mysql/client/mysql.cc
---- mysql-orig/client/mysql.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysql.cc 2012-08-14 01:14:59.322198687 +0000
-@@ -3334,9 +3334,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3356,7 +3356,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -ur mysql-orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-orig/client/mysqldump.c 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqldump.c 2012-08-14 01:14:59.322198687 +0000
-@@ -849,7 +849,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4769,7 +4769,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -ur mysql-orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-orig/client/mysqltest.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqltest.cc 2012-08-14 01:14:59.322198687 +0000
-@@ -5666,9 +5666,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -ur mysql-orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-orig/client/mysql_upgrade.c 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysql_upgrade.c 2012-08-14 01:14:59.332198575 +0000
-@@ -533,7 +533,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -ur mysql-orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-orig/client/sql_string.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/sql_string.cc 2012-08-14 01:14:59.332198575 +0000
-@@ -665,7 +665,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -751,7 +751,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -768,7 +768,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -ur mysql-orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-orig/dbug/dbug.c 2012-08-14 01:12:29.743434923 +0000
-+++ mysql/dbug/dbug.c 2012-08-14 01:14:59.332198575 +0000
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -ur mysql-orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-orig/extra/yassl/src/ssl.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2012-08-14 01:14:59.332198575 +0000
-@@ -39,6 +39,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -114,7 +115,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -ur mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2012-08-14 01:14:59.332198575 +0000
-@@ -68,7 +68,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -ur mysql-orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-orig/extra/yassl/taocrypt/src/dh.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2012-08-14 01:14:59.332198575 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -ur mysql-orig/include/my_global.h mysql/include/my_global.h
---- mysql-orig/include/my_global.h 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/include/my_global.h 2012-08-14 01:14:59.332198575 +0000
-@@ -586,10 +586,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -ur mysql-orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-orig/libmysql/libmysql.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/libmysql/libmysql.c 2012-08-14 01:14:59.332198575 +0000
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -ur mysql-orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-orig/libmysqld/lib_sql.cc 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/libmysqld/lib_sql.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -844,7 +844,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -ur mysql-orig/mysys/array.c mysql/mysys/array.c
---- mysql-orig/mysys/array.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/array.c 2012-08-14 01:14:59.372198019 +0000
-@@ -50,7 +50,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -344,7 +344,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -ur mysql-orig/mysys/default.c mysql/mysys/default.c
---- mysql-orig/mysys/default.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/default.c 2012-08-14 01:14:59.372198019 +0000
-@@ -796,7 +796,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -ur mysql-orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-orig/mysys/mf_format.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/mf_format.c 2012-08-14 01:14:59.372198019 +0000
-@@ -86,7 +86,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -ur mysql-orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-orig/mysys/mf_iocache.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/mf_iocache.c 2012-08-14 01:14:59.372198019 +0000
-@@ -1099,7 +1099,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1258,7 +1258,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1367,7 +1367,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1401,7 +1401,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -ur mysql-orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-orig/mysys/my_alloc.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_alloc.c 2012-08-14 01:14:59.372198019 +0000
-@@ -214,7 +214,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -ur mysql-orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-orig/mysys/my_bitmap.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_bitmap.c 2012-08-14 01:14:59.372198019 +0000
-@@ -425,7 +425,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -ur mysql-orig/mysys/my_compare.c mysql/mysys/my_compare.c
---- mysql-orig/mysys/my_compare.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_compare.c 2012-08-14 01:14:59.372198019 +0000
-@@ -30,7 +30,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -158,7 +158,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -ur mysql-orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-orig/mysys/my_compress.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_compress.c 2012-08-14 01:14:59.372198019 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -ur mysql-orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-orig/mysys/my_conio.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_conio.c 2012-08-14 01:14:59.372198019 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -ur mysql-orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-orig/mysys/my_file.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_file.c 2012-08-14 01:14:59.372198019 +0000
-@@ -77,7 +77,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -99,7 +99,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -109,9 +109,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -ur mysql-orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-orig/mysys/my_getopt.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_getopt.c 2012-08-14 01:14:59.372198019 +0000
-@@ -985,7 +985,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -ur mysql-orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql-orig/mysys/my_static.h 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_static.h 2012-08-14 01:14:59.372198019 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -ur mysql-orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-orig/mysys/safemalloc.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/safemalloc.c 2012-08-14 01:14:59.372198019 +0000
-@@ -250,7 +250,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -ur mysql-orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-orig/mysys/stacktrace.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/stacktrace.c 2012-08-14 01:14:59.372198019 +0000
-@@ -98,7 +98,7 @@
- /* Read up to the maximum number of bytes. */
- while (total)
- {
-- count= min(sizeof(buf), total);
-+ count= MYSQL_MIN(sizeof(buf), total);
-
- if ((nbytes= pread(fd, buf, count, offset)) < 0)
- {
-@@ -328,7 +328,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) & ~(ulong) 0xFFFF);
- my_safe_printf_stderr("Cannot determine thread, fp=%p, "
-diff -ur mysql-orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-orig/server-tools/instance-manager/buffer.cc 2012-08-14 01:12:29.703435253 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -86,8 +86,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -ur mysql-orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-orig/server-tools/instance-manager/listener.cc 2012-08-14 01:12:29.703435253 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -106,7 +106,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -ur mysql-orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql-orig/sql/debug_sync.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/debug_sync.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -ur mysql-orig/sql/field.cc mysql/sql/field.cc
---- mysql-orig/sql/field.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/field.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -55,7 +55,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2073,7 +2073,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2081,7 +2081,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2506,7 +2506,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2522,7 +2522,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3092,7 +3092,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3304,7 +3304,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3521,7 +3521,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3740,7 +3740,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3981,7 +3981,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4204,7 +4204,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6443,13 +6443,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6457,7 +6457,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6715,7 +6715,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7709,7 +7709,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7869,7 +7869,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8065,7 +8065,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9783,7 +9783,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -ur mysql-orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-orig/sql/filesort.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/filesort.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -194,7 +194,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -216,12 +216,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
-
- if (table_sort.sort_keys &&
- table_sort.sort_keys_size != char_array_size(param.keys,
-@@ -1133,7 +1133,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1396,7 +1396,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -ur mysql-orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-orig/sql/ha_ndbcluster.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -799,7 +799,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -ur mysql-orig/sql/handler.h mysql/sql/handler.h
---- mysql-orig/sql/handler.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/handler.h 2012-08-14 01:14:59.382197947 +0000
-@@ -1607,15 +1607,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -ur mysql-orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql-orig/sql/ha_partition.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/ha_partition.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -6138,7 +6138,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -ur mysql-orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-orig/sql/item_buff.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_buff.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -61,7 +61,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -71,7 +71,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -ur mysql-orig/sql/item.cc mysql/sql/item.cc
---- mysql-orig/sql/item.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -76,7 +76,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -444,9 +444,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -752,7 +752,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5417,7 +5417,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5472,7 +5472,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7554,14 +7554,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7592,7 +7592,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7614,7 +7614,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7632,7 +7632,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -ur mysql-orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-orig/sql/item_cmpfunc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_cmpfunc.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4979,7 +4979,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4998,7 +4998,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5119,14 +5119,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5150,14 +5150,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -ur mysql-orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-orig/sql/item_func.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_func.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -549,7 +549,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1143,10 +1143,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1256,9 +1256,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1306,7 +1306,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1315,7 +1315,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1329,7 +1329,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1460,8 +1460,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1983,7 +1983,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1993,7 +1993,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2010,13 +2010,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2117,7 +2117,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2989,7 +2989,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2998,7 +2998,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -ur mysql-orig/sql/item_func.h mysql/sql/item_func.h
---- mysql-orig/sql/item_func.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_func.h 2012-08-14 01:14:59.402197785 +0000
-@@ -421,7 +421,7 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
-+ max_length= MYSQL_MIN(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
- unsigned_flag=1;
- }
- longlong val_int();
-diff -ur mysql-orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-orig/sql/item_strfunc.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_strfunc.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -389,7 +389,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -750,7 +750,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1251,7 +1251,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1271,7 +1271,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1962,7 +1962,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3114,11 +3114,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3582,7 +3582,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -ur mysql-orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql-orig/sql/item_strfunc.h 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_strfunc.h 2012-08-14 01:14:59.402197785 +0000
-@@ -709,7 +709,7 @@
- collation.set(args[0]->collation);
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
- 2 * collation.collation->mbmaxlen;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- }
- };
-
-diff -ur mysql-orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-orig/sql/item_sum.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_sum.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -1139,7 +1139,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1202,16 +1202,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1402,13 +1402,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3345,7 +3345,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -ur mysql-orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-orig/sql/item_timefunc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_timefunc.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -310,14 +310,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -326,7 +326,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -343,15 +343,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -362,14 +362,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -377,7 +377,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -429,7 +429,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -441,7 +441,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -453,7 +453,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -598,7 +598,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1830,7 +1830,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -ur mysql-orig/sql/key.cc mysql/sql/key.cc
---- mysql-orig/sql/key.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/key.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -128,13 +128,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -218,7 +218,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -227,7 +227,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -288,7 +288,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -354,7 +354,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -ur mysql-orig/sql/log.cc mysql/sql/log.cc
---- mysql-orig/sql/log.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/log.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2432,7 +2432,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5238,7 +5238,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -ur mysql-orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-orig/sql/log_event.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/log_event.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -1099,7 +1099,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2695,7 +2695,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5676,7 +5676,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7426,7 +7426,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -ur mysql-orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql-orig/sql/log_event_old.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/log_event_old.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -1434,7 +1434,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -ur mysql-orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-orig/sql/mysqld.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/mysqld.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -3241,7 +3241,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3253,15 +3253,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4947,7 +4947,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -ur mysql-orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-orig/sql/net_serv.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/net_serv.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -ur mysql-orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-orig/sql/opt_range.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/opt_range.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -ur mysql-orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql-orig/sql/opt_range.h 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/opt_range.h 2012-08-14 01:14:59.422197616 +0000
-@@ -85,7 +85,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -123,7 +123,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -ur mysql-orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-orig/sql/protocol.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/protocol.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -168,7 +168,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -263,7 +263,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -ur mysql-orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-orig/sql/rpl_record.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/rpl_record.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -287,7 +287,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -ur mysql-orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-orig/sql/rpl_rli.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_rli.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -690,7 +690,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -700,7 +700,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -ur mysql-orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-orig/sql/rpl_utility.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_utility.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -182,7 +182,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -ur mysql-orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql-orig/sql/rpl_utility.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_utility.h 2012-08-14 01:14:59.422197616 +0000
-@@ -315,7 +315,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -ur mysql-orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-orig/sql/set_var.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/set_var.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -1849,7 +1849,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4034,7 +4034,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -ur mysql-orig/sql/slave.cc mysql/sql/slave.cc
---- mysql-orig/sql/slave.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/slave.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -1791,7 +1791,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2408,7 +2408,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4112,7 +4112,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -ur mysql-orig/sql/spatial.h mysql/sql/spatial.h
---- mysql-orig/sql/spatial.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/spatial.h 2012-08-14 01:14:59.432197532 +0000
-@@ -182,8 +182,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -ur mysql-orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-orig/sql/sp_head.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sp_head.cc 2012-08-14 01:14:59.432197532 +0000
-@@ -2481,7 +2481,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2682,7 +2682,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -ur mysql-orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-orig/sql/sql_acl.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_acl.cc 2012-08-14 01:14:59.432197532 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -ur mysql-orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-orig/sql/sql_analyse.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_analyse.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -282,16 +282,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1045,7 +1045,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1070,7 +1070,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1187,7 +1187,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -ur mysql-orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-orig/sql/sql_cache.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_cache.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -1006,7 +1006,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2451,7 +2451,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2506,7 +2506,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2534,7 +2534,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2622,8 +2622,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2655,7 +2655,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2664,7 +2664,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3087,7 +3087,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -ur mysql-orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-orig/sql/sql_class.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_class.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -418,7 +418,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -433,7 +433,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2116,7 +2116,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -ur mysql-orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-orig/sql/sql_client.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_client.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -ur mysql-orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-orig/sql/sql_connect.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_connect.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -845,7 +845,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -ur mysql-orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-orig/sql/sql_parse.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_parse.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -5762,7 +5762,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7293,7 +7293,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -ur mysql-orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-orig/sql/sql_partition.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_partition.cc 2012-08-14 01:14:59.462197286 +0000
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -ur mysql-orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-orig/sql/sql_plugin.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_plugin.cc 2012-08-14 01:14:59.472197202 +0000
-@@ -512,7 +512,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2131,7 +2131,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -ur mysql-orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-orig/sql/sql_prepare.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_prepare.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -ur mysql-orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql-orig/sql/sql_profile.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_profile.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -254,7 +254,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -ur mysql-orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-orig/sql/sql_repl.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_repl.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -1299,12 +1299,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1478,7 +1478,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1750,14 +1750,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1766,7 +1766,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -ur mysql-orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-orig/sql/sql_select.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_select.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -3022,7 +3022,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3958,7 +3958,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3981,7 +3981,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4144,7 +4144,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4464,7 +4464,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4631,7 +4631,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5581,7 +5581,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10488,7 +10488,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13708,7 +13708,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13720,7 +13720,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14416,7 +14416,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14538,7 +14538,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -ur mysql-orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-orig/sql/sql_show.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_show.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1875,7 +1875,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2006,7 +2006,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3276,7 +3276,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7095,7 +7095,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -ur mysql-orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-orig/sql/sql_string.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_string.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -700,7 +700,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -786,7 +786,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -803,7 +803,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -1004,7 +1004,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1190,7 +1190,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -ur mysql-orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-orig/sql/sql_table.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_table.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -3276,7 +3276,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -ur mysql-orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-orig/sql/sql_yacc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_yacc.cc 2012-08-14 01:14:59.502196954 +0000
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -ur mysql-orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql-orig/sql/sql_yacc.yy 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_yacc.yy 2012-08-14 01:14:59.512196872 +0000
-@@ -1807,7 +1807,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1817,7 +1817,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -ur mysql-orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-orig/sql/thr_malloc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/thr_malloc.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -132,7 +132,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -ur mysql-orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-orig/sql/tztime.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/tztime.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -169,7 +169,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -398,7 +398,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1825,7 +1825,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -ur mysql-orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-orig/sql/unireg.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/unireg.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -498,7 +498,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -718,7 +718,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -ur mysql-orig/sql-common/client.c mysql/sql-common/client.c
---- mysql-orig/sql-common/client.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/sql-common/client.c 2012-08-14 01:14:59.512196872 +0000
-@@ -730,7 +730,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2113,7 +2113,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -ur mysql-orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-orig/sql-common/my_time.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/sql-common/my_time.c 2012-08-14 01:14:59.512196872 +0000
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -ur mysql-orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-orig/storage/csv/ha_tina.cc 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/csv/ha_tina.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -1195,7 +1195,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1431,7 +1431,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -ur mysql-orig/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql-orig/storage/example/ha_example.h 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/storage/example/ha_example.h 2012-08-14 01:14:59.512196872 +0000
-@@ -112,14 +112,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -130,7 +130,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -141,7 +141,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -ur mysql-orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-orig/storage/federated/ha_federated.cc 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/federated/ha_federated.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -ur mysql-orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-orig/storage/heap/hp_create.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/heap/hp_create.c 2012-08-14 01:14:59.512196872 +0000
-@@ -230,7 +230,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -ur mysql-orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-orig/storage/heap/hp_test2.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/heap/hp_test2.c 2012-08-14 01:14:59.512196872 +0000
-@@ -138,7 +138,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -219,7 +219,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -ur mysql-orig/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql-orig/storage/innobase/include/ut0byte.h 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/innobase/include/ut0byte.h 2012-08-14 01:14:59.522196790 +0000
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -ur mysql-orig/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql-orig/storage/innodb_plugin/dict/dict0dict.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2012-08-14 01:14:59.522196790 +0000
-@@ -4898,7 +4898,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4908,7 +4908,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -ur mysql-orig/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql-orig/storage/innodb_plugin/include/dict0dict.h 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2012-08-14 01:14:59.552196542 +0000
-@@ -1115,7 +1115,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -ur mysql-orig/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql-orig/storage/myisam/ft_boolean_search.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/ft_boolean_search.c 2012-08-14 01:14:59.552196542 +0000
-@@ -48,9 +48,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -ur mysql-orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-orig/storage/myisam/ha_myisam.cc 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2012-08-14 01:14:59.552196542 +0000
-@@ -1546,7 +1546,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -ur mysql-orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-orig/storage/myisam/mi_cache.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_cache.c 2012-08-14 01:14:59.572196376 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -ur mysql-orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-orig/storage/myisam/mi_check.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_check.c 2012-08-14 01:14:59.572196376 +0000
-@@ -2175,7 +2175,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2331,7 +2331,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2420,7 +2420,7 @@
- (see _create_index_by_sort)
- */
- sort_info.max_records= 10 *
-- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
-+ MYSQL_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
- sort_param.key_length;
- }
-
-@@ -2784,7 +2784,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3982,7 +3982,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-diff -ur mysql-orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-orig/storage/myisam/mi_create.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_create.c 2012-08-14 01:14:59.572196376 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-orig/storage/myisam/mi_dynrec.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2012-08-14 01:14:59.572196376 +0000
-@@ -882,7 +882,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -ur mysql-orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-orig/storage/myisam/mi_extra.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_extra.c 2012-08-14 01:14:59.572196376 +0000
-@@ -101,7 +101,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -ur mysql-orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-orig/storage/myisam/mi_open.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_open.c 2012-08-14 01:14:59.582196294 +0000
-@@ -330,7 +330,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -503,7 +503,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -716,10 +716,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -ur mysql-orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-orig/storage/myisam/mi_packrec.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2012-08-14 01:14:59.582196294 +0000
-@@ -686,7 +686,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1401,7 +1401,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -ur mysql-orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-orig/storage/myisam/mi_test1.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_test1.c 2012-08-14 01:14:59.582196294 +0000
-@@ -438,7 +438,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -ur mysql-orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-orig/storage/myisam/mi_test2.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_test2.c 2012-08-14 01:14:59.582196294 +0000
-@@ -603,7 +603,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -ur mysql-orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-orig/storage/myisam/myisamlog.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/myisamlog.c 2012-08-14 01:14:59.582196294 +0000
-@@ -92,7 +92,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -ur mysql-orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-orig/storage/myisam/myisampack.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/myisampack.c 2012-08-14 01:14:59.582196294 +0000
-@@ -1240,7 +1240,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3002,7 +3002,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-orig/storage/myisam/rt_mbr.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2012-08-14 01:14:59.582196294 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -ur mysql-orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-orig/storage/myisam/sort.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/sort.c 2012-08-14 01:14:59.582196294 +0000
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -ur mysql-orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-orig/storage/myisammrg/ha_myisammrg.cc 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2012-08-14 01:14:59.582196294 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -ur mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-08-14 01:12:29.673435501 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -ur mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-08-14 01:12:29.683435419 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -ur mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -ur mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -ur mysql-orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-orig/storage/ndb/test/src/getarg.c 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2012-08-14 01:14:59.582196294 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -ur mysql-orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-orig/strings/ctype-big5.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-big5.c 2012-08-14 01:14:59.592196210 +0000
-@@ -254,7 +254,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -267,7 +267,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-orig/strings/ctype-bin.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-bin.c 2012-08-14 01:14:59.592196210 +0000
-@@ -82,7 +82,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -133,7 +133,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -177,7 +177,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -406,7 +406,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -419,7 +419,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-orig/strings/ctype-gbk.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-gbk.c 2012-08-14 01:14:59.592196210 +0000
-@@ -2617,7 +2617,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2628,7 +2628,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-orig/strings/ctype-mb.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-mb.c 2012-08-14 01:14:59.592196210 +0000
-@@ -369,7 +369,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -413,7 +413,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -452,7 +452,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-orig/strings/ctype-simple.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-simple.c 2012-08-14 01:14:59.592196210 +0000
-@@ -161,7 +161,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -875,7 +875,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -929,7 +929,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1160,7 +1160,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -ur mysql-orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-orig/strings/ctype-tis620.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-tis620.c 2012-08-14 01:14:59.592196210 +0000
-@@ -583,7 +583,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -640,7 +640,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -ur mysql-orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-orig/strings/ctype-uca.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-uca.c 2012-08-14 01:14:59.592196210 +0000
-@@ -7569,7 +7569,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -ur mysql-orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-orig/strings/ctype-ucs2.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-ucs2.c 2012-08-14 01:14:59.602196128 +0000
-@@ -280,7 +280,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1332,7 +1332,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1426,7 +1426,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1473,7 +1473,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-orig/strings/ctype-utf8.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-utf8.c 2012-08-14 01:14:59.602196128 +0000
-@@ -2114,7 +2114,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -ur mysql-orig/strings/decimal.c mysql/strings/decimal.c
---- mysql-orig/strings/decimal.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/decimal.c 2012-08-14 01:14:59.602196128 +0000
-@@ -405,7 +405,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -428,7 +428,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1531,8 +1531,8 @@
-
- if (to != from)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg0+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg0+MYSQL_MAX(frac1, frac0);
-
- DBUG_ASSERT(p0 - buf0 <= len);
- DBUG_ASSERT(p1 - buf1 <= len);
-@@ -1543,7 +1543,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1645,7 +1645,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1664,7 +1664,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1713,11 +1713,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1732,7 +1732,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1757,7 +1757,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1768,7 +1768,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN(frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1786,14 +1786,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1814,7 +1814,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1889,7 +1889,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1900,7 +1900,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1924,7 +1924,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2187,11 +2187,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2315,7 +2315,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2353,7 +2353,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -ur mysql-orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-orig/strings/my_vsnprintf.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/my_vsnprintf.c 2012-08-14 01:14:59.602196128 +0000
-@@ -143,7 +143,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -ur mysql-orig/strings/str2int.c mysql/strings/str2int.c
---- mysql-orig/strings/str2int.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/str2int.c 2012-08-14 01:14:59.602196128 +0000
-@@ -84,7 +84,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -ur mysql-orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-orig/vio/viosocket.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/vio/viosocket.c 2012-08-14 01:14:59.602196128 +0000
-@@ -79,7 +79,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07110_all_mysql_gcc-4.2_5.1.69.patch b/07110_all_mysql_gcc-4.2_5.1.69.patch
deleted file mode 100644
index 3d0a742..0000000
--- a/07110_all_mysql_gcc-4.2_5.1.69.patch
+++ /dev/null
@@ -1,3837 +0,0 @@
-X-Gentoo-Bug: 280843
-X-Upstream-Bug: 30866
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=280843
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=30866
-
-diff -ur mysql-orig/client/mysqlbinlog.cc mysql/client/mysqlbinlog.cc
---- mysql-orig/client/mysqlbinlog.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqlbinlog.cc 2012-08-14 01:14:59.292197574 +0000
-@@ -1978,7 +1978,7 @@
- my_off_t length,tmp;
- for (length= start_position_mot ; length > 0 ; length-=tmp)
- {
-- tmp=min(length,sizeof(buff));
-+ tmp=MYSQL_MIN(length,sizeof(buff));
- if (my_b_read(file, buff, (uint) tmp))
- {
- error("Failed reading from file.");
-diff -ur mysql-orig/client/mysql.cc mysql/client/mysql.cc
---- mysql-orig/client/mysql.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysql.cc 2012-08-14 01:14:59.322198687 +0000
-@@ -3334,9 +3334,9 @@
- {
- uint length= column_names ? field->name_length : 0;
- if (quick)
-- length=max(length,field->length);
-+ length=MYSQL_MAX(length,field->length);
- else
-- length=max(length,field->max_length);
-+ length=MYSQL_MAX(length,field->max_length);
- if (length < 4 && !IS_NOT_NULL(field->flags))
- length=4; // Room for "NULL"
- field->max_length=length;
-@@ -3356,7 +3356,7 @@
- field->name,
- field->name + name_length);
- uint display_length= field->max_length + name_length - numcells;
-- tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
-+ tee_fprintf(PAGER, " %-*s |",(int) MYSQL_MIN(display_length,
- MAX_COLUMN_LENGTH),
- field->name);
- num_flag[off]= IS_NUM(field->type);
-diff -ur mysql-orig/client/mysqldump.c mysql/client/mysqldump.c
---- mysql-orig/client/mysqldump.c 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqldump.c 2012-08-14 01:14:59.322198687 +0000
-@@ -849,7 +849,7 @@
- &err_ptr, &err_len);
- if (err_len)
- {
-- strmake(buff, err_ptr, min(sizeof(buff) - 1, err_len));
-+ strmake(buff, err_ptr, MYSQL_MIN(sizeof(buff) - 1, err_len));
- fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
- exit(1);
- }
-@@ -4769,7 +4769,7 @@
-
- for (; pos != end && *pos != ','; pos++) ;
- var_len= (uint) (pos - start);
-- strmake(buff, start, min(sizeof(buff) - 1, var_len));
-+ strmake(buff, start, MYSQL_MIN(sizeof(buff) - 1, var_len));
- find= find_type(buff, lib, var_len);
- if (!find)
- {
-diff -ur mysql-orig/client/mysqltest.cc mysql/client/mysqltest.cc
---- mysql-orig/client/mysqltest.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysqltest.cc 2012-08-14 01:14:59.322198687 +0000
-@@ -5666,9 +5666,9 @@
- }
- else if ((c == '{' &&
- (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
-- (uchar*) buf, min(5, p - buf), 0) ||
-+ (uchar*) buf, MYSQL_MIN(5, p - buf), 0) ||
- !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
-- (uchar*) buf, min(2, p - buf), 0))))
-+ (uchar*) buf, MYSQL_MIN(2, p - buf), 0))))
- {
- /* Only if and while commands can be terminated by { */
- *p++= c;
-diff -ur mysql-orig/client/mysql_upgrade.c mysql/client/mysql_upgrade.c
---- mysql-orig/client/mysql_upgrade.c 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/mysql_upgrade.c 2012-08-14 01:14:59.332198575 +0000
-@@ -533,7 +533,7 @@
- if ((value_end= strchr(value_start, '\n')) == NULL)
- return 1; /* Unexpected result */
-
-- strncpy(value, value_start, min(FN_REFLEN, value_end-value_start));
-+ strncpy(value, value_start, MYSQL_MIN(FN_REFLEN, value_end-value_start));
- return 0;
- }
-
-diff -ur mysql-orig/client/sql_string.cc mysql/client/sql_string.cc
---- mysql-orig/client/sql_string.cc 2012-08-14 01:12:29.733435005 +0000
-+++ mysql/client/sql_string.cc 2012-08-14 01:14:59.332198575 +0000
-@@ -665,7 +665,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -751,7 +751,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -768,7 +768,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-diff -ur mysql-orig/dbug/dbug.c mysql/dbug/dbug.c
---- mysql-orig/dbug/dbug.c 2012-08-14 01:12:29.743434923 +0000
-+++ mysql/dbug/dbug.c 2012-08-14 01:14:59.332198575 +0000
-@@ -1205,7 +1205,7 @@
- if (TRACING)
- {
- Indent(cs, cs->level + 1);
-- pos= min(max(cs->level-cs->stack->sub_level,0)*INDENT,80);
-+ pos= MYSQL_MIN(MYSQL_MAX(cs->level-cs->stack->sub_level,0)*INDENT,80);
- }
- else
- {
-@@ -1690,7 +1690,7 @@
- {
- REGISTER int count;
-
-- indent= max(indent-1-cs->stack->sub_level,0)*INDENT;
-+ indent= MYSQL_MAX(indent-1-cs->stack->sub_level,0)*INDENT;
- for (count= 0; count < indent ; count++)
- {
- if ((count % INDENT) == 0)
-diff -ur mysql-orig/extra/yassl/src/ssl.cpp mysql/extra/yassl/src/ssl.cpp
---- mysql-orig/extra/yassl/src/ssl.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/src/ssl.cpp 2012-08-14 01:14:59.332198575 +0000
-@@ -39,6 +39,7 @@
- #include "file.hpp" // for TaoCrypt Source
- #include "coding.hpp" // HexDecoder
- #include "helpers.hpp" // for placement new hack
-+#include "my_global.h"
- #include <stdio.h>
-
- #ifdef _WIN32
-@@ -114,7 +115,7 @@
- // use file's salt for key derivation, but not real iv
- TaoCrypt::Source source(info.iv, info.ivSz);
- TaoCrypt::HexDecoder dec(source);
-- memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),
-+ memcpy(info.iv, source.get_buffer(), MYSQL_MIN((uint)sizeof(info.iv),
- source.size()));
- EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
- passwordSz, 1, key, iv);
-diff -ur mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp mysql/extra/yassl/taocrypt/include/pwdbased.hpp
---- mysql-orig/extra/yassl/taocrypt/include/pwdbased.hpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/taocrypt/include/pwdbased.hpp 2012-08-14 01:14:59.332198575 +0000
-@@ -68,7 +68,7 @@
- }
- hmac.Final(buffer.get_buffer());
-
-- word32 segmentLen = min(dLen, buffer.size());
-+ word32 segmentLen = MYSQL_MIN(dLen, buffer.size());
- memcpy(derived, buffer.get_buffer(), segmentLen);
-
- for (j = 1; j < iterations; j++) {
-diff -ur mysql-orig/extra/yassl/taocrypt/src/dh.cpp mysql/extra/yassl/taocrypt/src/dh.cpp
---- mysql-orig/extra/yassl/taocrypt/src/dh.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/extra/yassl/taocrypt/src/dh.cpp 2012-08-14 01:14:59.332198575 +0000
-@@ -23,6 +23,7 @@
- #include "runtime.hpp"
- #include "dh.hpp"
- #include "asn.hpp"
-+#include "my_global.h"
- #include <math.h>
-
- namespace TaoCrypt {
-@@ -54,7 +55,7 @@
- // Generate private value
- void DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)
- {
-- Integer x(rng, Integer::One(), min(p_ - 1,
-+ Integer x(rng, Integer::One(), MYSQL_MIN(p_ - 1,
- Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );
- x.Encode(priv, p_.ByteCount());
- }
-diff -ur mysql-orig/include/my_global.h mysql/include/my_global.h
---- mysql-orig/include/my_global.h 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/include/my_global.h 2012-08-14 01:14:59.332198575 +0000
-@@ -586,10 +586,8 @@
- #endif
-
- /* Define some useful general macros */
--#if !defined(max)
--#define max(a, b) ((a) > (b) ? (a) : (b))
--#define min(a, b) ((a) < (b) ? (a) : (b))
--#endif
-+#define MYSQL_MAX(a, b) ((a) > (b) ? (a) : (b))
-+#define MYSQL_MIN(a, b) ((a) < (b) ? (a) : (b))
-
- #if !defined(HAVE_UINT)
- #undef HAVE_UINT
-diff -ur mysql-orig/libmysql/libmysql.c mysql/libmysql/libmysql.c
---- mysql-orig/libmysql/libmysql.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/libmysql/libmysql.c 2012-08-14 01:14:59.332198575 +0000
-@@ -1572,7 +1572,7 @@
- my_net_set_read_timeout(net, CLIENT_NET_READ_TIMEOUT);
- my_net_set_write_timeout(net, CLIENT_NET_WRITE_TIMEOUT);
- net->retry_count= 1;
-- net->max_packet_size= max(net_buffer_length, max_allowed_packet);
-+ net->max_packet_size= MYSQL_MAX(net_buffer_length, max_allowed_packet);
- }
-
- /*
-@@ -3622,7 +3622,7 @@
- copy_length= end - start;
- /* We've got some data beyond offset: copy up to buffer_length bytes */
- if (param->buffer_length)
-- memcpy(buffer, start, min(copy_length, param->buffer_length));
-+ memcpy(buffer, start, MYSQL_MIN(copy_length, param->buffer_length));
- }
- else
- copy_length= 0;
-@@ -3855,9 +3855,9 @@
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
-- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
-+ sprintf(buff, "%-*.*g", (int) MYSQL_MIN(sizeof(buff)-1,
- param->buffer_length),
-- min(DBL_DIG, width), value);
-+ MYSQL_MIN(DBL_DIG,width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
-@@ -4175,7 +4175,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- *param->length= length;
- *param->error= copy_length < length;
-@@ -4187,7 +4187,7 @@
- uchar **row)
- {
- ulong length= net_field_length(row);
-- ulong copy_length= min(length, param->buffer_length);
-+ ulong copy_length= MYSQL_MIN(length, param->buffer_length);
- memcpy(param->buffer, (char *)*row, copy_length);
- /* Add an end null if there is room in the buffer */
- if (copy_length != param->buffer_length)
-diff -ur mysql-orig/libmysqld/lib_sql.cc mysql/libmysqld/lib_sql.cc
---- mysql-orig/libmysqld/lib_sql.cc 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/libmysqld/lib_sql.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -844,7 +844,7 @@
- is cleared between substatements, and mysqltest gets confused
- */
- thd->cur_data->embedded_info->warning_count=
-- (thd->spcont ? 0 : min(total_warn_count, 65535));
-+ (thd->spcont ? 0 : MYSQL_MIN(total_warn_count, 65535));
- return FALSE;
- }
-
-diff -ur mysql-orig/mysys/array.c mysql/mysys/array.c
---- mysql-orig/mysys/array.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/array.c 2012-08-14 01:14:59.372198019 +0000
-@@ -50,7 +50,7 @@
- DBUG_ENTER("init_dynamic_array");
- if (!alloc_increment)
- {
-- alloc_increment=max((8192-MALLOC_OVERHEAD)/element_size,16);
-+ alloc_increment=MYSQL_MAX((8192-MALLOC_OVERHEAD)/element_size,16);
- if (init_alloc > 8 && alloc_increment > init_alloc * 2)
- alloc_increment=init_alloc*2;
- }
-@@ -344,7 +344,7 @@
-
- void freeze_size(DYNAMIC_ARRAY *array)
- {
-- uint elements=max(array->elements,1);
-+ uint elements=MYSQL_MAX(array->elements,1);
-
- /*
- Do nothing if we are using a static buffer
-diff -ur mysql-orig/mysys/default.c mysql/mysys/default.c
---- mysql-orig/mysys/default.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/default.c 2012-08-14 01:14:59.372198019 +0000
-@@ -796,7 +796,7 @@
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
- end[0]=0;
-
-- strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-+ strmake(curr_gr, ptr, MYSQL_MIN((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
-
- /* signal that a new group is found */
- opt_handler(handler_ctx, curr_gr, NULL);
-diff -ur mysql-orig/mysys/mf_format.c mysql/mysys/mf_format.c
---- mysql-orig/mysys/mf_format.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/mf_format.c 2012-08-14 01:14:59.372198019 +0000
-@@ -86,7 +86,7 @@
- tmp_length= strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
- (uint) length));
-- (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
-+ (void) strmake(to,startpos,MYSQL_MIN(tmp_length,FN_REFLEN-1));
- }
- else
- {
-diff -ur mysql-orig/mysys/mf_iocache.c mysql/mysys/mf_iocache.c
---- mysql-orig/mysys/mf_iocache.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/mf_iocache.c 2012-08-14 01:14:59.372198019 +0000
-@@ -1099,7 +1099,7 @@
- */
- while (write_length)
- {
-- size_t copy_length= min(write_length, write_cache->buffer_length);
-+ size_t copy_length= MYSQL_MIN(write_length, write_cache->buffer_length);
- int __attribute__((unused)) rc;
-
- rc= lock_io_cache(write_cache, write_cache->pos_in_file);
-@@ -1258,7 +1258,7 @@
- TODO: figure out if the assert below is needed or correct.
- */
- DBUG_ASSERT(pos_in_file == info->end_of_file);
-- copy_len=min(Count, len_in_buff);
-+ copy_len=MYSQL_MIN(Count, len_in_buff);
- memcpy(Buffer, info->append_read_pos, copy_len);
- info->append_read_pos += copy_len;
- Count -= copy_len;
-@@ -1367,7 +1367,7 @@
- }
- #endif
- /* Copy found bytes to buffer */
-- length=min(Count,read_length);
-+ length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->read_pos,(size_t) length);
- Buffer+=length;
- Count-=length;
-@@ -1401,7 +1401,7 @@
- if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (size_t) -1)
- return info->error= -1;
-- use_length=min(Count,read_length);
-+ use_length=MYSQL_MIN(Count,read_length);
- memcpy(Buffer,info->request_pos,(size_t) use_length);
- info->read_pos=info->request_pos+Count;
- info->read_end=info->request_pos+read_length;
-diff -ur mysql-orig/mysys/my_alloc.c mysql/mysys/my_alloc.c
---- mysql-orig/mysys/my_alloc.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_alloc.c 2012-08-14 01:14:59.372198019 +0000
-@@ -214,7 +214,7 @@
- { /* Time to alloc new block */
- block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
-- get_size= max(get_size, block_size);
-+ get_size= MYSQL_MAX(get_size, block_size);
-
- if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
- {
-diff -ur mysql-orig/mysys/my_bitmap.c mysql/mysys/my_bitmap.c
---- mysql-orig/mysys/my_bitmap.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_bitmap.c 2012-08-14 01:14:59.372198019 +0000
-@@ -425,7 +425,7 @@
-
- DBUG_ASSERT(map->bitmap && map2->bitmap);
-
-- end= to+min(len,len2);
-+ end= to+MYSQL_MIN(len,len2);
- for (; to < end; to++, from++)
- *to &= *from;
-
-diff -ur mysql-orig/mysys/my_compare.c mysql/mysys/my_compare.c
---- mysql-orig/mysys/my_compare.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_compare.c 2012-08-14 01:14:59.372198019 +0000
-@@ -30,7 +30,7 @@
- static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
- my_bool part_key, my_bool skip_end_space)
- {
-- uint length= min(a_length,b_length);
-+ uint length= MYSQL_MIN(a_length,b_length);
- uchar *end= a+ length;
- int flag;
-
-@@ -158,7 +158,7 @@
- continue; /* To next key part */
- }
- }
-- end= a+ min(keyseg->length,key_length);
-+ end= a+ MYSQL_MIN(keyseg->length,key_length);
- next_key_length=key_length-keyseg->length;
-
- switch ((enum ha_base_keytype) keyseg->type) {
-diff -ur mysql-orig/mysys/my_compress.c mysql/mysys/my_compress.c
---- mysql-orig/mysys/my_compress.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_compress.c 2012-08-14 01:14:59.372198019 +0000
-@@ -244,7 +244,7 @@
-
- if (ver != 1)
- DBUG_RETURN(1);
-- if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
-+ if (!(data= my_malloc(MYSQL_MAX(orglen, complen), MYF(MY_WME))))
- DBUG_RETURN(2);
- memcpy(data, pack_data + BLOB_HEADER, complen);
-
-diff -ur mysql-orig/mysys/my_conio.c mysql/mysys/my_conio.c
---- mysql-orig/mysys/my_conio.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_conio.c 2012-08-14 01:14:59.372198019 +0000
-@@ -165,13 +165,13 @@
- though it is known it should not be more than 64K
- so we cut 64K and try first size of screen buffer
- if it is still to large we cut half of it and try again
-- later we may want to cycle from min(clen, 65535) to allowed size
-+ later we may want to cycle from MYSQL_MIN(clen, 65535) to allowed size
- with small decrement to determine exact allowed buffer
- */
-- clen= min(clen, 65535);
-+ clen= MYSQL_MIN(clen, 65535);
- do
- {
-- clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-+ clen= MYSQL_MIN(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
- NULL))
- {
-diff -ur mysql-orig/mysys/my_file.c mysql/mysys/my_file.c
---- mysql-orig/mysys/my_file.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_file.c 2012-08-14 01:14:59.372198019 +0000
-@@ -77,7 +77,7 @@
- static uint set_max_open_files(uint max_file_limit)
- {
- /* We don't know the limit. Return best guess */
-- return min(max_file_limit, OS_FILE_LIMIT);
-+ return MYSQL_MIN(max_file_limit, OS_FILE_LIMIT);
- }
- #endif
-
-@@ -99,7 +99,7 @@
- DBUG_ENTER("my_set_max_open_files");
- DBUG_PRINT("enter",("files: %u my_file_limit: %u", files, my_file_limit));
-
-- files= set_max_open_files(min(files, OS_FILE_LIMIT));
-+ files= set_max_open_files(MYSQL_MIN(files, OS_FILE_LIMIT));
- if (files <= MY_NFILE)
- DBUG_RETURN(files);
-
-@@ -109,9 +109,9 @@
-
- /* Copy any initialized files */
- memcpy((char*) tmp, (char*) my_file_info,
-- sizeof(*tmp) * min(my_file_limit, files));
-+ sizeof(*tmp) * MYSQL_MIN(my_file_limit, files));
- bzero((char*) (tmp + my_file_limit),
-- max((int) (files- my_file_limit), 0)*sizeof(*tmp));
-+ MYSQL_MAX((int) (files- my_file_limit), 0)*sizeof(*tmp));
- my_free_open_file_info(); /* Free if already allocated */
- my_file_info= tmp;
- my_file_limit= files;
-diff -ur mysql-orig/mysys/my_getopt.c mysql/mysys/my_getopt.c
---- mysql-orig/mysys/my_getopt.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_getopt.c 2012-08-14 01:14:59.372198019 +0000
-@@ -985,7 +985,7 @@
- }
- if (optp->max_value && num > (double) optp->max_value)
- num= (double) optp->max_value;
-- return max(num, (double) optp->min_value);
-+ return MYSQL_MAX(num, (double) optp->min_value);
- }
-
- /*
-diff -ur mysql-orig/mysys/my_static.h mysql/mysys/my_static.h
---- mysql-orig/mysys/my_static.h 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/my_static.h 2012-08-14 01:14:59.372198019 +0000
-@@ -22,7 +22,7 @@
- #include <signal.h>
-
- #define MAX_SIGNALS 10 /* Max signals under a dont-allow */
--#define MIN_KEYBLOCK (min(IO_SIZE,1024))
-+#define MIN_KEYBLOCK (MYSQL_MIN(IO_SIZE,1024))
- #define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */
- #define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK
-
-diff -ur mysql-orig/mysys/safemalloc.c mysql/mysys/safemalloc.c
---- mysql-orig/mysys/safemalloc.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/safemalloc.c 2012-08-14 01:14:59.372198019 +0000
-@@ -250,7 +250,7 @@
-
- if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
- {
-- size=min(size, irem->datasize); /* Move as much as possibly */
-+ size=MYSQL_MIN(size, irem->datasize); /* Move as much as possibly */
- memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
- _myfree(ptr, filename, lineno, 0); /* Free not needed area */
- }
-diff -ur mysql-orig/mysys/stacktrace.c mysql/mysys/stacktrace.c
---- mysql-orig/mysys/stacktrace.c 2012-08-14 01:12:29.713435171 +0000
-+++ mysql/mysys/stacktrace.c 2012-08-14 01:14:59.372198019 +0000
-@@ -98,7 +98,7 @@
- /* Read up to the maximum number of bytes. */
- while (total)
- {
-- count= min(sizeof(buf), total);
-+ count= MYSQL_MIN(sizeof(buf), total);
-
- if ((nbytes= pread(fd, buf, count, offset)) < 0)
- {
-@@ -328,7 +328,7 @@
-
- if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp)
- {
-- ulong tmp= min(0x10000,thread_stack);
-+ ulong tmp= MYSQL_MIN(0x10000,thread_stack);
- /* Assume that the stack starts at the previous even 65K */
- stack_bottom= (uchar*) (((ulong) &fp + tmp) & ~(ulong) 0xFFFF);
- my_safe_printf_stderr("Cannot determine thread, fp=%p, "
-diff -ur mysql-orig/server-tools/instance-manager/buffer.cc mysql/server-tools/instance-manager/buffer.cc
---- mysql-orig/server-tools/instance-manager/buffer.cc 2012-08-14 01:12:29.703435253 +0000
-+++ mysql/server-tools/instance-manager/buffer.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -86,8 +86,8 @@
- if (position + len_arg >= buffer_size)
- {
- buffer= (uchar*) my_realloc(buffer,
-- min(MAX_BUFFER_SIZE,
-- max((uint) (buffer_size*1.5),
-+ MYSQL_MIN(MAX_BUFFER_SIZE,
-+ MYSQL_MAX((uint) (buffer_size*1.5),
- position + len_arg)), MYF(0));
- if (!(buffer))
- goto err;
-diff -ur mysql-orig/server-tools/instance-manager/listener.cc mysql/server-tools/instance-manager/listener.cc
---- mysql-orig/server-tools/instance-manager/listener.cc 2012-08-14 01:12:29.703435253 +0000
-+++ mysql/server-tools/instance-manager/listener.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -106,7 +106,7 @@
-
- /* II. Listen sockets and spawn childs */
- for (i= 0; i < num_sockets; i++)
-- n= max(n, sockets[i]);
-+ n= MYSQL_MAX(n, sockets[i]);
- n++;
-
- timeval tv;
-diff -ur mysql-orig/sql/debug_sync.cc mysql/sql/debug_sync.cc
---- mysql-orig/sql/debug_sync.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/debug_sync.cc 2012-08-14 01:14:59.372198019 +0000
-@@ -1036,7 +1036,7 @@
- DBUG_ASSERT(action);
- DBUG_ASSERT(ds_control);
-
-- action->activation_count= max(action->hit_limit, action->execute);
-+ action->activation_count= MYSQL_MAX(action->hit_limit, action->execute);
- if (!action->activation_count)
- {
- debug_sync_remove_action(ds_control, action);
-diff -ur mysql-orig/sql/field.cc mysql/sql/field.cc
---- mysql-orig/sql/field.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/field.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -55,7 +55,7 @@
- #define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
- #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
--((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
-+((ulong) ((LL(1) << MYSQL_MIN(arg, 4) * 8) - LL(1)))
-
- #define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
- #define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
-@@ -2073,7 +2073,7 @@
- tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
- else if (expo_sign_char == '-')
- {
-- tmp_uint=min(exponent,(uint)(int_digits_end-int_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(int_digits_end-int_digits_from));
- frac_digits_added_zeros=exponent-tmp_uint;
- int_digits_end -= tmp_uint;
- frac_digits_head_end=int_digits_end+tmp_uint;
-@@ -2081,7 +2081,7 @@
- }
- else // (expo_sign_char=='+')
- {
-- tmp_uint=min(exponent,(uint)(frac_digits_end-frac_digits_from));
-+ tmp_uint=MYSQL_MIN(exponent,(uint)(frac_digits_end-frac_digits_from));
- int_digits_added_zeros=exponent-tmp_uint;
- int_digits_tail_from=frac_digits_from;
- frac_digits_from=frac_digits_from+tmp_uint;
-@@ -2506,7 +2506,7 @@
- {
- signed int overflow;
-
-- dec= min(dec, DECIMAL_MAX_SCALE);
-+ dec= MYSQL_MIN(dec, DECIMAL_MAX_SCALE);
-
- /*
- If the value still overflows the field with the corrected dec,
-@@ -2522,7 +2522,7 @@
- overflow= required_length - len;
-
- if (overflow > 0)
-- dec= max(0, dec - overflow); // too long, discard fract
-+ dec= MYSQL_MAX(0, dec - overflow); // too long, discard fract
- else
- /* Corrected value fits. */
- len= required_length;
-@@ -3092,7 +3092,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,5*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,5*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
-
-@@ -3304,7 +3304,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,7*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,7*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- short j;
-@@ -3521,7 +3521,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,10*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,10*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- long j= unsigned_flag ? (long) uint3korr(ptr) : sint3korr(ptr);
-@@ -3740,7 +3740,7 @@
- ASSERT_COLUMN_MARKED_FOR_READ;
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,12*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,12*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- int32 j;
-@@ -3981,7 +3981,7 @@
- {
- CHARSET_INFO *cs= &my_charset_bin;
- uint length;
-- uint mlength=max(field_length+1,22*cs->mbmaxlen);
-+ uint mlength=MYSQL_MAX(field_length+1,22*cs->mbmaxlen);
- val_buffer->alloc(mlength);
- char *to=(char*) val_buffer->ptr();
- longlong j;
-@@ -4204,7 +4204,7 @@
- #endif
- memcpy_fixed((uchar*) &nr,ptr,sizeof(nr));
-
-- uint to_length=max(field_length,70);
-+ uint to_length=MYSQL_MAX(field_length,70);
- val_buffer->alloc(to_length);
- char *to=(char*) val_buffer->ptr();
-
-@@ -6443,13 +6443,13 @@
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
-- digits= max(1, (int) max_length - fractional);
-+ digits= MYSQL_MAX(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
-- digits= max(1, (int) digits + exp);
-+ digits= MYSQL_MAX(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
-@@ -6457,7 +6457,7 @@
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
-- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-+ digits= MYSQL_MAX(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-@@ -6715,7 +6715,7 @@
- uint max_length,
- bool low_byte_first __attribute__((unused)))
- {
-- uint length= min(field_length,max_length);
-+ uint length= MYSQL_MIN(field_length,max_length);
- uint local_char_length= max_length/field_charset->mbmaxlen;
- if (length > local_char_length)
- local_char_length= my_charpos(field_charset, from, from+length,
-@@ -7709,7 +7709,7 @@
- from= tmpstr.ptr();
- }
-
-- new_length= min(max_data_length(), field_charset->mbmaxlen * length);
-+ new_length= MYSQL_MIN(max_data_length(), field_charset->mbmaxlen * length);
- if (value.alloc(new_length))
- goto oom_error;
-
-@@ -7869,7 +7869,7 @@
- b_length=get_length(b_ptr);
- if (b_length > max_length)
- b_length=max_length;
-- diff=memcmp(a,b,min(a_length,b_length));
-+ diff=memcmp(a,b,MYSQL_MIN(a_length,b_length));
- return diff ? diff : (int) (a_length - b_length);
- }
-
-@@ -8065,7 +8065,7 @@
- length given is smaller than the actual length of the blob, we
- just store the initial bytes of the blob.
- */
-- store_length(to, packlength, min(length, max_length), low_byte_first);
-+ store_length(to, packlength, MYSQL_MIN(length, max_length), low_byte_first);
-
- /*
- Store the actual blob data, which will occupy 'length' bytes.
-@@ -9112,7 +9112,7 @@
- {
- ASSERT_COLUMN_MARKED_FOR_READ;
- char buff[sizeof(longlong)];
-- uint length= min(pack_length(), sizeof(longlong));
-+ uint length= MYSQL_MIN(pack_length(), sizeof(longlong));
- ulonglong bits= val_int();
- mi_int8store(buff,bits);
-
-@@ -9198,7 +9198,7 @@
- *buff++= bits;
- length--;
- }
-- uint data_length = min(length, bytes_in_rec);
-+ uint data_length = MYSQL_MIN(length, bytes_in_rec);
- memcpy(buff, ptr, data_length);
- return data_length + 1;
- }
-@@ -9326,7 +9326,7 @@
- uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
- *to++= bits;
- }
-- length= min(bytes_in_rec, max_length - (bit_len > 0));
-+ length= MYSQL_MIN(bytes_in_rec, max_length - (bit_len > 0));
- memcpy(to, from, length);
- return to + length;
- }
-@@ -9783,7 +9783,7 @@
- DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
- if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
- length= ((length+1)/2)*2;
-- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
-+ length= MYSQL_MIN(length, MAX_DATETIME_COMPRESSED_WIDTH);
- }
- flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- /*
-diff -ur mysql-orig/sql/filesort.cc mysql/sql/filesort.cc
---- mysql-orig/sql/filesort.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/filesort.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -194,7 +194,7 @@
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-- records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
-+ records=MYSQL_MIN((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table->file->stats.records)+EXTRA_RECORDS;
- selected_records_file=0;
- }
-@@ -216,12 +216,12 @@
- goto err;
-
- memavl= thd->variables.sortbuff_size;
-- min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
-+ min_sort_memory= MYSQL_MAX(MIN_SORT_MEMORY, param.sort_length*MERGEBUFF2);
- while (memavl >= min_sort_memory)
- {
- ulong old_memavl;
- ulong keys= memavl/(param.rec_length+sizeof(char*));
-- param.keys=(uint) min(records+1, keys);
-+ param.keys=(uint) MYSQL_MIN(records+1, keys);
-
- if (table_sort.sort_keys &&
- table_sort.sort_keys_size != char_array_size(param.keys,
-@@ -1133,7 +1133,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= rec_length*count),buffpek->file_pos,MYF_RW))
-@@ -1396,7 +1396,7 @@
- != -1 && error != 0);
-
- end:
-- lastbuff->count= min(org_max_rows-max_rows, param->max_rows);
-+ lastbuff->count= MYSQL_MIN(org_max_rows-max_rows, param->max_rows);
- lastbuff->file_pos= to_start_filepos;
- err:
- delete_queue(&queue);
-diff -ur mysql-orig/sql/ha_ndbcluster.cc mysql/sql/ha_ndbcluster.cc
---- mysql-orig/sql/ha_ndbcluster.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/ha_ndbcluster.cc 2012-08-14 01:14:59.382197947 +0000
-@@ -799,7 +799,7 @@
-
- DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u",
- (long) blob_ptr, blob_len));
-- DBUG_DUMP("value", blob_ptr, min(blob_len, 26));
-+ DBUG_DUMP("value", blob_ptr, MYSQL_MIN(blob_len, 26));
-
- if (set_blob_value)
- *set_blob_value= TRUE;
-diff -ur mysql-orig/sql/handler.h mysql/sql/handler.h
---- mysql-orig/sql/handler.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/handler.h 2012-08-14 01:14:59.382197947 +0000
-@@ -1607,15 +1607,15 @@
- { return (HA_ERR_WRONG_COMMAND); }
-
- uint max_record_length() const
-- { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
-+ { return MYSQL_MIN(HA_MAX_REC_LENGTH, max_supported_record_length()); }
- uint max_keys() const
-- { return min(MAX_KEY, max_supported_keys()); }
-+ { return MYSQL_MIN(MAX_KEY, max_supported_keys()); }
- uint max_key_parts() const
-- { return min(MAX_REF_PARTS, max_supported_key_parts()); }
-+ { return MYSQL_MIN(MAX_REF_PARTS, max_supported_key_parts()); }
- uint max_key_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_length()); }
- uint max_key_part_length() const
-- { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-+ { return MYSQL_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); }
-
- virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
- virtual uint max_supported_keys() const { return 0; }
-diff -ur mysql-orig/sql/ha_partition.cc mysql/sql/ha_partition.cc
---- mysql-orig/sql/ha_partition.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/ha_partition.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -6138,7 +6138,7 @@
- {
- *first= bitmap_get_first_set(&(m_part_info->used_partitions));
- *num_used_parts= bitmap_bits_set(&(m_part_info->used_partitions));
-- *check_min_num= min(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
-+ *check_min_num= MYSQL_MIN(MAX_PARTS_FOR_OPTIMIZER_CALLS, *num_used_parts);
- }
-
-
-diff -ur mysql-orig/sql/item_buff.cc mysql/sql/item_buff.cc
---- mysql-orig/sql/item_buff.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_buff.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -61,7 +61,7 @@
-
- Cached_item_str::Cached_item_str(THD *thd, Item *arg)
- :item(arg),
-- value_max_length(min(arg->max_length, thd->variables.max_sort_length)),
-+ value_max_length(MYSQL_MIN(arg->max_length, thd->variables.max_sort_length)),
- value(value_max_length)
- {}
-
-@@ -71,7 +71,7 @@
- bool tmp;
-
- if ((res=item->val_str(&tmp_value)))
-- res->length(min(res->length(), value_max_length));
-+ res->length(MYSQL_MIN(res->length(), value_max_length));
- if (null_value != item->null_value)
- {
- if ((null_value= item->null_value))
-diff -ur mysql-orig/sql/item.cc mysql/sql/item.cc
---- mysql-orig/sql/item.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -76,7 +76,7 @@
- Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
- {
- item->decimals= arg->decimals;
-- item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
-+ item->max_length= MYSQL_MIN(arg->max_length + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_STR_LENGTH);
- }
-
-@@ -444,9 +444,9 @@
- {
- uint prec=
- my_decimal_length_to_precision(max_length, decimals, unsigned_flag);
-- return min(prec, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(prec, DECIMAL_MAX_PRECISION);
- }
-- return min(max_length, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_length, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -752,7 +752,7 @@
- &res_length);
- }
- else
-- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
-+ name= sql_strmake(str, (name_length= MYSQL_MIN(length,MAX_ALIAS_NAME)));
- }
-
-
-@@ -5417,7 +5417,7 @@
- // following assert is redundant, because fixed=1 assigned in constructor
- DBUG_ASSERT(fixed == 1);
- char *end=(char*) str_value.ptr()+str_value.length(),
-- *ptr=end-min(str_value.length(),sizeof(longlong));
-+ *ptr=end-MYSQL_MIN(str_value.length(),sizeof(longlong));
-
- ulonglong value=0;
- for (; ptr != end ; ptr++)
-@@ -5472,7 +5472,7 @@
- void Item_hex_string::print(String *str, enum_query_type query_type)
- {
- char *end= (char*) str_value.ptr() + str_value.length(),
-- *ptr= end - min(str_value.length(), sizeof(longlong));
-+ *ptr= end - MYSQL_MIN(str_value.length(), sizeof(longlong));
- str->append("0x");
- for (; ptr != end ; ptr++)
- {
-@@ -7554,14 +7554,14 @@
- /* fix variable decimals which always is NOT_FIXED_DEC */
- if (Field::result_merge_type(fld_type) == INT_RESULT)
- item_decimals= 0;
-- decimals= max(decimals, item_decimals);
-+ decimals= MYSQL_MAX(decimals, item_decimals);
- }
- if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
- {
-- decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(MYSQL_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
- int item_int_part= item->decimal_int_part();
-- int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
-- int precision= min(item_prec, DECIMAL_MAX_PRECISION);
-+ int item_prec = MYSQL_MAX(prev_decimal_int_part, item_int_part) + decimals;
-+ int precision= MYSQL_MIN(item_prec, DECIMAL_MAX_PRECISION);
- unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
-@@ -7592,7 +7592,7 @@
- */
- if (collation.collation != &my_charset_bin)
- {
-- max_length= max(old_max_chars * collation.collation->mbmaxlen,
-+ max_length= MYSQL_MAX(old_max_chars * collation.collation->mbmaxlen,
- display_length(item) /
- item->collation.collation->mbmaxlen *
- collation.collation->mbmaxlen);
-@@ -7614,7 +7614,7 @@
- {
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
-- max_length= max(delta1, delta2) + decimals;
-+ max_length= MYSQL_MAX(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= MAX_FLOAT_STR_LENGTH;
-@@ -7632,7 +7632,7 @@
- break;
- }
- default:
-- max_length= max(max_length, display_length(item));
-+ max_length= MYSQL_MAX(max_length, display_length(item));
- };
- maybe_null|= item->maybe_null;
- get_full_info(item);
-diff -ur mysql-orig/sql/item_cmpfunc.cc mysql/sql/item_cmpfunc.cc
---- mysql-orig/sql/item_cmpfunc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_cmpfunc.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -628,7 +628,7 @@
- {
- if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
- {
-- precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
-+ precision= 5 / log_10[MYSQL_MAX((*a)->decimals, (*b)->decimals) + 1];
- if (func == &Arg_comparator::compare_real)
- func= &Arg_comparator::compare_real_fixed;
- else if (func == &Arg_comparator::compare_e_real)
-@@ -1315,7 +1315,7 @@
- owner->null_value= 0;
- uint res1_length= res1->length();
- uint res2_length= res2->length();
-- int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length));
-+ int cmp= memcmp(res1->ptr(), res2->ptr(), MYSQL_MIN(res1_length,res2_length));
- return cmp ? cmp : (int) (res1_length - res2_length);
- }
- }
-@@ -2447,7 +2447,7 @@
- {
- agg_result_type(&hybrid_type, args, 2);
- maybe_null=args[1]->maybe_null;
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag;
-
- if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT)
-@@ -2458,10 +2458,10 @@
- int len1= args[1]->max_length - args[1]->decimals
- - (args[1]->unsigned_flag ? 0 : 1);
-
-- max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length= MYSQL_MAX(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
-
- switch (hybrid_type) {
- case STRING_RESULT:
-@@ -2485,9 +2485,9 @@
- {
- int arg0_int_part= args[0]->decimal_int_part();
- int arg1_int_part= args[1]->decimal_int_part();
-- int max_int_part= max(arg0_int_part, arg1_int_part);
-+ int max_int_part= MYSQL_MAX(arg0_int_part, arg1_int_part);
- int precision= max_int_part + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -2615,7 +2615,7 @@
- Item_func_if::fix_length_and_dec()
- {
- maybe_null=args[1]->maybe_null || args[2]->maybe_null;
-- decimals= max(args[1]->decimals, args[2]->decimals);
-+ decimals= MYSQL_MAX(args[1]->decimals, args[2]->decimals);
- unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag;
-
- enum Item_result arg1_type=args[1]->result_type();
-@@ -2659,10 +2659,10 @@
- int len2= args[2]->max_length - args[2]->decimals
- - (args[2]->unsigned_flag ? 0 : 1);
-
-- max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
-+ max_length=MYSQL_MAX(len1, len2) + decimals + (unsigned_flag ? 0 : 1);
- }
- else
-- max_length= max(args[1]->max_length, args[2]->max_length);
-+ max_length= MYSQL_MAX(args[1]->max_length, args[2]->max_length);
- }
-
-
-@@ -2670,8 +2670,8 @@
- {
- int arg1_prec= args[1]->decimal_int_part();
- int arg2_prec= args[2]->decimal_int_part();
-- int precision=max(arg1_prec,arg2_prec) + decimals;
-- return min(precision, DECIMAL_MAX_PRECISION);
-+ int precision=MYSQL_MAX(arg1_prec,arg2_prec) + decimals;
-+ return MYSQL_MIN(precision, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -3081,7 +3081,7 @@
-
- if (else_expr_num != -1)
- set_if_bigger(max_int_part, args[else_expr_num]->decimal_int_part());
-- return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ return MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- }
-
-
-@@ -4979,7 +4979,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
- g--;
-@@ -4998,7 +4998,7 @@
- else
- {
- if (i < g)
-- g = i; // g = min(i, g)
-+ g = i; // g = MYSQL_MIN(i, g)
- f = i;
- while (g >= 0 &&
- likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
-@@ -5119,14 +5119,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-@@ -5150,14 +5150,14 @@
- register const int v = plm1 - i;
- turboShift = u - v;
- bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
-- shift = max(turboShift, bcShift);
-- shift = max(shift, bmGs[i]);
-+ shift = MYSQL_MAX(turboShift, bcShift);
-+ shift = MYSQL_MAX(shift, bmGs[i]);
- if (shift == bmGs[i])
-- u = min(pattern_len - shift, v);
-+ u = MYSQL_MIN(pattern_len - shift, v);
- else
- {
- if (turboShift < bcShift)
-- shift = max(shift, u + 1);
-+ shift = MYSQL_MAX(shift, u + 1);
- u = 0;
- }
- j+= shift;
-diff -ur mysql-orig/sql/item_func.cc mysql/sql/item_func.cc
---- mysql-orig/sql/item_func.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_func.cc 2012-08-14 01:14:59.392197867 +0000
-@@ -549,7 +549,7 @@
- set_if_bigger(max_int_part, args[i]->decimal_int_part());
- set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
- }
-- int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-+ int precision= MYSQL_MIN(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1143,10 +1143,10 @@
- */
- void Item_func_additive_op::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
- int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
- int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
-- int precision= max(arg1_int, arg2_int) + 1 + decimals;
-+ int precision= MYSQL_MAX(arg1_int, arg2_int) + 1 + decimals;
-
- /* Integer operations keep unsigned_flag if one of arguments is unsigned */
- if (result_type() == INT_RESULT)
-@@ -1256,9 +1256,9 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
- uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
-- uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
-+ uint precision= MYSQL_MIN(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1306,7 +1306,7 @@
-
- void Item_func_div::result_precision()
- {
-- uint precision=min(args[0]->decimal_precision() +
-+ uint precision=MYSQL_MIN(args[0]->decimal_precision() +
- args[1]->decimals + prec_increment,
- DECIMAL_MAX_PRECISION);
-
-@@ -1315,7 +1315,7 @@
- unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
- else
- unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
- unsigned_flag);
- }
-@@ -1329,7 +1329,7 @@
- switch(hybrid_type) {
- case REAL_RESULT:
- {
-- decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
-+ decimals=MYSQL_MAX(args[0]->decimals,args[1]->decimals)+prec_increment;
- set_if_smaller(decimals, NOT_FIXED_DEC);
- uint tmp=float_length(decimals);
- if (decimals == NOT_FIXED_DEC)
-@@ -1460,8 +1460,8 @@
-
- void Item_func_mod::result_precision()
- {
-- decimals= max(args[0]->decimals, args[1]->decimals);
-- max_length= max(args[0]->max_length, args[1]->max_length);
-+ decimals= MYSQL_MAX(args[0]->decimals, args[1]->decimals);
-+ max_length= MYSQL_MAX(args[0]->max_length, args[1]->max_length);
- }
-
-
-@@ -1983,7 +1983,7 @@
-
- if (args[0]->decimals == NOT_FIXED_DEC)
- {
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- hybrid_type= REAL_RESULT;
- return;
-@@ -1993,7 +1993,7 @@
- case REAL_RESULT:
- case STRING_RESULT:
- hybrid_type= REAL_RESULT;
-- decimals= min(decimals_to_set, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals_to_set, NOT_FIXED_DEC);
- max_length= float_length(decimals);
- break;
- case INT_RESULT:
-@@ -2010,13 +2010,13 @@
- case DECIMAL_RESULT:
- {
- hybrid_type= DECIMAL_RESULT;
-- decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
-+ decimals_to_set= MYSQL_MIN(DECIMAL_MAX_SCALE, decimals_to_set);
- int decimals_delta= args[0]->decimals - decimals_to_set;
- int precision= args[0]->decimal_precision();
- int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
-
- precision-= decimals_delta - length_increase;
-- decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -2117,7 +2117,7 @@
- my_decimal val, *value= args[0]->val_decimal(&val);
- longlong dec= args[1]->val_int();
- if (dec >= 0 || args[1]->unsigned_flag)
-- dec= min((ulonglong) dec, decimals);
-+ dec= MYSQL_MIN((ulonglong) dec, decimals);
- else if (dec < INT_MIN)
- dec= INT_MIN;
-
-@@ -2989,7 +2989,7 @@
- free_udf(u_d);
- DBUG_RETURN(TRUE);
- }
-- func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
-+ func->max_length=MYSQL_MIN(initid.max_length,MAX_BLOB_WIDTH);
- func->maybe_null=initid.maybe_null;
- const_item_cache=initid.const_item;
- /*
-@@ -2998,7 +2998,7 @@
- */
- if (!const_item_cache && !used_tables_cache)
- used_tables_cache= RAND_TABLE_BIT;
-- func->decimals=min(initid.decimals,NOT_FIXED_DEC);
-+ func->decimals=MYSQL_MIN(initid.decimals,NOT_FIXED_DEC);
- }
- initialized=1;
- if (error)
-diff -ur mysql-orig/sql/item_func.h mysql/sql/item_func.h
---- mysql-orig/sql/item_func.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_func.h 2012-08-14 01:14:59.402197785 +0000
-@@ -421,6 +421,6 @@
- const char *func_name() const { return "cast_as_unsigned"; }
- void fix_length_and_dec()
- {
-- max_length= min(args[0]->max_length,MY_INT64_NUM_DECIMAL_DIGITS);
-+ max_length= MYSQL_MIN(args[0]->max_length,MY_INT64_NUM_DECIMAL_DIGITS);
- }
- longlong val_int();
-diff -ur mysql-orig/sql/item_strfunc.cc mysql/sql/item_strfunc.cc
---- mysql-orig/sql/item_strfunc.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_strfunc.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -389,7 +389,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -750,7 +750,7 @@
- }
- else
- {
-- uint new_len = max(tmp_value.alloced_length() * 2, concat_len);
-+ uint new_len = MYSQL_MAX(tmp_value.alloced_length() * 2, concat_len);
-
- if (tmp_value.realloc(new_len))
- goto null;
-@@ -1251,7 +1251,7 @@
-
- length= res->charpos((int) length, (uint32) start);
- tmp_length= res->length() - start;
-- length= min(length, tmp_length);
-+ length= MYSQL_MIN(length, tmp_length);
-
- if (!start && (longlong) res->length() == length)
- return res;
-@@ -1271,7 +1271,7 @@
- if (start < 0)
- max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
- else
-- max_length-= min((uint)(start - 1), max_length);
-+ max_length-= MYSQL_MIN((uint)(start - 1), max_length);
- }
- if (arg_count == 3 && args[2]->const_item())
- {
-@@ -1962,7 +1962,7 @@
- if ((null_value= args[0]->null_value))
- return 0; /* purecov: inspected */
-
-- if (tmp_value.alloc(max(res->length(), 4 * cs->mbminlen)))
-+ if (tmp_value.alloc(MYSQL_MAX(res->length(), 4 * cs->mbminlen)))
- return str; /* purecov: inspected */
- char *to= (char *) tmp_value.ptr();
- char *to_end= to + tmp_value.alloced_length();
-@@ -3114,11 +3114,11 @@
-
- void Item_func_export_set::fix_length_and_dec()
- {
-- uint length=max(args[1]->max_length,args[2]->max_length);
-+ uint length=MYSQL_MAX(args[1]->max_length,args[2]->max_length);
- uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
- max_length=length*64+sep_length*63;
-
-- if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
-+ if (agg_arg_charsets(collation, args+1, MYSQL_MIN(4,arg_count)-1,
- MY_COLL_ALLOW_CONV, 1))
- return;
- }
-@@ -3582,7 +3582,7 @@
- /*
- -1 so we won't make tv= uuid_time for nanoseq >= (tv - uuid_time)
- */
-- ulong delta= min(nanoseq, (ulong) (tv - uuid_time -1));
-+ ulong delta= MYSQL_MIN(nanoseq, (ulong) (tv - uuid_time -1));
- tv-= delta;
- nanoseq-= delta;
- }
-diff -ur mysql-orig/sql/item_strfunc.h mysql/sql/item_strfunc.h
---- mysql-orig/sql/item_strfunc.h 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_strfunc.h 2012-08-14 01:14:59.402197785 +0000
-@@ -709,7 +709,7 @@
- collation.set(args[0]->collation);
- ulonglong max_result_length= (ulonglong) args[0]->max_length * 2 +
- 2 * collation.collation->mbmaxlen;
-- max_length= (uint32) min(max_result_length, MAX_BLOB_WIDTH);
-+ max_length= (uint32) MYSQL_MIN(max_result_length, MAX_BLOB_WIDTH);
- }
- };
-
-diff -ur mysql-orig/sql/item_sum.cc mysql/sql/item_sum.cc
---- mysql-orig/sql/item_sum.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/item_sum.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -1139,7 +1139,7 @@
- AVG() will divide val by count. We need to reserve digits
- after decimal point as the result can be fractional.
- */
-- decimals= min(decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(decimals + prec_increment, NOT_FIXED_DEC);
- }
-
-
-@@ -1202,16 +1202,16 @@
- if (hybrid_type == DECIMAL_RESULT)
- {
- int precision= args[0]->decimal_precision() + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-- f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
-+ f_precision= MYSQL_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
- f_scale= args[0]->decimals;
- dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
- }
- else {
-- decimals= min(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, NOT_FIXED_DEC);
- max_length= args[0]->max_length + prec_increment;
- }
- }
-@@ -1402,13 +1402,13 @@
- switch (args[0]->result_type()) {
- case REAL_RESULT:
- case STRING_RESULT:
-- decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
-+ decimals= MYSQL_MIN(args[0]->decimals + 4, NOT_FIXED_DEC);
- break;
- case INT_RESULT:
- case DECIMAL_RESULT:
- {
- int precision= args[0]->decimal_precision()*2 + prec_increment;
-- decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
-+ decimals= MYSQL_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length_no_truncation(precision,
- decimals,
- unsigned_flag);
-@@ -3345,7 +3345,7 @@
- syntax of this function). If there is no ORDER BY clause, we don't
- create this tree.
- */
-- init_tree(tree, (uint) min(thd->variables.max_heap_table_size,
-+ init_tree(tree, (uint) MYSQL_MIN(thd->variables.max_heap_table_size,
- thd->variables.sortbuff_size/16), 0,
- tree_key_length,
- group_concat_key_cmp_with_order , 0, NULL, (void*) this);
-diff -ur mysql-orig/sql/item_timefunc.cc mysql/sql/item_timefunc.cc
---- mysql-orig/sql/item_timefunc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/item_timefunc.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -310,14 +310,14 @@
- switch (*++ptr) {
- /* Year */
- case 'Y':
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- if ((int) (tmp-val) <= 2)
- l_time->year= year_2000_handling(l_time->year);
- val= tmp;
- break;
- case 'y':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- l_time->year= year_2000_handling(l_time->year);
-@@ -326,7 +326,7 @@
- /* Month */
- case 'm':
- case 'c':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->month= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -343,15 +343,15 @@
- /* Day */
- case 'd':
- case 'e':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
- case 'D':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->day= (int) my_strtoll10(val, &tmp, &error);
- /* Skip 'st, 'nd, 'th .. */
-- val= tmp + min((int) (val_end-tmp), 2);
-+ val= tmp + MYSQL_MIN((int) (val_end-tmp), 2);
- break;
-
- /* Hour */
-@@ -362,14 +362,14 @@
- /* fall through */
- case 'k':
- case 'H':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->hour= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-
- /* Minute */
- case 'i':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->minute= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -377,7 +377,7 @@
- /* Second */
- case 's':
- case 'S':
-- tmp= (char*) val + min(2, val_len);
-+ tmp= (char*) val + MYSQL_MIN(2, val_len);
- l_time->second= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -429,7 +429,7 @@
- val= tmp;
- break;
- case 'j':
-- tmp= (char*) val + min(val_len, 3);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 3);
- yearday= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -441,7 +441,7 @@
- case 'u':
- sunday_first_n_first_week_non_iso= (*ptr=='U' || *ptr== 'V');
- strict_week_number= (*ptr=='V' || *ptr=='v');
-- tmp= (char*) val + min(val_len, 2);
-+ tmp= (char*) val + MYSQL_MIN(val_len, 2);
- if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 ||
- (strict_week_number && !week_number) ||
- week_number > 53)
-@@ -453,7 +453,7 @@
- case 'X':
- case 'x':
- strict_week_number_year_type= (*ptr=='X');
-- tmp= (char*) val + min(4, val_len);
-+ tmp= (char*) val + MYSQL_MIN(4, val_len);
- strict_week_number_year= (int) my_strtoll10(val, &tmp, &error);
- val= tmp;
- break;
-@@ -598,7 +598,7 @@
- err:
- {
- char buff[128];
-- strmake(buff, val_begin, min(length, sizeof(buff)-1));
-+ strmake(buff, val_begin, MYSQL_MIN(length, sizeof(buff)-1));
- push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
- ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
- date_time_type, buff, "str_to_date");
-@@ -1830,7 +1830,7 @@
- else
- {
- fixed_length=0;
-- max_length=min(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
-+ max_length=MYSQL_MIN(arg1->max_length, MAX_BLOB_WIDTH) * 10 *
- collation.collation->mbmaxlen;
- set_if_smaller(max_length,MAX_BLOB_WIDTH);
- }
-diff -ur mysql-orig/sql/key.cc mysql/sql/key.cc
---- mysql-orig/sql/key.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/key.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -128,13 +128,13 @@
- key_part->key_part_flag & HA_VAR_LENGTH_PART)
- {
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
- to_key+= HA_KEY_BLOB_LENGTH;
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- Field *field= key_part->field;
- CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
-@@ -218,7 +218,7 @@
- my_ptrdiff_t ptrdiff= to_record - field->table->record[0];
- field->move_field_offset(ptrdiff);
- key_length-= HA_KEY_BLOB_LENGTH;
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
- field->set_key_image(from_key, length);
- dbug_tmp_restore_column_map(field->table->write_set, old_map);
-@@ -227,7 +227,7 @@
- }
- else
- {
-- length= min(key_length, key_part->length);
-+ length= MYSQL_MIN(key_length, key_part->length);
- /* skip the byte with 'uneven' bits, if used */
- memcpy(to_record + key_part->offset, from_key + used_uneven_bits
- , (size_t) length - used_uneven_bits);
-@@ -288,7 +288,7 @@
- return 1;
- continue;
- }
-- length= min((uint) (key_end-key), store_length);
-+ length= MYSQL_MIN((uint) (key_end-key), store_length);
- if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
- FIELDFLAG_PACK)))
- {
-@@ -354,7 +354,7 @@
- {
- field->val_str(&tmp);
- if (key_part->length < field->pack_length())
-- tmp.length(min(tmp.length(),key_part->length));
-+ tmp.length(MYSQL_MIN(tmp.length(),key_part->length));
- to->append(tmp);
- }
- else
-diff -ur mysql-orig/sql/log.cc mysql/sql/log.cc
---- mysql-orig/sql/log.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/log.cc 2012-08-14 01:14:59.402197785 +0000
-@@ -597,11 +597,11 @@
- t.neg= 0;
-
- /* fill in query_time field */
-- calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* lock_time */
-- calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-+ calc_time_from_sec(&t, (long) MYSQL_MIN(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
- if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
- goto err;
- /* rows_sent */
-@@ -2432,7 +2432,7 @@
- {
- char *p= fn_ext(log_name);
- uint length= (uint) (p - log_name);
-- strmake(buff, log_name, min(length, FN_REFLEN-1));
-+ strmake(buff, log_name, MYSQL_MIN(length, FN_REFLEN-1));
- return (const char*)buff;
- }
- return log_name;
-@@ -5238,7 +5238,7 @@
- DBUG_ENTER("print_buffer_to_nt_eventlog");
-
- /* Add ending CR/LF's to string, overwrite last chars if necessary */
-- strmov(buffptr+min(length, buffLen-5), "\r\n\r\n");
-+ strmov(buffptr+MYSQL_MIN(length, buffLen-5), "\r\n\r\n");
-
- setup_windows_event_source();
- if ((event= RegisterEventSource(NULL,"MySQL")))
-diff -ur mysql-orig/sql/log_event.cc mysql/sql/log_event.cc
---- mysql-orig/sql/log_event.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/log_event.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -1099,7 +1099,7 @@
- of 13 bytes, whereas LOG_EVENT_MINIMAL_HEADER_LEN is 19 bytes (it's
- "minimal" over the set {MySQL >=4.0}).
- */
-- uint header_size= min(description_event->common_header_len,
-+ uint header_size= MYSQL_MIN(description_event->common_header_len,
- LOG_EVENT_MINIMAL_HEADER_LEN);
-
- LOCK_MUTEX;
-@@ -2695,7 +2695,7 @@
- be even bigger, but this will suffice to catch most corruption
- errors that can lead to a crash.
- */
-- if (status_vars_len > min(data_len, MAX_SIZE_LOG_EVENT_STATUS))
-+ if (status_vars_len > MYSQL_MIN(data_len, MAX_SIZE_LOG_EVENT_STATUS))
- {
- DBUG_PRINT("info", ("status_vars_len (%u) > data_len (%lu); query= 0",
- status_vars_len, data_len));
-@@ -5676,7 +5676,7 @@
- char buf[UV_NAME_LEN_SIZE];
- char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE +
- UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE];
-- uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
-+ uchar buf2[MYSQL_MAX(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2;
- uint buf1_length;
- ulong event_length;
-
-@@ -7426,7 +7426,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -ur mysql-orig/sql/log_event_old.cc mysql/sql/log_event_old.cc
---- mysql-orig/sql/log_event_old.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/log_event_old.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -1434,7 +1434,7 @@
- trigger false warnings.
- */
- #ifndef HAVE_purify
-- DBUG_DUMP("row_data", row_data, min(length, 32));
-+ DBUG_DUMP("row_data", row_data, MYSQL_MIN(length, 32));
- #endif
-
- DBUG_ASSERT(m_rows_buf <= m_rows_cur);
-diff -ur mysql-orig/sql/mysqld.cc mysql/sql/mysqld.cc
---- mysql-orig/sql/mysqld.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/mysqld.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -3241,7 +3241,7 @@
- can't get max_connections*5 but still got no less than was
- requested (value of wanted_files).
- */
-- max_open_files= max(max(wanted_files, max_connections*5),
-+ max_open_files= MYSQL_MAX(MYSQL_MAX(wanted_files, max_connections*5),
- open_files_limit);
- files= my_set_max_open_files(max_open_files);
-
-@@ -3253,15 +3253,15 @@
- If we have requested too much file handles than we bring
- max_connections in supported bounds.
- */
-- max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
-+ max_connections= (ulong) MYSQL_MIN(files-10-TABLE_OPEN_CACHE_MIN*2,
- max_connections);
- /*
- Decrease table_cache_size according to max_connections, but
-- not below TABLE_OPEN_CACHE_MIN. Outer min() ensures that we
-+ not below TABLE_OPEN_CACHE_MIN. Outer MYSQL_MIN() ensures that we
- never increase table_cache_size automatically (that could
- happen if max_connections is decreased above).
- */
-- table_cache_size= (ulong) min(max((files-10-max_connections)/2,
-+ table_cache_size= (ulong) MYSQL_MIN(MYSQL_MAX((files-10-max_connections)/2,
- TABLE_OPEN_CACHE_MIN),
- table_cache_size);
- DBUG_PRINT("warning",
-@@ -4947,7 +4947,7 @@
- {
- my_socket sock,new_sock;
- uint error_count=0;
-- uint max_used_connection= (uint) (max(ip_sock,unix_sock)+1);
-+ uint max_used_connection= (uint) (MYSQL_MAX(ip_sock,unix_sock)+1);
- fd_set readFDs,clientFDs;
- THD *thd;
- struct sockaddr_in cAddr;
-diff -ur mysql-orig/sql/net_serv.cc mysql/sql/net_serv.cc
---- mysql-orig/sql/net_serv.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/net_serv.cc 2012-08-14 01:14:59.412197702 +0000
-@@ -755,7 +755,7 @@
- {
- while (remain > 0)
- {
-- size_t length= min(remain, net->max_packet);
-+ size_t length= MYSQL_MIN(remain, net->max_packet);
- if (net_safe_read(net, net->buff, length, alarmed))
- DBUG_RETURN(1);
- update_statistics(thd_increment_bytes_received(length));
-@@ -946,7 +946,7 @@
- len=uint3korr(net->buff+net->where_b);
- if (!len) /* End of big multi-packet */
- goto end;
-- helping = max(len,*complen) + net->where_b;
-+ helping = MYSQL_MAX(len,*complen) + net->where_b;
- /* The necessary size of net->buff */
- if (helping >= net->max_packet)
- {
-diff -ur mysql-orig/sql/opt_range.cc mysql/sql/opt_range.cc
---- mysql-orig/sql/opt_range.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/opt_range.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -2347,7 +2347,7 @@
- group_trp= get_best_group_min_max(&param, tree);
- if (group_trp)
- {
-- param.table->quick_condition_rows= min(group_trp->records,
-+ param.table->quick_condition_rows= MYSQL_MIN(group_trp->records,
- head->file->stats.records);
- if (group_trp->read_cost < best_read_time)
- {
-@@ -3823,7 +3823,7 @@
- {
- imerge_trp->read_cost= imerge_cost;
- imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
-- imerge_trp->records= min(imerge_trp->records,
-+ imerge_trp->records= MYSQL_MIN(imerge_trp->records,
- param->table->file->stats.records);
- imerge_trp->range_scans= range_scans;
- imerge_trp->range_scans_end= range_scans + n_child_scans;
-@@ -7471,7 +7471,7 @@
- param->table->quick_key_parts[key]=param->max_key_part+1;
- param->table->quick_n_ranges[key]= param->n_ranges;
- param->table->quick_condition_rows=
-- min(param->table->quick_condition_rows, records);
-+ MYSQL_MIN(param->table->quick_condition_rows, records);
- }
- /*
- Need to save quick_rows in any case as it is used when calculating
-@@ -7540,7 +7540,7 @@
- uchar *tmp_min_key, *tmp_max_key;
- uint8 save_first_null_comp= param->first_null_comp;
-
-- param->max_key_part=max(param->max_key_part,key_tree->part);
-+ param->max_key_part=MYSQL_MAX(param->max_key_part,key_tree->part);
- if (key_tree->left != &null_element)
- {
- /*
-@@ -8462,13 +8462,13 @@
- /* Do not allocate the buffers twice. */
- if (multi_range_length)
- {
-- DBUG_ASSERT(multi_range_length == min(multi_range_count, ranges.elements));
-+ DBUG_ASSERT(multi_range_length == MYSQL_MIN(multi_range_count, ranges.elements));
- DBUG_RETURN(0);
- }
-
- /* Allocate the ranges array. */
- DBUG_ASSERT(ranges.elements);
-- multi_range_length= min(multi_range_count, ranges.elements);
-+ multi_range_length= MYSQL_MIN(multi_range_count, ranges.elements);
- DBUG_ASSERT(multi_range_length > 0);
- while (multi_range_length && ! (multi_range= (KEY_MULTI_RANGE*)
- my_malloc(multi_range_length *
-@@ -8487,7 +8487,7 @@
- /* Allocate the handler buffer if necessary. */
- if (file->ha_table_flags() & HA_NEED_READ_RANGE_BUFFER)
- {
-- mrange_bufsiz= min(multi_range_bufsiz,
-+ mrange_bufsiz= MYSQL_MIN(multi_range_bufsiz,
- ((uint)QUICK_SELECT_I::records + 1)* head->s->reclength);
-
- while (mrange_bufsiz &&
-@@ -8568,7 +8568,7 @@
- goto end;
- }
-
-- uint count= min(multi_range_length, ranges.elements -
-+ uint count= MYSQL_MIN(multi_range_length, ranges.elements -
- (cur_range - (QUICK_RANGE**) ranges.buffer));
- if (count == 0)
- {
-@@ -9270,7 +9270,7 @@
-
- TODO
- - What happens if the query groups by the MIN/MAX field, and there is no
-- other field as in: "select min(a) from t1 group by a" ?
-+ other field as in: "select MYSQL_MIN(a) from t1 group by a" ?
- - We assume that the general correctness of the GROUP-BY query was checked
- before this point. Is this correct, or do we have to check it completely?
- - Lift the limitation in condition (B3), that is, make this access method
-@@ -9496,7 +9496,7 @@
- cur_group_prefix_len+= cur_part->store_length;
- used_key_parts_map.set_bit(key_part_nr);
- ++cur_group_key_parts;
-- max_key_part= max(max_key_part,key_part_nr);
-+ max_key_part= MYSQL_MAX(max_key_part,key_part_nr);
- }
- /*
- Check that used key parts forms a prefix of the index.
-@@ -10132,9 +10132,9 @@
- {
- double blocks_per_group= (double) num_blocks / (double) num_groups;
- p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
-- p_overlap= min(p_overlap, 1.0);
-+ p_overlap= MYSQL_MIN(p_overlap, 1.0);
- }
-- io_cost= (double) min(num_groups * (1 + p_overlap), num_blocks);
-+ io_cost= (double) MYSQL_MIN(num_groups * (1 + p_overlap), num_blocks);
- }
- else
- io_cost= (keys_per_group > keys_per_block) ?
-diff -ur mysql-orig/sql/opt_range.h mysql/sql/opt_range.h
---- mysql-orig/sql/opt_range.h 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/opt_range.h 2012-08-14 01:14:59.422197616 +0000
-@@ -85,7 +85,7 @@
- void make_min_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_min_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-@@ -123,7 +123,7 @@
- void make_max_endpoint(key_range *kr, uint prefix_length,
- key_part_map keypart_map) {
- make_max_endpoint(kr);
-- kr->length= min(kr->length, prefix_length);
-+ kr->length= MYSQL_MIN(kr->length, prefix_length);
- kr->keypart_map&= keypart_map;
- }
-
-diff -ur mysql-orig/sql/protocol.cc mysql/sql/protocol.cc
---- mysql-orig/sql/protocol.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/protocol.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -168,7 +168,7 @@
- pos+=2;
-
- /* We can only return up to 65535 warnings in two bytes */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- int2store(pos, tmp);
- pos+= 2;
- }
-@@ -263,7 +263,7 @@
- Don't send warn count during SP execution, as the warn_list
- is cleared between substatements, and mysqltest gets confused
- */
-- uint tmp= min(total_warn_count, 65535);
-+ uint tmp= MYSQL_MIN(total_warn_count, 65535);
- buff[0]= 254;
- int2store(buff+1, tmp);
- /*
-diff -ur mysql-orig/sql/rpl_record.cc mysql/sql/rpl_record.cc
---- mysql-orig/sql/rpl_record.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/rpl_record.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -287,7 +287,7 @@
- /*
- throw away master's extra fields
- */
-- uint max_cols= min(tabledef->size(), cols->n_bits);
-+ uint max_cols= MYSQL_MIN(tabledef->size(), cols->n_bits);
- for (; i < max_cols; i++)
- {
- if (bitmap_is_set(cols, i))
-diff -ur mysql-orig/sql/rpl_rli.cc mysql/sql/rpl_rli.cc
---- mysql-orig/sql/rpl_rli.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_rli.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -690,7 +690,7 @@
- ulong log_name_extension;
- char log_name_tmp[FN_REFLEN]; //make a char[] from String
-
-- strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1));
-+ strmake(log_name_tmp, log_name->ptr(), MYSQL_MIN(log_name->length(), FN_REFLEN-1));
-
- char *p= fn_ext(log_name_tmp);
- char *p_end;
-@@ -700,7 +700,7 @@
- goto err;
- }
- // Convert 0-3 to 4
-- log_pos= max(log_pos, BIN_LOG_HEADER_SIZE);
-+ log_pos= MYSQL_MAX(log_pos, BIN_LOG_HEADER_SIZE);
- /* p points to '.' */
- log_name_extension= strtoul(++p, &p_end, 10);
- /*
-diff -ur mysql-orig/sql/rpl_utility.cc mysql/sql/rpl_utility.cc
---- mysql-orig/sql/rpl_utility.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_utility.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -182,7 +182,7 @@
- /*
- We only check the initial columns for the tables.
- */
-- uint const cols_to_check= min(table->s->fields, size());
-+ uint const cols_to_check= MYSQL_MIN(table->s->fields, size());
- int error= 0;
- Relay_log_info const *rli= const_cast<Relay_log_info*>(rli_arg);
-
-diff -ur mysql-orig/sql/rpl_utility.h mysql/sql/rpl_utility.h
---- mysql-orig/sql/rpl_utility.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/rpl_utility.h 2012-08-14 01:14:59.422197616 +0000
-@@ -315,7 +315,7 @@
- do { \
- char buf[256]; \
- uint i; \
-- for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
-+ for (i = 0 ; i < MYSQL_MIN(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
- buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[i] = '\0'; \
- DBUG_PRINT((N), ((FRM), buf)); \
-diff -ur mysql-orig/sql/set_var.cc mysql/sql/set_var.cc
---- mysql-orig/sql/set_var.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/set_var.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -1849,7 +1849,7 @@
- &not_used));
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- }
-@@ -4034,7 +4034,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- goto err;
- }
- return FALSE;
-diff -ur mysql-orig/sql/slave.cc mysql/sql/slave.cc
---- mysql-orig/sql/slave.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/slave.cc 2012-08-14 01:14:59.422197616 +0000
-@@ -1791,7 +1791,7 @@
- special marker to say "consider we have caught up".
- */
- protocol->store((longlong)(mi->rli.last_master_timestamp ?
-- max(0, time_diff) : 0));
-+ MYSQL_MAX(0, time_diff) : 0));
- }
- else
- {
-@@ -2408,7 +2408,7 @@
- exec_res= 0;
- rli->cleanup_context(thd, 1);
- /* chance for concurrent connection to get more locks */
-- safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
-+ safe_sleep(thd, MYSQL_MIN(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE),
- (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli);
- pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS
- rli->trans_retries++;
-@@ -4112,7 +4112,7 @@
- relay_log_pos Current log pos
- pending Number of bytes already processed from the event
- */
-- rli->event_relay_log_pos= max(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
-+ rli->event_relay_log_pos= MYSQL_MAX(rli->event_relay_log_pos, BIN_LOG_HEADER_SIZE);
- my_b_seek(cur_log,rli->event_relay_log_pos);
- DBUG_RETURN(cur_log);
- }
-diff -ur mysql-orig/sql/spatial.h mysql/sql/spatial.h
---- mysql-orig/sql/spatial.h 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/spatial.h 2012-08-14 01:14:59.432197532 +0000
-@@ -182,8 +182,8 @@
- if (d != mbr->dimension() || d <= 0 || contains(mbr) || within(mbr))
- return 0;
-
-- MBR intersection(max(xmin, mbr->xmin), max(ymin, mbr->ymin),
-- min(xmax, mbr->xmax), min(ymax, mbr->ymax));
-+ MBR intersection(MYSQL_MAX(xmin, mbr->xmin), MYSQL_MAX(ymin, mbr->ymin),
-+ MYSQL_MIN(xmax, mbr->xmax), MYSQL_MIN(ymax, mbr->ymax));
-
- return (d == intersection.dimension());
- }
-diff -ur mysql-orig/sql/sp_head.cc mysql/sql/sp_head.cc
---- mysql-orig/sql/sp_head.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sp_head.cc 2012-08-14 01:14:59.432197532 +0000
-@@ -2481,7 +2481,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string(col3_caption,
-- max(m_defstr.length, 1024));
-+ MYSQL_MAX(m_defstr.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-@@ -2682,7 +2682,7 @@
- field_list.push_back(new Item_uint("Pos", 9));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Instruction",
-- max(buffer.length(), 1024)));
-+ MYSQL_MAX(buffer.length(), 1024)));
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS |
- Protocol::SEND_EOF))
- DBUG_RETURN(1);
-diff -ur mysql-orig/sql/sql_acl.cc mysql/sql/sql_acl.cc
---- mysql-orig/sql/sql_acl.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_acl.cc 2012-08-14 01:14:59.432197532 +0000
-@@ -824,7 +824,7 @@
- chars= 128; // Marker that chars existed
- }
- }
-- sort= (sort << 8) + (wild_pos ? min(wild_pos, 127) : chars);
-+ sort= (sort << 8) + (wild_pos ? MYSQL_MIN(wild_pos, 127) : chars);
- }
- va_end(args);
- return sort;
-diff -ur mysql-orig/sql/sql_analyse.cc mysql/sql/sql_analyse.cc
---- mysql-orig/sql/sql_analyse.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_analyse.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -282,16 +282,16 @@
- {
- if (((longlong) info->ullval) < 0)
- return 0; // Impossible to store as a negative number
-- ev_info->llval = -(longlong) max((ulonglong) -ev_info->llval,
-+ ev_info->llval = -(longlong) MYSQL_MAX((ulonglong) -ev_info->llval,
- info->ullval);
-- ev_info->min_dval = (double) -max(-ev_info->min_dval, info->dval);
-+ ev_info->min_dval = (double) -MYSQL_MAX(-ev_info->min_dval, info->dval);
- }
- else // ulonglong is as big as bigint in MySQL
- {
- if ((check_ulonglong(num, info->integers) == DECIMAL_NUM))
- return 0;
-- ev_info->ullval = (ulonglong) max(ev_info->ullval, info->ullval);
-- ev_info->max_dval = (double) max(ev_info->max_dval, info->dval);
-+ ev_info->ullval = (ulonglong) MYSQL_MAX(ev_info->ullval, info->ullval);
-+ ev_info->max_dval = (double) MYSQL_MAX(ev_info->max_dval, info->dval);
- }
- return 1;
- } // get_ev_num_info
-@@ -1045,7 +1045,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
- /* TODO remove this after decimal_div returns proper frac */
- my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
-- min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
-+ MYSQL_MIN(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
- FALSE,&rounded_avg);
- my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
- return s;
-@@ -1070,7 +1070,7 @@
- my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment);
- my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr);
- s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)),
-- min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-+ MYSQL_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset);
-
- return s;
- }
-@@ -1187,7 +1187,7 @@
- func_items[8] = new Item_proc_string("Std", 255);
- func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string("Optimal_fieldtype",
-- max(64, output_str_length));
-+ MYSQL_MAX(64, output_str_length));
-
- for (uint i = 0; i < array_elements(func_items); i++)
- field_list.push_back(func_items[i]);
-diff -ur mysql-orig/sql/sql_cache.cc mysql/sql/sql_cache.cc
---- mysql-orig/sql/sql_cache.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_cache.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -1006,7 +1006,7 @@
- }
- last_result_block= header->result()->prev;
- allign_size= ALIGN_SIZE(last_result_block->used);
-- len= max(query_cache.min_allocation_unit, allign_size);
-+ len= MYSQL_MAX(query_cache.min_allocation_unit, allign_size);
- if (last_result_block->length >= query_cache.min_allocation_unit + len)
- query_cache.split_block(last_result_block,len);
-
-@@ -2451,7 +2451,7 @@
- DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
- data_len, header_len, all_headers_len));
-- Query_cache_block *block= allocate_block(max(align_len,
-+ Query_cache_block *block= allocate_block(MYSQL_MAX(align_len,
- min_allocation_unit),1, 0);
- if (block != 0)
- {
-@@ -2506,7 +2506,7 @@
- ulong append_min = get_min_append_result_data_size();
- if (last_block_free_space < data_len &&
- append_next_free_block(last_block,
-- max(tail, append_min)))
-+ MYSQL_MAX(tail, append_min)))
- last_block_free_space = last_block->length - last_block->used;
- // If no space in last block (even after join) allocate new block
- if (last_block_free_space < data_len)
-@@ -2534,7 +2534,7 @@
- // Now finally write data to the last block
- if (success && last_block_free_space > 0)
- {
-- ulong to_copy = min(data_len,last_block_free_space);
-+ ulong to_copy = MYSQL_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
- memcpy((uchar*) last_block + last_block->used, data, to_copy);
-@@ -2622,8 +2622,8 @@
- if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
- return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
-- avg_result = min(avg_result, query_cache_limit);
-- return max(min_result_data_size, avg_result);
-+ avg_result = MYSQL_MIN(avg_result, query_cache_limit);
-+ return MYSQL_MAX(min_result_data_size, avg_result);
- }
-
- inline ulong Query_cache::get_min_append_result_data_size()
-@@ -2655,7 +2655,7 @@
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
-
-- if (!(new_block= allocate_block(max(min_size, align_len),
-+ if (!(new_block= allocate_block(MYSQL_MAX(min_size, align_len),
- min_result_data_size == 0,
- all_headers_len + min_result_data_size)))
- {
-@@ -2664,7 +2664,7 @@
- }
-
- new_block->n_tables = 0;
-- new_block->used = min(len, new_block->length);
-+ new_block->used = MYSQL_MIN(len, new_block->length);
- new_block->type = Query_cache_block::RES_INCOMPLETE;
- new_block->next = new_block->prev = new_block;
- Query_cache_result *header = new_block->result();
-@@ -3087,7 +3087,7 @@
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
- len, not_less,min));
-
-- if (len >= min(query_cache_size, query_cache_limit))
-+ if (len >= MYSQL_MIN(query_cache_size, query_cache_limit))
- {
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
- query_cache_size, query_cache_limit));
-diff -ur mysql-orig/sql/sql_class.cc mysql/sql/sql_class.cc
---- mysql-orig/sql/sql_class.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_class.cc 2012-08-14 01:14:59.442197450 +0000
-@@ -418,7 +418,7 @@
- if (max_query_len < 1)
- len= thd->query_length();
- else
-- len= min(thd->query_length(), max_query_len);
-+ len= MYSQL_MIN(thd->query_length(), max_query_len);
- str.append('\n');
- str.append(thd->query(), len);
- }
-@@ -433,7 +433,7 @@
- was reallocated to a larger buffer to be able to fit.
- */
- DBUG_ASSERT(buffer != NULL);
-- length= min(str.length(), length-1);
-+ length= MYSQL_MIN(str.length(), length-1);
- memcpy(buffer, str.c_ptr_quick(), length);
- /* Make sure that the new string is null terminated */
- buffer[length]= '\0';
-@@ -2116,7 +2116,7 @@
- else
- {
- if (fixed_row_size)
-- used_length=min(res->length(),item->max_length);
-+ used_length=MYSQL_MIN(res->length(),item->max_length);
- else
- used_length=res->length();
- if ((result_type == STRING_RESULT || is_unsafe_field_sep) &&
-diff -ur mysql-orig/sql/sql_client.cc mysql/sql/sql_client.cc
---- mysql-orig/sql/sql_client.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_client.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -34,7 +34,7 @@
- (uint)global_system_variables.net_write_timeout);
-
- net->retry_count= (uint) global_system_variables.net_retry_count;
-- net->max_packet_size= max(global_system_variables.net_buffer_length,
-+ net->max_packet_size= MYSQL_MAX(global_system_variables.net_buffer_length,
- global_system_variables.max_allowed_packet);
- #endif
- }
-diff -ur mysql-orig/sql/sql_connect.cc mysql/sql/sql_connect.cc
---- mysql-orig/sql/sql_connect.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_connect.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -845,7 +845,7 @@
- if (thd->main_security_ctx.host)
- {
- if (thd->main_security_ctx.host != my_localhost)
-- thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),
-+ thd->main_security_ctx.host[MYSQL_MIN(strlen(thd->main_security_ctx.host),
- HOSTNAME_LENGTH)]= 0;
- thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;
- }
-diff -ur mysql-orig/sql/sql_parse.cc mysql/sql/sql_parse.cc
---- mysql-orig/sql/sql_parse.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_parse.cc 2012-08-14 01:14:59.452197368 +0000
-@@ -5762,7 +5762,7 @@
- return 1;
- }
- #ifndef DBUG_OFF
-- max_stack_used= max(max_stack_used, stack_used);
-+ max_stack_used= MYSQL_MAX(max_stack_used, stack_used);
- #endif
- return 0;
- }
-@@ -7293,7 +7293,7 @@
- char command[80];
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- strmake(command, lip->yylval->symbol.str,
-- min(lip->yylval->symbol.length, sizeof(command)-1));
-+ MYSQL_MIN(lip->yylval->symbol.length, sizeof(command)-1));
- my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
- return 1;
- }
-diff -ur mysql-orig/sql/sql_partition.cc mysql/sql/sql_partition.cc
---- mysql-orig/sql/sql_partition.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_partition.cc 2012-08-14 01:14:59.462197286 +0000
-@@ -4592,7 +4592,7 @@
- */
- start_part= 0;
- end_part= new_total_partitions - (upper_2n + 1);
-- end_part= max(lower_2n - 1, end_part);
-+ end_part= MYSQL_MAX(lower_2n - 1, end_part);
- }
- else if (new_total_partitions <= upper_2n)
- {
-diff -ur mysql-orig/sql/sql_plugin.cc mysql/sql/sql_plugin.cc
---- mysql-orig/sql/sql_plugin.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_plugin.cc 2012-08-14 01:14:59.472197202 +0000
-@@ -512,7 +512,7 @@
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
-- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-+ memcpy(cur+i, old, MYSQL_MIN(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
- }
-@@ -2131,7 +2131,7 @@
- &error, &error_len, &not_used);
- if (error_len)
- {
-- strmake(buff, error, min(sizeof(buff) - 1, error_len));
-+ strmake(buff, error, MYSQL_MIN(sizeof(buff) - 1, error_len));
- strvalue= buff;
- goto err;
- }
-diff -ur mysql-orig/sql/sql_prepare.cc mysql/sql/sql_prepare.cc
---- mysql-orig/sql/sql_prepare.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_prepare.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -249,7 +249,7 @@
- int2store(buff+5, columns);
- int2store(buff+7, stmt->param_count);
- buff[9]= 0; // Guard against a 4.1 client
-- tmp= min(stmt->thd->total_warn_count, 65535);
-+ tmp= MYSQL_MIN(stmt->thd->total_warn_count, 65535);
- int2store(buff+10, tmp);
-
- /*
-diff -ur mysql-orig/sql/sql_profile.cc mysql/sql/sql_profile.cc
---- mysql-orig/sql/sql_profile.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_profile.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -254,7 +254,7 @@
- uint query_length_arg)
- {
- /* Truncate to avoid DoS attacks. */
-- uint length= min(MAX_QUERY_LENGTH, query_length_arg);
-+ uint length= MYSQL_MIN(MAX_QUERY_LENGTH, query_length_arg);
-
- DBUG_ASSERT(query_source == NULL); /* we don't leak memory */
- if (query_source_arg != NULL)
-diff -ur mysql-orig/sql/sql_repl.cc mysql/sql/sql_repl.cc
---- mysql-orig/sql/sql_repl.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_repl.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -1299,12 +1299,12 @@
- {
- /*
- Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is
-- not initialized), so we use a max().
-+ not initialized), so we use a MYSQL_MAX().
- What happens to mi->rli.master_log_pos during the initialization stages
- of replication is not 100% clear, so we guard against problems using
- max().
- */
-- mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
-+ mi->master_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE,
- mi->rli.group_master_log_pos);
- strmake(mi->master_log_name, mi->rli.group_master_log_name,
- sizeof(mi->master_log_name)-1);
-@@ -1478,7 +1478,7 @@
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
- ha_rows event_count, limit_start, limit_end;
-- my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
-+ my_off_t pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
- char search_file_name[FN_REFLEN], *name;
- const char *log_file_name = lex_mi->log_file_name;
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
-@@ -1750,14 +1750,14 @@
- DBUG_RETURN(0);
-
- for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
-- buffer += min(block_len, max_event_size),
-- block_len -= min(block_len, max_event_size))
-+ buffer += MYSQL_MIN(block_len, max_event_size),
-+ block_len -= MYSQL_MIN(block_len, max_event_size))
- {
- lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&a))
- DBUG_RETURN(1);
-@@ -1766,7 +1766,7 @@
- {
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer,
-- min(block_len, max_event_size),
-+ MYSQL_MIN(block_len, max_event_size),
- lf_info->log_delayed);
- if (mysql_bin_log.write(&b))
- DBUG_RETURN(1);
-diff -ur mysql-orig/sql/sql_select.cc mysql/sql/sql_select.cc
---- mysql-orig/sql/sql_select.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_select.cc 2012-08-14 01:14:59.482197120 +0000
-@@ -3022,7 +3022,7 @@
- This is can't be to high as otherwise we are likely to use
- table scan.
- */
-- s->worst_seeks= min((double) s->found_records / 10,
-+ s->worst_seeks= MYSQL_MIN((double) s->found_records / 10,
- (double) s->read_time*3);
- if (s->worst_seeks < 2.0) // Fix for small tables
- s->worst_seeks=2.0;
-@@ -3958,7 +3958,7 @@
- uint and_level,i,found_eq_constant;
- KEY_FIELD *key_fields, *end, *field;
- uint sz;
-- uint m= max(select_lex->max_equal_elems,1);
-+ uint m= MYSQL_MAX(select_lex->max_equal_elems,1);
-
- /*
- We use the same piece of memory to store both KEY_FIELD
-@@ -3981,7 +3981,7 @@
- can be not more than select_lex->max_equal_elems such
- substitutions.
- */
-- sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
-+ sz= MYSQL_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
- (((thd->lex->current_select->cond_count+1)*2 +
- thd->lex->current_select->between_count)*m+1);
- if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
-@@ -4144,7 +4144,7 @@
- if (map == 1) // Only one table
- {
- TABLE *tmp_table=join->all_tables[tablenr];
-- keyuse->ref_table_rows= max(tmp_table->file->stats.records, 100);
-+ keyuse->ref_table_rows= MYSQL_MAX(tmp_table->file->stats.records, 100);
- }
- }
- /*
-@@ -4464,7 +4464,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- }
- else
-@@ -4631,7 +4631,7 @@
- tmp= record_count*(tmp+keys_per_block-1)/keys_per_block;
- }
- else
-- tmp= record_count*min(tmp,s->worst_seeks);
-+ tmp= record_count*MYSQL_MIN(tmp,s->worst_seeks);
- }
- else
- tmp= best_time; // Do nothing
-@@ -5581,7 +5581,7 @@
- {
- uint blob_length=(uint) (join_tab->table->file->stats.mean_rec_length-
- (join_tab->table->s->reclength- rec_length));
-- rec_length+=(uint) max(4,blob_length);
-+ rec_length+=(uint) MYSQL_MAX(4,blob_length);
- }
- join_tab->used_fields=fields;
- join_tab->used_fieldlength=rec_length;
-@@ -10488,7 +10488,7 @@
- share->max_rows= ~(ha_rows) 0;
- else
- share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ?
-- min(thd->variables.tmp_table_size,
-+ MYSQL_MIN(thd->variables.tmp_table_size,
- thd->variables.max_heap_table_size) :
- thd->variables.tmp_table_size) /
- share->reclength);
-@@ -13708,7 +13708,7 @@
- index entry.
- */
- index_scan_time= select_limit/rec_per_key *
-- min(rec_per_key, table->file->scan_time());
-+ MYSQL_MIN(rec_per_key, table->file->scan_time());
- if ((ref_key < 0 && is_covering) ||
- (ref_key < 0 && (group || table->force_index)) ||
- index_scan_time < read_time)
-@@ -13720,7 +13720,7 @@
- if (table->quick_keys.is_set(nr))
- quick_records= table->quick_rows[nr];
- if (best_key < 0 ||
-- (select_limit <= min(quick_records,best_records) ?
-+ (select_limit <= MYSQL_MIN(quick_records,best_records) ?
- keyinfo->key_parts < best_key_parts :
- quick_records < best_records))
- {
-@@ -14416,7 +14416,7 @@
- count++;
- if (!sortorder)
- sortorder= (SORT_FIELD*) sql_alloc(sizeof(SORT_FIELD) *
-- (max(count, *length) + 1));
-+ (MYSQL_MAX(count, *length) + 1));
- pos= sort= sortorder;
-
- if (!pos)
-@@ -14538,7 +14538,7 @@
- cache->length=length+blobs*sizeof(char*);
- cache->blobs=blobs;
- *blob_ptr=0; /* End sequentel */
-- size=max(thd->variables.join_buff_size, cache->length);
-+ size=MYSQL_MAX(thd->variables.join_buff_size, cache->length);
- if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
- DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
- cache->end=cache->buff+size;
-diff -ur mysql-orig/sql/sql_show.cc mysql/sql/sql_show.cc
---- mysql-orig/sql/sql_show.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_show.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -753,7 +753,7 @@
- {
- field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string("Create View",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string("character_set_client",
- MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string("collation_connection",
-@@ -764,7 +764,7 @@
- field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN));
- // 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string("Create Table",
-- max(buffer.length(),1024)));
-+ MYSQL_MAX(buffer.length(),1024)));
- }
-
- if (protocol->send_fields(&field_list,
-@@ -1875,7 +1875,7 @@
- pthread_mutex_lock(&tmp->LOCK_thd_data);
- if (tmp->query())
- {
-- uint length= min(max_query_length, tmp->query_length());
-+ uint length= MYSQL_MIN(max_query_length, tmp->query_length());
- thd_info->query= (char*) thd->strmake(tmp->query(),length);
- }
- pthread_mutex_unlock(&tmp->LOCK_thd_data);
-@@ -2006,7 +2006,7 @@
- if (tmp->query())
- {
- table->field[7]->store(tmp->query(),
-- min(PROCESS_LIST_INFO_WIDTH,
-+ MYSQL_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
- table->field[7]->set_notnull();
- }
-@@ -3276,7 +3276,7 @@
- for (ptr=tables->table->field; (field= *ptr) ; ptr++)
- {
- star_table_open_method=
-- min(star_table_open_method,
-+ MYSQL_MIN(star_table_open_method,
- schema_table->fields_info[field_indx].open_method);
- if (bitmap_is_set(tables->table->read_set, field->field_index))
- {
-@@ -7095,7 +7095,7 @@
-
- Item_empty_string *stmt_fld=
- new Item_empty_string("SQL Original Statement",
-- max(trg_sql_original_stmt.length, 1024));
-+ MYSQL_MAX(trg_sql_original_stmt.length, 1024));
-
- stmt_fld->maybe_null= TRUE;
-
-diff -ur mysql-orig/sql/sql_string.cc mysql/sql/sql_string.cc
---- mysql-orig/sql/sql_string.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_string.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -700,7 +700,7 @@
- {
- if (Alloced_length < str_length + space_needed)
- {
-- if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
-+ if (realloc(Alloced_length + MYSQL_MAX(space_needed, grow_by) - 1))
- return TRUE;
- }
- return FALSE;
-@@ -786,7 +786,7 @@
-
- int stringcmp(const String *s,const String *t)
- {
-- uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len);
-+ uint32 s_len=s->length(),t_len=t->length(),len=MYSQL_MIN(s_len,t_len);
- int cmp= memcmp(s->ptr(), t->ptr(), len);
- return (cmp) ? cmp : (int) (s_len - t_len);
- }
-@@ -803,7 +803,7 @@
- }
- if (to->realloc(from_length))
- return from; // Actually an error
-- if ((to->str_length=min(from->str_length,from_length)))
-+ if ((to->str_length=MYSQL_MIN(from->str_length,from_length)))
- memcpy(to->Ptr,from->Ptr,to->str_length);
- to->str_charset=from->str_charset;
- return to;
-@@ -1004,7 +1004,7 @@
-
- if (to_cs == &my_charset_bin)
- {
-- res= min(min(nchars, to_length), from_length);
-+ res= MYSQL_MIN(MYSQL_MIN(nchars, to_length), from_length);
- memmove(to, from, res);
- *from_end_pos= from + res;
- *well_formed_error_pos= NULL;
-@@ -1190,7 +1190,7 @@
- char *t= to;
- char *t_end= to + to_len - 1; // '- 1' is for the '\0' at the end
- const char *f= from;
-- const char *f_end= from + (nbytes ? min(from_len, nbytes) : from_len);
-+ const char *f_end= from + (nbytes ? MYSQL_MIN(from_len, nbytes) : from_len);
- char *dots= to; // last safe place to append '...'
-
- if (!f || t == t_end)
-diff -ur mysql-orig/sql/sql_table.cc mysql/sql/sql_table.cc
---- mysql-orig/sql/sql_table.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/sql_table.cc 2012-08-14 01:14:59.492197038 +0000
-@@ -3276,7 +3276,7 @@
- if ((length=column->length) > max_key_length ||
- length > file->max_key_part_length())
- {
-- length=min(max_key_length, file->max_key_part_length());
-+ length=MYSQL_MIN(max_key_length, file->max_key_part_length());
- if (key->type == Key::MULTIPLE)
- {
- /* not a critical problem */
-diff -ur mysql-orig/sql/sql_yacc.cc mysql/sql/sql_yacc.cc
---- mysql-orig/sql/sql_yacc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_yacc.cc 2012-08-14 01:14:59.502196954 +0000
-@@ -16217,7 +16217,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- break;
-
-@@ -16237,7 +16237,7 @@
- {
- Lex->mi.relay_log_pos = (yyvsp[(3) - (3)].ulong_num);
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- break;
-
-diff -ur mysql-orig/sql/sql_yacc.yy mysql/sql/sql_yacc.yy
---- mysql-orig/sql/sql_yacc.yy 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/sql_yacc.yy 2012-08-14 01:14:59.512196872 +0000
-@@ -1807,7 +1807,7 @@
- from 0" (4 in fact), unspecified means "don't change the position
- (keep the preceding value)").
- */
-- Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
-+ Lex->mi.pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
- }
- | RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
- {
-@@ -1817,7 +1817,7 @@
- {
- Lex->mi.relay_log_pos = $3;
- /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
-- Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
-+ Lex->mi.relay_log_pos = MYSQL_MAX(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
- }
- ;
-
-diff -ur mysql-orig/sql/thr_malloc.cc mysql/sql/thr_malloc.cc
---- mysql-orig/sql/thr_malloc.cc 2012-08-14 01:12:29.423437567 +0000
-+++ mysql/sql/thr_malloc.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -132,7 +132,7 @@
- if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
- {
- // Safety if to_cs->mbmaxlen > 0
-- new_length= min(arg_length, max_res_length);
-+ new_length= MYSQL_MIN(arg_length, max_res_length);
- memcpy(pos, str, new_length);
- }
- else
-diff -ur mysql-orig/sql/tztime.cc mysql/sql/tztime.cc
---- mysql-orig/sql/tztime.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/tztime.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -169,7 +169,7 @@
- uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES +
- TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES +
- #ifdef ABBR_ARE_USED
-- max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
-+ MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) +
- #endif
- sizeof(LS_INFO) * TZ_MAX_LEAPS];
- } u;
-@@ -398,7 +398,7 @@
- Let us choose end_t as point before next time type change or leap
- second correction.
- */
-- end_t= min((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
-+ end_t= MYSQL_MIN((next_trans_idx < sp->timecnt) ? sp->ats[next_trans_idx] - 1:
- MY_TIME_T_MAX,
- (next_leap_idx < sp->leapcnt) ?
- sp->lsis[next_leap_idx].ls_trans - 1: MY_TIME_T_MAX);
-@@ -1825,7 +1825,7 @@
- uchar types[TZ_MAX_TIMES];
- TRAN_TYPE_INFO ttis[TZ_MAX_TYPES];
- #ifdef ABBR_ARE_USED
-- char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
-+ char chars[MYSQL_MAX(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
- #endif
- /*
- Used as a temporary tz_info until we decide that we actually want to
-diff -ur mysql-orig/sql/unireg.cc mysql/sql/unireg.cc
---- mysql-orig/sql/unireg.cc 2012-08-14 01:12:29.413437640 +0000
-+++ mysql/sql/unireg.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -498,7 +498,7 @@
- }
- cfield->row=(uint8) row;
- cfield->col=(uint8) (length+1);
-- cfield->sc_length=(uint8) min(cfield->length,cols-(length+2));
-+ cfield->sc_length=(uint8) MYSQL_MIN(cfield->length,cols-(length+2));
- }
- length=(uint) (pos-start_screen);
- int2store(start_screen,length);
-@@ -718,7 +718,7 @@
- DBUG_RETURN(1);
- }
- /* Hack to avoid bugs with small static rows in MySQL */
-- reclength=max(file->min_record_length(table_options),reclength);
-+ reclength=MYSQL_MAX(file->min_record_length(table_options),reclength);
- if (info_length+(ulong) create_fields.elements*FCOMP+288+
- n_length+int_length+com_length > 65535L || int_count > 255)
- {
-diff -ur mysql-orig/sql-common/client.c mysql/sql-common/client.c
---- mysql-orig/sql-common/client.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/sql-common/client.c 2012-08-14 01:14:59.512196872 +0000
-@@ -730,7 +730,7 @@
- }
-
- (void) strmake(net->last_error,(char*) pos,
-- min((uint) len,(uint) sizeof(net->last_error)-1));
-+ MYSQL_MIN((uint) len,(uint) sizeof(net->last_error)-1));
- }
- else
- set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-@@ -2113,7 +2113,7 @@
- {
- IF_DBUG(char ipaddr[18];)
- memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
-- min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
-+ MYSQL_MIN(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
- DBUG_PRINT("info",("Trying %s...",
- (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
- status= my_connect(sock, (struct sockaddr *) &sock_addr,
-diff -ur mysql-orig/sql-common/my_time.c mysql/sql-common/my_time.c
---- mysql-orig/sql-common/my_time.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/sql-common/my_time.c 2012-08-14 01:14:59.512196872 +0000
-@@ -251,7 +251,7 @@
- 2003-03-03 20:00:20 AM
- 20:00:20.000000 AM 03-03-2000
- */
-- i= max((uint) format_position[0], (uint) format_position[1]);
-+ i= MYSQL_MAX((uint) format_position[0], (uint) format_position[1]);
- set_if_bigger(i, (uint) format_position[2]);
- allow_space= ((1 << i) | (1 << format_position[6]));
- allow_space&= (1 | 2 | 4 | 8);
-diff -ur mysql-orig/storage/csv/ha_tina.cc mysql/storage/csv/ha_tina.cc
---- mysql-orig/storage/csv/ha_tina.cc 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/csv/ha_tina.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -1195,7 +1195,7 @@
- if (closest_hole == chain_ptr) /* no more chains */
- *end_pos= file_buff->end();
- else
-- *end_pos= min(file_buff->end(),
-+ *end_pos= MYSQL_MIN(file_buff->end(),
- closest_hole->begin);
- return (closest_hole != chain_ptr) && (*end_pos == closest_hole->begin);
- }
-@@ -1431,7 +1431,7 @@
- /* write repaired file */
- while (1)
- {
-- write_end= min(file_buff->end(), current_position);
-+ write_end= MYSQL_MIN(file_buff->end(), current_position);
- if ((write_end - write_begin) &&
- (my_write(repair_file, (uchar*)file_buff->ptr(),
- (size_t) (write_end - write_begin), MYF_RW)))
-diff -ur mysql-orig/storage/example/ha_example.h mysql/storage/example/ha_example.h
---- mysql-orig/storage/example/ha_example.h 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/storage/example/ha_example.h 2012-08-14 01:14:59.512196872 +0000
-@@ -112,14 +112,14 @@
- max_supported_key_parts(), uint max_supported_key_length()
- to make sure that the storage engine can handle the data it is about to
- send. Return *real* limits of your storage engine here; MySQL will do
-- min(your_limits, MySQL_limits) automatically.
-+ MYSQL_MIN(your_limits, MySQL_limits) automatically.
- */
- uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
-
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -130,7 +130,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-@@ -141,7 +141,7 @@
- /** @brief
- unireg.cc will call this to make sure that the storage engine can handle
- the data it is about to send. Return *real* limits of your storage engine
-- here; MySQL will do min(your_limits, MySQL_limits) automatically.
-+ here; MySQL will do MYSQL_MIN(your_limits, MySQL_limits) automatically.
-
- @details
- There is no need to implement ..._key_... methods if your engine doesn't
-diff -ur mysql-orig/storage/federated/ha_federated.cc mysql/storage/federated/ha_federated.cc
---- mysql-orig/storage/federated/ha_federated.cc 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/federated/ha_federated.cc 2012-08-14 01:14:59.512196872 +0000
-@@ -546,7 +546,7 @@
- size_t buf_len;
- DBUG_ENTER("ha_federated parse_url_error");
-
-- buf_len= min(table->s->connect_string.length,
-+ buf_len= MYSQL_MIN(table->s->connect_string.length,
- FEDERATED_QUERY_BUFFER_SIZE-1);
- strmake(buf, table->s->connect_string.str, buf_len);
- my_error(error_num, MYF(0), buf);
-@@ -1291,7 +1291,7 @@
- {
- Field *field= key_part->field;
- uint store_length= key_part->store_length;
-- uint part_length= min(store_length, length);
-+ uint part_length= MYSQL_MIN(store_length, length);
- needs_quotes= field->str_needs_quotes();
- DBUG_DUMP("key, start of loop", ptr, length);
-
-diff -ur mysql-orig/storage/heap/hp_create.c mysql/storage/heap/hp_create.c
---- mysql-orig/storage/heap/hp_create.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/heap/hp_create.c 2012-08-14 01:14:59.512196872 +0000
-@@ -230,7 +230,7 @@
- {
- uint i,recbuffer,records_in_block;
-
-- max_records= max(min_records,max_records);
-+ max_records= MYSQL_MAX(min_records,max_records);
- if (!max_records)
- max_records= 1000; /* As good as quess as anything */
- recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1);
-diff -ur mysql-orig/storage/heap/hp_test2.c mysql/storage/heap/hp_test2.c
---- mysql-orig/storage/heap/hp_test2.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/heap/hp_test2.c 2012-08-14 01:14:59.512196872 +0000
-@@ -138,7 +138,7 @@
-
- for (i=0 ; i < recant ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*5,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*5,MAX_RECORDS));
- make_record(record,n1,n2,n3,"Pos",write_count);
-
- if (heap_write(file,record))
-@@ -219,7 +219,7 @@
- printf("- Update\n");
- for (i=0 ; i < write_count/10 ; i++)
- {
-- n1=rnd(1000); n2=rnd(100); n3=rnd(min(recant*2,MAX_RECORDS));
-+ n1=rnd(1000); n2=rnd(100); n3=rnd(MYSQL_MIN(recant*2,MAX_RECORDS));
- make_record(record2, n1, n2, n3, "XXX", update);
- if (rnd(2) == 1)
- {
-diff -ur mysql-orig/storage/innobase/include/ut0byte.h mysql/storage/innobase/include/ut0byte.h
---- mysql-orig/storage/innobase/include/ut0byte.h 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/innobase/include/ut0byte.h 2012-08-14 01:14:59.522196790 +0000
-@@ -87,7 +87,7 @@
- dulint
- ut_dulint_get_max(
- /*==============*/
-- /* out: max(a, b) */
-+ /* out: MYSQL_MAX(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-@@ -96,7 +96,7 @@
- dulint
- ut_dulint_get_min(
- /*==============*/
-- /* out: min(a, b) */
-+ /* out: MYSQL_MIN(a, b) */
- dulint a, /* in: dulint */
- dulint b); /* in: dulint */
- /***********************************************************
-diff -ur mysql-orig/storage/innodb_plugin/dict/dict0dict.c mysql/storage/innodb_plugin/dict/dict0dict.c
---- mysql-orig/storage/innodb_plugin/dict/dict0dict.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/innodb_plugin/dict/dict0dict.c 2012-08-14 01:14:59.522196790 +0000
-@@ -4898,7 +4898,7 @@
-
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-@@ -4908,7 +4908,7 @@
- const char* name) /*!< in: name of the index to find */
- {
- dict_index_t* index;
-- dict_index_t* min_index; /* Index with matching name and min(id) */
-+ dict_index_t* min_index; /* Index with matching name and MYSQL_MIN(id) */
-
- min_index = NULL;
- index = dict_table_get_first_index(table);
-diff -ur mysql-orig/storage/innodb_plugin/include/dict0dict.h mysql/storage/innodb_plugin/include/dict0dict.h
---- mysql-orig/storage/innodb_plugin/include/dict0dict.h 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/innodb_plugin/include/dict0dict.h 2012-08-14 01:14:59.552196542 +0000
-@@ -1115,7 +1115,7 @@
- const char* name); /*!< in: name of the index to find */
- /**********************************************************************//**
- In case there is more than one index with the same name return the index
--with the min(id).
-+with the MYSQL_MIN(id).
- @return index, NULL if does not exist */
- UNIV_INTERN
- dict_index_t*
-diff -ur mysql-orig/storage/myisam/ft_boolean_search.c mysql/storage/myisam/ft_boolean_search.c
---- mysql-orig/storage/myisam/ft_boolean_search.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/ft_boolean_search.c 2012-08-14 01:14:59.552196542 +0000
-@@ -48,9 +48,9 @@
- three subexpressions (including the top-level one),
- every one has its own max_docid, updated by its plus word.
- but for the search word6 uses
-- max(word1.max_docid, word3.max_docid, word5.max_docid),
-+ MYSQL_MAX(word1.max_docid, word3.max_docid, word5.max_docid),
- while word4 uses, accordingly,
-- max(word1.max_docid, word3.max_docid).
-+ MYSQL_MAX(word1.max_docid, word3.max_docid).
- */
-
- #define FT_CORE
-diff -ur mysql-orig/storage/myisam/ha_myisam.cc mysql/storage/myisam/ha_myisam.cc
---- mysql-orig/storage/myisam/ha_myisam.cc 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/ha_myisam.cc 2012-08-14 01:14:59.552196542 +0000
-@@ -1546,7 +1546,7 @@
- {
- DBUG_ENTER("ha_myisam::start_bulk_insert");
- THD *thd= current_thd;
-- ulong size= min(thd->variables.read_buff_size,
-+ ulong size= MYSQL_MIN(thd->variables.read_buff_size,
- (ulong) (table->s->avg_row_length*rows));
- DBUG_PRINT("info",("start_bulk_insert: rows %lu size %lu",
- (ulong) rows, size));
-diff -ur mysql-orig/storage/myisam/mi_cache.c mysql/storage/myisam/mi_cache.c
---- mysql-orig/storage/myisam/mi_cache.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_cache.c 2012-08-14 01:14:59.572196376 +0000
-@@ -61,7 +61,7 @@
- (my_off_t) (info->read_end - info->request_pos))
- {
- in_buff_pos=info->request_pos+(uint) offset;
-- in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos));
-+ in_buff_length= MYSQL_MIN(length, (size_t) (info->read_end-in_buff_pos));
- memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length);
- if (!(length-=in_buff_length))
- DBUG_RETURN(0);
-diff -ur mysql-orig/storage/myisam/mi_check.c mysql/storage/myisam/mi_check.c
---- mysql-orig/storage/myisam/mi_check.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_check.c 2012-08-14 01:14:59.572196376 +0000
-@@ -2175,7 +2175,7 @@
- ulong buff_length;
- DBUG_ENTER("filecopy");
-
-- buff_length=(ulong) min(param->write_buffer_length,length);
-+ buff_length=(ulong) MYSQL_MIN(param->write_buffer_length,length);
- if (!(buff=my_malloc(buff_length,MYF(0))))
- {
- buff=tmp_buff; buff_length=IO_SIZE;
-@@ -2331,7 +2331,7 @@
- init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- length=share->base.min_block_length;
- else
-@@ -2420,7 +2420,7 @@
- (see _create_index_by_sort)
- */
- sort_info.max_records= 10 *
-- max(param->sort_buffer_length, MIN_SORT_BUFFER) /
-+ MYSQL_MAX(param->sort_buffer_length, MIN_SORT_BUFFER) /
- sort_param.key_length;
- }
-
-@@ -2784,7 +2784,7 @@
- my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
-
- if (share->data_file_type == DYNAMIC_RECORD)
-- rec_length=max(share->base.min_pack_length+1,share->base.min_block_length);
-+ rec_length=MYSQL_MAX(share->base.min_pack_length+1,share->base.min_block_length);
- else if (share->data_file_type == COMPRESSED_RECORD)
- rec_length=share->base.min_block_length;
- else
-@@ -3982,7 +3982,7 @@
- ft_buf->buf=ft_buf->lastkey+a_len;
- /*
- 32 is just a safety margin here
-- (at least max(val_len, sizeof(nod_flag)) should be there).
-+ (at least MYSQL_MAX(val_len, sizeof(nod_flag)) should be there).
- May be better performance could be achieved if we'd put
- (sort_info->keyinfo->block_length-32)/XXX
- instead.
-diff -ur mysql-orig/storage/myisam/mi_create.c mysql/storage/myisam/mi_create.c
---- mysql-orig/storage/myisam/mi_create.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_create.c 2012-08-14 01:14:59.572196376 +0000
-@@ -439,8 +439,8 @@
- block_length= (keydef->block_length ?
- my_round_up_to_next_power(keydef->block_length) :
- myisam_block_size);
-- block_length= max(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-- block_length= min(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
-+ block_length= MYSQL_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
-
- keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
- pointer,MI_MAX_KEYPTR_SIZE,
-@@ -529,7 +529,7 @@
- got from MYI file header (see also myisampack.c:save_state)
- */
- share.base.key_reflength=
-- mi_get_pointer_length(max(ci->key_file_length,tmp),3);
-+ mi_get_pointer_length(MYSQL_MAX(ci->key_file_length,tmp),3);
- share.base.keys= share.state.header.keys= keys;
- share.state.header.uniques= uniques;
- share.state.header.fulltext_keys= fulltext_keys;
-@@ -567,7 +567,7 @@
- share.base.min_block_length=
- (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
- ! share.base.blobs) ?
-- max(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
-+ MYSQL_MAX(share.base.pack_reclength,MI_MIN_BLOCK_LENGTH) :
- MI_EXTEND_BLOCK_LENGTH;
- if (! (flags & HA_DONT_TOUCH_DATA))
- share.state.create_time= (long) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/mi_dynrec.c mysql/storage/myisam/mi_dynrec.c
---- mysql-orig/storage/myisam/mi_dynrec.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_dynrec.c 2012-08-14 01:14:59.572196376 +0000
-@@ -882,7 +882,7 @@
- uint tmp=MY_ALIGN(reclength - length + 3 +
- test(reclength >= 65520L),MI_DYN_ALIGN_SIZE);
- /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */
-- tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
-+ tmp= MYSQL_MIN(length+tmp, MI_MAX_BLOCK_LENGTH)-length;
- /* Check if we can extend this block */
- if (block_info.filepos + block_info.block_len ==
- info->state->data_file_length &&
-diff -ur mysql-orig/storage/myisam/mi_extra.c mysql/storage/myisam/mi_extra.c
---- mysql-orig/storage/myisam/mi_extra.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_extra.c 2012-08-14 01:14:59.572196376 +0000
-@@ -101,7 +101,7 @@
- cache_size= (extra_arg ? *(ulong*) extra_arg :
- my_default_record_cache_size);
- if (!(init_io_cache(&info->rec_cache,info->dfile,
-- (uint) min(info->state->data_file_length+1,
-+ (uint) MYSQL_MIN(info->state->data_file_length+1,
- cache_size),
- READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
- MYF(share->write_flag & MY_WAIT_IF_FULL))))
-diff -ur mysql-orig/storage/myisam/mi_open.c mysql/storage/myisam/mi_open.c
---- mysql-orig/storage/myisam/mi_open.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_open.c 2012-08-14 01:14:59.582196294 +0000
-@@ -330,7 +330,7 @@
- strmov(share->index_file_name, index_name);
- strmov(share->data_file_name, data_name);
-
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- {
- HA_KEYSEG *pos=share->keyparts;
- uint32 ftkey_nr= 1;
-@@ -503,7 +503,7 @@
- share->base.margin_key_file_length=(share->base.max_key_file_length -
- (keys ? MI_INDEX_BLOCK_MARGIN *
- share->blocksize * keys : 0));
-- share->blocksize=min(IO_SIZE,myisam_block_size);
-+ share->blocksize=MYSQL_MIN(IO_SIZE,myisam_block_size);
- share->data_file_type=STATIC_RECORD;
- if (share->options & HA_OPTION_COMPRESS_RECORD)
- {
-@@ -716,10 +716,10 @@
- if (length == (ulong) -1)
- {
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
-- length= max(info->s->base.pack_reclength, info->s->max_pack_length);
-+ length= MYSQL_MAX(info->s->base.pack_reclength, info->s->max_pack_length);
- else
- length= info->s->base.pack_reclength;
-- length= max(length, info->s->base.max_key_length);
-+ length= MYSQL_MAX(length, info->s->base.max_key_length);
- /* Avoid unnecessary realloc */
- if (newptr && length == old_length)
- return newptr;
-diff -ur mysql-orig/storage/myisam/mi_packrec.c mysql/storage/myisam/mi_packrec.c
---- mysql-orig/storage/myisam/mi_packrec.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/mi_packrec.c 2012-08-14 01:14:59.582196294 +0000
-@@ -686,7 +686,7 @@
- return OFFSET_TABLE_SIZE;
- }
- length2= find_longest_bitstream(next, end) + 1;
-- length=max(length,length2);
-+ length=MYSQL_MAX(length,length2);
- }
- return length;
- }
-@@ -1401,7 +1401,7 @@
- info->filepos=filepos+head_length;
- if (file > 0)
- {
-- info->offset=min(info->rec_len, ref_length - head_length);
-+ info->offset=MYSQL_MIN(info->rec_len, ref_length - head_length);
- memcpy(*rec_buff_p, header + head_length, info->offset);
- }
- return 0;
-diff -ur mysql-orig/storage/myisam/mi_test1.c mysql/storage/myisam/mi_test1.c
---- mysql-orig/storage/myisam/mi_test1.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_test1.c 2012-08-14 01:14:59.582196294 +0000
-@@ -438,7 +438,7 @@
- uint tmp;
- uchar *ptr;;
- sprintf((char*) blob_record,"... row: %d", rownr);
-- strappend((char*) blob_record,max(MAX_REC_LENGTH-rownr,10),' ');
-+ strappend((char*) blob_record,MYSQL_MAX(MAX_REC_LENGTH-rownr,10),' ');
- tmp=strlen((char*) blob_record);
- int4store(pos,tmp);
- ptr=blob_record;
-diff -ur mysql-orig/storage/myisam/mi_test2.c mysql/storage/myisam/mi_test2.c
---- mysql-orig/storage/myisam/mi_test2.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/mi_test2.c 2012-08-14 01:14:59.582196294 +0000
-@@ -603,7 +603,7 @@
- goto err;
-
- bmove(read_record2,read_record,reclength);
-- for (i=min(2,keys) ; i-- > 0 ;)
-+ for (i=MYSQL_MIN(2,keys) ; i-- > 0 ;)
- {
- if (mi_rsame(file,read_record2,(int) i)) goto err;
- if (memcmp(read_record,read_record2,reclength) != 0)
-diff -ur mysql-orig/storage/myisam/myisamlog.c mysql/storage/myisam/myisamlog.c
---- mysql-orig/storage/myisam/myisamlog.c 2012-08-14 01:12:29.653435667 +0000
-+++ mysql/storage/myisam/myisamlog.c 2012-08-14 01:14:59.582196294 +0000
-@@ -92,7 +92,7 @@
- log_filename=myisam_log_filename;
- get_options(&argc,&argv);
- /* Number of MyISAM files we can have open at one time */
-- max_files= (my_set_max_open_files(min(max_files,8))-6)/2;
-+ max_files= (my_set_max_open_files(MYSQL_MIN(max_files,8))-6)/2;
- if (update)
- printf("Trying to %s MyISAM files according to log '%s'\n",
- (recover ? "recover" : "update"),log_filename);
-diff -ur mysql-orig/storage/myisam/myisampack.c mysql/storage/myisam/myisampack.c
---- mysql-orig/storage/myisam/myisampack.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/myisampack.c 2012-08-14 01:14:59.582196294 +0000
-@@ -1240,7 +1240,7 @@
- {
- if (huff_counts->field_length > 2 &&
- huff_counts->empty_fields + (records - huff_counts->empty_fields)*
-- (1+max_bit(max(huff_counts->max_pre_space,
-+ (1+max_bit(MYSQL_MAX(huff_counts->max_pre_space,
- huff_counts->max_end_space))) <
- records * max_bit(huff_counts->field_length))
- {
-@@ -3002,7 +3002,7 @@
- if (mrg->src_file_has_indexes_disabled)
- {
- isam_file->s->state.state.key_file_length=
-- max(isam_file->s->state.state.key_file_length, new_length);
-+ MYSQL_MAX(isam_file->s->state.state.key_file_length, new_length);
- }
- state.dellink= HA_OFFSET_ERROR;
- state.version=(ulong) time((time_t*) 0);
-diff -ur mysql-orig/storage/myisam/rt_mbr.c mysql/storage/myisam/rt_mbr.c
---- mysql-orig/storage/myisam/rt_mbr.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/rt_mbr.c 2012-08-14 01:14:59.582196294 +0000
-@@ -325,8 +325,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -338,8 +338,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = min(amin, bmin); \
-- amax = max(amax, bmax); \
-+ amin = MYSQL_MIN(amin, bmin); \
-+ amax = MYSQL_MAX(amax, bmax); \
- store_func(c, amin); \
- store_func(c+len, amax); \
- }
-@@ -417,8 +417,8 @@
- bmin = korr_func(b); \
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -431,8 +431,8 @@
- get_func(bmin, b); \
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
-- amin = max(amin, bmin); \
-- amax = min(amax, bmax); \
-+ amin = MYSQL_MAX(amin, bmin); \
-+ amax = MYSQL_MIN(amax, bmax); \
- if (amin >= amax) \
- return 0; \
- res *= amax - amin; \
-@@ -508,7 +508,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_AREA_INC_GET(type, get_func, len)\
-@@ -519,7 +519,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_area *= (((double)amax) - ((double)amin)); \
-- loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ loc_ab_area *= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-@@ -604,7 +604,7 @@
- amax = korr_func(a+len); \
- bmax = korr_func(b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- #define RT_PERIM_INC_GET(type, get_func, len)\
-@@ -615,7 +615,7 @@
- get_func(amax, a+len); \
- get_func(bmax, b+len); \
- a_perim+= (((double)amax) - ((double)amin)); \
-- *ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
-+ *ab_perim+= ((double)MYSQL_MAX(amax, bmax) - (double)MYSQL_MIN(amin, bmin)); \
- }
-
- /*
-diff -ur mysql-orig/storage/myisam/sort.c mysql/storage/myisam/sort.c
---- mysql-orig/storage/myisam/sort.c 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisam/sort.c 2012-08-14 01:14:59.582196294 +0000
-@@ -131,7 +131,7 @@
- sort_keys= (uchar **) NULL; error= 1;
- maxbuffer=1;
-
-- memavl= max(sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sortbuff_size, MIN_SORT_BUFFER);
- records= info->sort_info->max_records;
- sort_length= info->key_length;
- LINT_INIT(keys);
-@@ -348,7 +348,7 @@
- bzero((char*) &sort_param->unique, sizeof(sort_param->unique));
- sort_keys= (uchar **) NULL;
-
-- memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER);
-+ memavl= MYSQL_MAX(sort_param->sortbuff_size, MIN_SORT_BUFFER);
- idx= (uint)sort_param->sort_info->max_records;
- sort_length= sort_param->key_length;
- maxbuffer= 1;
-@@ -822,7 +822,7 @@
- register uint count;
- uint length;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- if (my_pread(fromfile->file,(uchar*) buffpek->base,
- (length= sort_length*count),buffpek->file_pos,MYF_RW))
-@@ -843,7 +843,7 @@
- uint idx;
- uchar *buffp;
-
-- if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
-+ if ((count=(uint) MYSQL_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
- {
- buffp = buffpek->base;
-
-diff -ur mysql-orig/storage/myisammrg/ha_myisammrg.cc mysql/storage/myisammrg/ha_myisammrg.cc
---- mysql-orig/storage/myisammrg/ha_myisammrg.cc 2012-08-14 01:12:29.643435749 +0000
-+++ mysql/storage/myisammrg/ha_myisammrg.cc 2012-08-14 01:14:59.582196294 +0000
-@@ -965,7 +965,7 @@
- memcpy((char*) table->key_info[0].rec_per_key,
- (char*) mrg_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key[0]) *
-- min(file->keys, table->s->key_parts));
-+ MYSQL_MIN(file->keys, table->s->key_parts));
- }
- }
- if (flag & HA_STATUS_ERRKEY)
-diff -ur mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp mysql/storage/ndb/src/common/portlib/NdbTCP.cpp
---- mysql-orig/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-08-14 01:12:29.673435501 +0000
-+++ mysql/storage/ndb/src/common/portlib/NdbTCP.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -30,7 +30,7 @@
- &tmp_errno);
- if (hp)
- {
-- memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
-+ memcpy(dst, hp->h_addr, MYSQL_MIN(sizeof(*dst), (size_t) hp->h_length));
- my_gethostbyname_r_free();
- return 0; //DBUG_RETURN(0);
- }
-diff -ur mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp
---- mysql-orig/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-08-14 01:12:29.683435419 +0000
-+++ mysql/storage/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -212,7 +212,7 @@
- }
- }
- // return values
-- par.m_depth = 1 + max(cpar[0].m_depth, cpar[1].m_depth);
-+ par.m_depth = 1 + MYSQL_MAX(cpar[0].m_depth, cpar[1].m_depth);
- par.m_occup = node.getOccup();
- for (unsigned i = 0; i <= 1; i++) {
- if (node.getLink(i) == NullTupLoc)
-diff -ur mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp mysql/storage/ndb/src/ndbapi/NdbBlob.cpp
---- mysql-orig/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-08-14 01:12:29.693435335 +0000
-+++ mysql/storage/ndb/src/ndbapi/NdbBlob.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -1523,7 +1523,7 @@
- }
- // these buffers are always used
- theKeyBuf.alloc(theTable->m_keyLenInWords << 2);
-- thePackKeyBuf.alloc(max(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
-+ thePackKeyBuf.alloc(MYSQL_MAX(theTable->m_keyLenInWords, theAccessTable->m_keyLenInWords) << 2);
- theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize);
- theHead = (Head*)theHeadInlineBuf.data;
- theInlineData = theHeadInlineBuf.data + sizeof(Head);
-diff -ur mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp mysql/storage/ndb/test/ndbapi/testIndexStat.cpp
---- mysql-orig/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/ndb/test/ndbapi/testIndexStat.cpp 2012-08-14 01:14:59.582196294 +0000
-@@ -30,10 +30,10 @@
- * 0. baseline with same options as handler
- */
-
--#undef min
--#undef max
--#define min(a, b) ((a) <= (b) ? (a) : (b))
--#define max(a, b) ((a) >= (b) ? (a) : (b))
-+#undef MYSQL_MIN
-+#undef MYSQL_MAX
-+#define MYSQL_MIN(a, b) ((a) <= (b) ? (a) : (b))
-+#define MYSQL_MAX(a, b) ((a) >= (b) ? (a) : (b))
-
- inline NdbOut&
- NdbOut::operator<<(double x)
-@@ -784,13 +784,13 @@
- uint
- Range::minattrs() const
- {
-- return min(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MIN(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- uint
- Range::maxattrs() const
- {
-- return max(bnd[0].val.numattrs, bnd[1].val.numattrs);
-+ return MYSQL_MAX(bnd[0].val.numattrs, bnd[1].val.numattrs);
- }
-
- int
-@@ -856,8 +856,8 @@
- lim[i] = lo;
- }
- // the range
-- const int lo = max(lim[0], 0);
-- const int hi = min(lim[1], (int)g_sortcount - 1);
-+ const int lo = MYSQL_MAX(lim[0], 0);
-+ const int hi = MYSQL_MIN(lim[1], (int)g_sortcount - 1);
- if (! g_opts.nochecks) {
- int curr = -1;
- for (i = 0; i < (int)g_sortcount; i++) {
-diff -ur mysql-orig/storage/ndb/test/src/getarg.c mysql/storage/ndb/test/src/getarg.c
---- mysql-orig/storage/ndb/test/src/getarg.c 2012-08-14 01:12:29.663435583 +0000
-+++ mysql/storage/ndb/test/src/getarg.c 2012-08-14 01:14:59.582196294 +0000
-@@ -65,8 +65,8 @@
-
- #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
-
--#ifndef max
--#define max(a, b) (a) > (b) ? (a) : (b)
-+#ifndef MYSQL_MAX
-+#define MYSQL_MAX(a, b) (a) > (b) ? (a) : (b)
- #endif
-
- #ifdef HAVE___PROGNAME
-@@ -306,7 +306,7 @@
- }
- if (args[i].long_name && args[i].short_name)
- len += 2; /* ", " */
-- max_len = max(max_len, len);
-+ max_len = MYSQL_MAX(max_len, len);
- }
- if (extra_string) {
- col = check_column(stderr, col, strlen(extra_string) + 1, columns);
-diff -ur mysql-orig/strings/ctype-big5.c mysql/strings/ctype-big5.c
---- mysql-orig/strings/ctype-big5.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-big5.c 2012-08-14 01:14:59.592196210 +0000
-@@ -254,7 +254,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
- return res ? res : (int)((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -267,7 +267,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_big5_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-bin.c mysql/strings/ctype-bin.c
---- mysql-orig/strings/ctype-bin.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-bin.c 2012-08-14 01:14:59.592196210 +0000
-@@ -82,7 +82,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -133,7 +133,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
- }
-@@ -177,7 +177,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -406,7 +406,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, 0);
- return dstlen;
-@@ -419,7 +419,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen,srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-gbk.c mysql/strings/ctype-gbk.c
---- mysql-orig/strings/ctype-gbk.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-gbk.c 2012-08-14 01:14:59.592196210 +0000
-@@ -2617,7 +2617,7 @@
- const uchar *b, size_t b_length,
- my_bool b_is_prefix)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
- return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length);
- }
-@@ -2628,7 +2628,7 @@
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference)
- {
-- size_t length= min(a_length, b_length);
-+ size_t length= MYSQL_MIN(a_length, b_length);
- int res= my_strnncoll_gbk_internal(&a, &b, length);
-
- #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
-diff -ur mysql-orig/strings/ctype-mb.c mysql/strings/ctype-mb.c
---- mysql-orig/strings/ctype-mb.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-mb.c 2012-08-14 01:14:59.592196210 +0000
-@@ -369,7 +369,7 @@
- const uchar *t, size_t tlen,
- my_bool t_is_prefix)
- {
-- size_t len=min(slen,tlen);
-+ size_t len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen);
- }
-@@ -413,7 +413,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -452,7 +452,7 @@
- const uchar *src, size_t srclen)
- {
- if (dest != src)
-- memcpy(dest, src, min(dstlen, srclen));
-+ memcpy(dest, src, MYSQL_MIN(dstlen, srclen));
- if (dstlen > srclen)
- bfill(dest + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-simple.c mysql/strings/ctype-simple.c
---- mysql-orig/strings/ctype-simple.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-simple.c 2012-08-14 01:14:59.592196210 +0000
-@@ -161,7 +161,7 @@
- diff_if_only_endspace_difference= 0;
- #endif
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (map[*a++] != map[*b++])
-@@ -875,7 +875,7 @@
- val= new_val;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- memcpy(dst, p, len);
- return len+sign;
- }
-@@ -929,7 +929,7 @@
- long_val= quo;
- }
-
-- len= min(len, (size_t) (e-p));
-+ len= MYSQL_MIN(len, (size_t) (e-p));
- cnv:
- memcpy(dst, p, len);
- return len+sign;
-@@ -1160,7 +1160,7 @@
- {
- size_t nbytes= (size_t) (end-start);
- *error= 0;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-diff -ur mysql-orig/strings/ctype-tis620.c mysql/strings/ctype-tis620.c
---- mysql-orig/strings/ctype-tis620.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-tis620.c 2012-08-14 01:14:59.592196210 +0000
-@@ -583,7 +583,7 @@
- a_length= thai2sortable(a, a_length);
- b_length= thai2sortable(b, b_length);
-
-- end= a + (length= min(a_length, b_length));
-+ end= a + (length= MYSQL_MIN(a_length, b_length));
- while (a < end)
- {
- if (*a++ != *b++)
-@@ -640,7 +640,7 @@
- const uchar *src, size_t srclen)
- {
- size_t dstlen= len;
-- len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-+ len= (size_t) (strmake((char*) dest, (char*) src, MYSQL_MIN(len, srclen)) -
- (char*) dest);
- len= thai2sortable(dest, len);
- if (dstlen > len)
-diff -ur mysql-orig/strings/ctype-uca.c mysql/strings/ctype-uca.c
---- mysql-orig/strings/ctype-uca.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-uca.c 2012-08-14 01:14:59.592196210 +0000
-@@ -7569,7 +7569,7 @@
- {
- char tail[30];
- size_t len= lexem->end - lexem->prev;
-- strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1));
-+ strmake (tail, lexem->prev, (size_t) MYSQL_MIN(len, sizeof(tail)-1));
- errstr[errsize-1]= '\0';
- my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail);
- }
-diff -ur mysql-orig/strings/ctype-ucs2.c mysql/strings/ctype-ucs2.c
---- mysql-orig/strings/ctype-ucs2.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-ucs2.c 2012-08-14 01:14:59.602196128 +0000
-@@ -280,7 +280,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort :
- (((int) s[0]) << 8) + (int) s[1];
-@@ -1332,7 +1332,7 @@
- size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1;
- *error= 0;
- nchars*= 2;
-- return min(nbytes, nchars);
-+ return MYSQL_MIN(nbytes, nchars);
- }
-
-
-@@ -1426,7 +1426,7 @@
- se= s + slen;
- te= t + tlen;
-
-- for (minlen= min(slen, tlen); minlen; minlen-= 2)
-+ for (minlen= MYSQL_MIN(slen, tlen); minlen; minlen-= 2)
- {
- int s_wc= s[0] * 256 + s[1];
- int t_wc= t[0] * 256 + t[1];
-@@ -1473,7 +1473,7 @@
- const uchar *src, size_t srclen)
- {
- if (dst != src)
-- memcpy(dst,src,srclen= min(dstlen,srclen));
-+ memcpy(dst,src,srclen= MYSQL_MIN(dstlen,srclen));
- if (dstlen > srclen)
- cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
- return dstlen;
-diff -ur mysql-orig/strings/ctype-utf8.c mysql/strings/ctype-utf8.c
---- mysql-orig/strings/ctype-utf8.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/ctype-utf8.c 2012-08-14 01:14:59.602196128 +0000
-@@ -2114,7 +2114,7 @@
- const uchar *t, const uchar *te)
- {
- int slen= (int) (se-s), tlen= (int) (te-t);
-- int len=min(slen,tlen);
-+ int len=MYSQL_MIN(slen,tlen);
- int cmp= memcmp(s,t,len);
- return cmp ? cmp : slen-tlen;
- }
-diff -ur mysql-orig/strings/decimal.c mysql/strings/decimal.c
---- mysql-orig/strings/decimal.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/decimal.c 2012-08-14 01:14:59.602196128 +0000
-@@ -405,7 +405,7 @@
- for (; frac>0; frac-=DIG_PER_DEC1)
- {
- dec1 x=*buf++;
-- for (i=min(frac, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(frac, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/DIG_MASK;
- *s1++='0'+(uchar)y;
-@@ -428,7 +428,7 @@
- for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1)
- {
- dec1 x=*--buf;
-- for (i=min(intg, DIG_PER_DEC1); i; i--)
-+ for (i=MYSQL_MIN(intg, DIG_PER_DEC1); i; i--)
- {
- dec1 y=x/10;
- *--s='0'+(uchar)(x-y*10);
-@@ -1531,8 +1531,8 @@
-
- if (to != from)
- {
-- dec1 *p0= buf0+intg0+max(frac1, frac0);
-- dec1 *p1= buf1+intg0+max(frac1, frac0);
-+ dec1 *p0= buf0+intg0+MYSQL_MAX(frac1, frac0);
-+ dec1 *p1= buf1+intg0+MYSQL_MAX(frac1, frac0);
-
- DBUG_ASSERT(p0 - buf0 <= len);
- DBUG_ASSERT(p1 - buf1 <= len);
-@@ -1543,7 +1543,7 @@
- buf0=to->buf;
- buf1=to->buf;
- to->sign=from->sign;
-- to->intg=min(intg0, len)*DIG_PER_DEC1;
-+ to->intg=MYSQL_MIN(intg0, len)*DIG_PER_DEC1;
- }
-
- if (frac0 > frac1)
-@@ -1645,7 +1645,7 @@
- scale=frac0*DIG_PER_DEC1;
- error=E_DEC_TRUNCATED; /* XXX */
- }
-- for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--)
-+ for (buf1=to->buf+intg0+MYSQL_MAX(frac0,0); buf1 > to->buf; buf1--)
- {
- buf1[0]=buf1[-1];
- }
-@@ -1664,7 +1664,7 @@
- /* making 'zero' with the proper scale */
- dec1 *p0= to->buf + frac0 + 1;
- to->intg=1;
-- to->frac= max(scale, 0);
-+ to->frac= MYSQL_MAX(scale, 0);
- to->sign= 0;
- for (buf1= to->buf; buf1<p0; buf1++)
- *buf1= 0;
-@@ -1713,11 +1713,11 @@
- {
- switch (op) {
- case '-':
-- return ROUND_UP(max(from1->intg, from2->intg)) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '+':
-- return ROUND_UP(max(from1->intg, from2->intg)+1) +
-- ROUND_UP(max(from1->frac, from2->frac));
-+ return ROUND_UP(MYSQL_MAX(from1->intg, from2->intg)+1) +
-+ ROUND_UP(MYSQL_MAX(from1->frac, from2->frac));
- case '*':
- return ROUND_UP(from1->intg+from2->intg)+
- ROUND_UP(from1->frac)+ROUND_UP(from2->frac);
-@@ -1732,7 +1732,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac),
-- frac0=max(frac1, frac2), intg0=max(intg1, intg2), error;
-+ frac0=MYSQL_MAX(frac1, frac2), intg0=MYSQL_MAX(intg1, intg2), error;
- dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry;
-
- sanity(to);
-@@ -1757,7 +1757,7 @@
- buf0=to->buf+intg0+frac0;
-
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg0*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1768,7 +1768,7 @@
- set_if_smaller(intg2, intg0);
- }
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN(frac) */
- if (frac1 > frac2)
- {
- buf1=from1->buf+intg1+frac1;
-@@ -1786,14 +1786,14 @@
- while (buf1 > stop)
- *--buf0=*--buf1;
-
-- /* part 2 - min(frac) ... min(intg) */
-+ /* part 2 - MYSQL_MIN(frac) ... MYSQL_MIN(intg) */
- carry=0;
- while (buf1 > stop2)
- {
- ADD(*--buf0, *--buf1, *--buf2, carry);
- }
-
-- /* part 3 - min(intg) ... max(intg) */
-+ /* part 3 - MYSQL_MIN(intg) ... MYSQL_MAX(intg) */
- buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) :
- ((stop=from2->buf)+intg2-intg1) ;
- while (buf1 > stop)
-@@ -1814,7 +1814,7 @@
- {
- int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg),
- frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac);
-- int frac0=max(frac1, frac2), error;
-+ int frac0=MYSQL_MAX(frac1, frac2), error;
- dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2, carry=0;
-
- /* let carry:=1 if from2 > from1 */
-@@ -1889,7 +1889,7 @@
- FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error);
- buf0=to->buf+intg1+frac0;
-
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- to->intg=intg1*DIG_PER_DEC1;
- if (unlikely(error))
- {
-@@ -1900,7 +1900,7 @@
- }
- carry=0;
-
-- /* part 1 - max(frac) ... min (frac) */
-+ /* part 1 - MYSQL_MAX(frac) ... MYSQL_MIN (frac) */
- if (frac1 > frac2)
- {
- buf1=start1+intg1+frac1;
-@@ -1924,7 +1924,7 @@
- }
- }
-
-- /* part 2 - min(frac) ... intg2 */
-+ /* part 2 - MYSQL_MIN(frac) ... intg2 */
- while (buf2 > start2)
- {
- SUB(*--buf0, *--buf1, *--buf2, carry);
-@@ -2187,11 +2187,11 @@
- {
- /* we're calculating N1 % N2.
- The result will have
-- frac=max(frac1, frac2), as for subtraction
-+ frac=MYSQL_MAX(frac1, frac2), as for subtraction
- intg=intg2
- */
- to->sign=from1->sign;
-- to->frac=max(from1->frac, from2->frac);
-+ to->frac=MYSQL_MAX(from1->frac, from2->frac);
- frac0=0;
- }
- else
-@@ -2315,7 +2315,7 @@
- /*
- now the result is in tmp1, it has
- intg=prec1-frac1
-- frac=max(frac1, frac2)=to->frac
-+ frac=MYSQL_MAX(frac1, frac2)=to->frac
- */
- if (dcarry)
- *--start1=dcarry;
-@@ -2353,7 +2353,7 @@
- }
- DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg));
- stop1=start1+frac0+intg0;
-- to->intg=min(intg0*DIG_PER_DEC1, from2->intg);
-+ to->intg=MYSQL_MIN(intg0*DIG_PER_DEC1, from2->intg);
- }
- if (unlikely(intg0+frac0 > to->len))
- {
-diff -ur mysql-orig/strings/my_vsnprintf.c mysql/strings/my_vsnprintf.c
---- mysql-orig/strings/my_vsnprintf.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/my_vsnprintf.c 2012-08-14 01:14:59.602196128 +0000
-@@ -143,7 +143,7 @@
- /* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (store_start == buff)
- {
-- length= min(length, to_length);
-+ length= MYSQL_MIN(length, to_length);
- if (res_length < length)
- {
- size_t diff= (length- res_length);
-diff -ur mysql-orig/strings/str2int.c mysql/strings/str2int.c
---- mysql-orig/strings/str2int.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/strings/str2int.c 2012-08-14 01:14:59.602196128 +0000
-@@ -84,7 +84,7 @@
- machines all, if +|n| is representable, so is -|n|, but on
- twos complement machines the converse is not true. So the
- "maximum" representable number has a negative representative.
-- Limit is set to min(-|lower|,-|upper|); this is the "largest"
-+ Limit is set to MYSQL_MIN(-|lower|,-|upper|); this is the "largest"
- number we are concerned with. */
-
- /* Calculate Limit using Scale as a scratch variable */
-diff -ur mysql-orig/vio/viosocket.c mysql/vio/viosocket.c
---- mysql-orig/vio/viosocket.c 2012-08-14 01:12:29.723435087 +0000
-+++ mysql/vio/viosocket.c 2012-08-14 01:14:59.602196128 +0000
-@@ -79,7 +79,7 @@
-
- if (vio->read_pos < vio->read_end)
- {
-- rc= min((size_t) (vio->read_end - vio->read_pos), size);
-+ rc= MYSQL_MIN((size_t) (vio->read_end - vio->read_pos), size);
- memcpy(buf, vio->read_pos, rc);
- vio->read_pos+= rc;
- /*
diff --git a/07120_all_openssl_handshake_mybug_33050.patch b/07120_all_openssl_handshake_mybug_33050.patch
deleted file mode 100644
index 7109589..0000000
--- a/07120_all_openssl_handshake_mybug_33050.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From: kent
-Date: December 22 2007 4:08am
-Subject: bk commit into 5.0 tree (kent:1.2586) BUG#33050
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of kent. When kent does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-12-22 04:08:48+01:00, kent@stripped +1 -0
- viossl.c:
- In OpenSSL the connection type, "accept" or "connect",
- must be set before starting the handshake (bug#33050)
-
- vio/viossl.c@stripped, 2007-12-22 04:06:54+01:00, kent@stripped +22 -7
- In OpenSSL the connection type, "accept" or "connect",
- must be set before starting the handshake (bug#33050)
-
-diff -Nrup a/vio/viossl.c b/vio/viossl.c
---- a/vio/viossl.c 2007-08-28 11:34:42 +02:00
-+++ b/vio/viossl.c 2007-12-22 04:06:54 +01:00
-@@ -172,14 +172,9 @@ void vio_ssl_delete(Vio *vio)
- vio_delete(vio);
- }
-
--int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
--{
-- DBUG_ENTER("sslaccept");
-- DBUG_RETURN(sslconnect(ptr, vio, timeout));
--}
--
-+#define VIO_SSL_ACCEPT_MODE 1
-
--int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+static int ssl_connect_accept(struct st_VioSSLFd *ptr, Vio *vio, long timeout, int mode)
- {
- SSL *ssl;
- my_bool unused;
-@@ -204,6 +199,12 @@ int sslconnect(struct st_VioSSLFd *ptr,
- SSL_SESSION_set_timeout(SSL_get_session(ssl), timeout);
- SSL_set_fd(ssl, vio->sd);
-
-+ /* OpenSSL wants to know what mode, yaSSL seems to know */
-+ if (mode == VIO_SSL_ACCEPT_MODE)
-+ SSL_set_accept_state(ssl);
-+ else
-+ SSL_set_connect_state(ssl);
-+
- /*
- SSL_do_handshake will select between SSL_connect
- or SSL_accept depending on server or client side
-@@ -256,6 +257,20 @@ int sslconnect(struct st_VioSSLFd *ptr,
- #endif
-
- DBUG_RETURN(0);
-+}
-+
-+
-+int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+{
-+ DBUG_ENTER("sslaccept");
-+ DBUG_RETURN(ssl_connect_accept(ptr, vio, timeout, VIO_SSL_ACCEPT_MODE));
-+}
-+
-+
-+int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
-+{
-+ DBUG_ENTER("sslaccept");
-+ DBUG_RETURN(ssl_connect_accept(ptr, vio, timeout, 0));
- }
-
-
diff --git a/07130_all_mysqldump-hang-33057_5.0.52.patch b/07130_all_mysqldump-hang-33057_5.0.52.patch
deleted file mode 100644
index 7834377..0000000
--- a/07130_all_mysqldump-hang-33057_5.0.52.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-Patch borrowed from CentOS mysql-5.0.52-mysqldump-hang-33057.patch
-
-#### ChangeSet ####
-2007-12-20 21:37:21+01:00, df@pippilotta.erinye.com
- BUG#33057 mysql command line client slows down and uses 100% CPU when restoring dump
-
-==== client/mysql.cc ====
-2007-12-20 21:37:19+01:00, df@pippilotta.erinye.com +1 -3
- BUG#33057, avoid calling strlen() *for every single character* in the client's input
-
---- 1.244/client/mysql.cc 2007-12-13 02:49:10 -08:00
-+++ 1.245/client/mysql.cc 2007-12-20 12:37:19 -08:00
-@@ -1272,9 +1272,7 @@ static bool add_line(String &buffer,char
- if (status.add_to_history && line[0] && not_in_history(line))
- add_history(line);
- #endif
--#ifdef USE_MB
- char *end_of_line=line+(uint) strlen(line);
--#endif
-
- for (pos=out=line ; (inchar= (uchar) *pos) ; pos++)
- {
-@@ -1364,7 +1362,7 @@ static bool add_line(String &buffer,char
- }
- }
- else if (!*ml_comment && !*in_string &&
-- strlen(pos) >= 10 &&
-+ (end_of_line - pos) >= 10 &&
- !my_strnncoll(charset_info, (uchar*) pos, 10,
- (const uchar*) "delimiter ", 10))
- {
diff --git a/07190_all_disallow_database_ops_without_super_mybug_27440.patch b/07190_all_disallow_database_ops_without_super_mybug_27440.patch
deleted file mode 100644
index 252375d..0000000
--- a/07190_all_disallow_database_ops_without_super_mybug_27440.patch
+++ /dev/null
@@ -1,210 +0,0 @@
-http://lists.mysql.com/commits/39534?f=plain
-
-From: kpetterssonDate: December 7 2007 3:39pm
-Subject: bk commit into 5.0 tree (thek:1.2589) BUG#27440
-
-Below is the list of changes that have just been committed into a local
-5.0 repository of thek. When thek does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-12-07 15:39:41+01:00, thek@adventure.(none) +3 -0
- Bug #27440 read_only allows create and drop database
-
- When read_only option was enabled, a user without SUPER privilege could
- perform CREATE DATABASE and DROP DATABASE operations.
-
- This patch adds a check to make sure this isn't possible. It also attempts to
- simplify the logic used to determine if relevant tables are updated,
- making it more human readable.
-
- mysql-test/r/read_only.result@stripped, 2007-12-07 15:39:40+01:00, thek@adventure.(none) +31 -0
- Updated result file
-
- mysql-test/t/read_only.test@stripped, 2007-12-07 15:39:40+01:00, thek@adventure.(none) +34 -0
- A test case is added which shows that it is not possible to drop or create a
- database in read-only mode despite having the GRANT permissions to do so,
- SUPER user excepted.
-
- sql/sql_parse.cc@stripped, 2007-12-07 15:39:40+01:00, thek@adventure.(none) +69 -8
- - Simplified complex predicate by grouping it in a read friendly way.
- - Added predicate to fail on database updates while running in read-only
- mode.
-
-diff -Nrup a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result
---- a/mysql-test/r/read_only.result 2006-11-20 15:35:19 +01:00
-+++ b/mysql-test/r/read_only.result 2007-12-07 15:39:40 +01:00
-@@ -46,4 +46,35 @@ Warnings:
- Note 1051 Unknown table 'ttt'
- drop table t1,t2;
- drop user test@localhost;
-+#
-+# Bug #27440 read_only allows create and drop database
-+#
-+drop database if exists mysqltest_db1;
-+drop database if exists mysqltest_db2;
-+delete from mysql.user where User like 'mysqltest_%';
-+delete from mysql.db where User like 'mysqltest_%';
-+delete from mysql.tables_priv where User like 'mysqltest_%';
-+delete from mysql.columns_priv where User like 'mysqltest_%';
-+flush privileges;
-+grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
-+create database mysqltest_db1;
-+grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
-+flush privileges;
-+show grants for current_user();
-+Grants for mysqltest_u1@%
-+GRANT USAGE ON *.* TO 'mysqltest_u1'@'%'
-+GRANT ALL PRIVILEGES ON `mysqltest_db2`.* TO 'mysqltest_u1'@'%'
-+GRANT ALL PRIVILEGES ON `mysqltest_db1`.* TO 'mysqltest_u1'@'%'
-+create database mysqltest_db2;
-+ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
-+show databases like '%mysqltest_db2%';
-+Database (%mysqltest_db2%)
-+drop database mysqltest_db1;
-+ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
-+delete from mysql.user where User like 'mysqltest_%';
-+delete from mysql.db where User like 'mysqltest_%';
-+delete from mysql.tables_priv where User like 'mysqltest_%';
-+delete from mysql.columns_priv where User like 'mysqltest_%';
-+flush privileges;
-+drop database mysqltest_db1;
- set global read_only=0;
-diff -Nrup a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test
---- a/mysql-test/t/read_only.test 2006-11-20 15:35:19 +01:00
-+++ b/mysql-test/t/read_only.test 2007-12-07 15:39:40 +01:00
-@@ -117,4 +117,38 @@ connection default;
- drop table t1,t2;
- drop user test@localhost;
-
-+--echo #
-+--echo # Bug #27440 read_only allows create and drop database
-+--echo #
-+--disable_warnings
-+drop database if exists mysqltest_db1;
-+drop database if exists mysqltest_db2;
-+--enable_warnings
-+
-+delete from mysql.user where User like 'mysqltest_%';
-+delete from mysql.db where User like 'mysqltest_%';
-+delete from mysql.tables_priv where User like 'mysqltest_%';
-+delete from mysql.columns_priv where User like 'mysqltest_%';
-+flush privileges;
-+
-+grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
-+create database mysqltest_db1;
-+grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
-+flush privileges;
-+connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,);
-+connection con_bug27440;
-+show grants for current_user();
-+--error ER_OPTION_PREVENTS_STATEMENT
-+create database mysqltest_db2;
-+show databases like '%mysqltest_db2%';
-+--error ER_OPTION_PREVENTS_STATEMENT
-+drop database mysqltest_db1;
-+disconnect con_bug27440;
-+connection default;
-+delete from mysql.user where User like 'mysqltest_%';
-+delete from mysql.db where User like 'mysqltest_%';
-+delete from mysql.tables_priv where User like 'mysqltest_%';
-+delete from mysql.columns_priv where User like 'mysqltest_%';
-+flush privileges;
-+drop database mysqltest_db1;
- set global read_only=0;
-diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
---- a/sql/sql_parse.cc 2007-11-22 13:18:18 +01:00
-+++ b/sql/sql_parse.cc 2007-12-07 15:39:40 +01:00
-@@ -1597,6 +1597,74 @@ static bool do_command(THD *thd)
- #endif /* EMBEDDED_LIBRARY */
-
-
-+/**
-+ @brief Determine if an attempt to update a non-temporary table while the
-+ read-only option was enabled has been made.
-+
-+ This is a helper function to mysql_execute_command.
-+
-+ @note SQLCOM_MULTI_UPDATE is an exception and delt with elsewhere.
-+
-+ @see mysql_execute_command
-+ @returns Status code
-+ @retval TRUE The statement should be denied.
-+ @retval FALSE The statement isn't updating any relevant tables.
-+*/
-+
-+static my_bool deny_updates_if_read_only_option(THD *thd,
-+ TABLE_LIST *all_tables)
-+{
-+ DBUG_ENTER("deny_updates_if_read_only_option");
-+
-+ if (!opt_readonly)
-+ DBUG_RETURN(FALSE);
-+
-+ LEX *lex= thd->lex;
-+
-+ const my_bool user_is_super=
-+ ((ulong)(thd->security_ctx->master_access & SUPER_ACL) ==
-+ (ulong)SUPER_ACL);
-+
-+ if (user_is_super)
-+ DBUG_RETURN(FALSE);
-+
-+ if (!uc_update_queries[lex->sql_command])
-+ DBUG_RETURN(FALSE);
-+
-+ /* Multi update is an exception and is dealt with later. */
-+ if (lex->sql_command == SQLCOM_UPDATE_MULTI)
-+ DBUG_RETURN(FALSE);
-+
-+ const my_bool create_temp_tables=
-+ (lex->sql_command == SQLCOM_CREATE_TABLE) &&
-+ (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE);
-+
-+ const my_bool drop_temp_tables=
-+ (lex->sql_command == SQLCOM_DROP_TABLE) &&
-+ lex->drop_temporary;
-+
-+ const my_bool update_real_tables=
-+ some_non_temp_table_to_be_updated(thd, all_tables) &&
-+ !(create_temp_tables || drop_temp_tables);
-+
-+
-+ const my_bool create_or_drop_databases=
-+ (lex->sql_command == SQLCOM_CREATE_DB) ||
-+ (lex->sql_command == SQLCOM_DROP_DB);
-+
-+ if (update_real_tables || create_or_drop_databases)
-+ {
-+ /*
-+ An attempt was made to modify one or more non-temporary tables.
-+ */
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ /* Assuming that only temporary tables are modified. */
-+ DBUG_RETURN(FALSE);
-+}
-+
- /*
- Perform one connection-level (COM_XXXX) command.
-
-@@ -2590,14 +2658,7 @@ mysql_execute_command(THD *thd)
- When option readonly is set deny operations which change non-temporary
- tables. Except for the replication thread and the 'super' users.
- */
-- if (opt_readonly &&
-- !(thd->security_ctx->master_access & SUPER_ACL) &&
-- uc_update_queries[lex->sql_command] &&
-- !((lex->sql_command == SQLCOM_CREATE_TABLE) &&
-- (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) &&
-- !((lex->sql_command == SQLCOM_DROP_TABLE) && lex->drop_temporary) &&
-- ((lex->sql_command != SQLCOM_UPDATE_MULTI) &&
-- some_non_temp_table_to_be_updated(thd, all_tables)))
-+ if (deny_updates_if_read_only_option(thd, all_tables))
- {
- my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
- DBUG_RETURN(-1);
diff --git a/07210_all_encode_html_entities-5.0.70.patch b/07210_all_encode_html_entities-5.0.70.patch
deleted file mode 100644
index 87c64b5..0000000
--- a/07210_all_encode_html_entities-5.0.70.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-When using the commandline client and --html, HTML entities are not encoded,
-leading to a potential XSS.
-
-The testcase portion of this patch is disabled, as it does not apply to 5.0.72.
-You can find an updated testcase in 721_all_encode_html_entities_testcase-5.0.70.patch.
-
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-X-Patch-URL: http://bugs.mysql.com/file.php?id=9232
-MySQL-Bug: 27884
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=27884
-Gentoo-Bug: 240407
-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=240407
-
-=== modified file 'client/mysql.cc'
---- client/mysql.cc 2007-11-13 13:29:42 +0000
-+++ client/mysql.cc 2008-05-01 19:16:09 +0000
-@@ -2636,9 +2636,12 @@
- {
- while((field = mysql_fetch_field(result)))
- {
-- tee_fprintf(PAGER, "<TH>%s</TH>", (field->name ?
-- (field->name[0] ? field->name :
-- " &nbsp; ") : "NULL"));
-+ tee_fputs("<TH>", PAGER);
-+ if (field->name && field->name[0])
-+ xmlencode_print(field->name, field->name_length);
-+ else
-+ tee_fputs(field->name ? " &nbsp; " : "NULL", PAGER);
-+ tee_fputs("</TH>", PAGER);
- }
- (void) tee_fputs("</TR>", PAGER);
- }
-@@ -2651,7 +2654,7 @@
- for (uint i=0; i < mysql_num_fields(result); i++)
- {
- (void) tee_fputs("<TD>", PAGER);
-- safe_put_field(cur[i],lengths[i]);
-+ xmlencode_print(cur[i], lengths[i]);
- (void) tee_fputs("</TD>", PAGER);
- }
- (void) tee_fputs("</TR>", PAGER);
-
-#=== modified file 'mysql-test/r/mysql.result'
-#--- mysql-test/r/mysql.result 2007-09-20 09:10:05 +0000
-#+++ mysql-test/r/mysql.result 2008-05-01 19:23:01 +0000
-#@@ -180,3 +180,5 @@
-# 1
-# End of 5.0 tests
-# WARNING: --server-arg option not supported in this configuration.
-#+<TABLE BORDER=1><TR><TH>&lt;</TH></TR><TR><TD>&lt; &amp; &gt;</TD></TR></TABLE>
-#+End of 5.1 tests
-#
-#=== modified file 'mysql-test/t/mysql.test'
-#--- mysql-test/t/mysql.test 2007-09-04 22:50:09 +0000
-#+++ mysql-test/t/mysql.test 2008-05-01 19:22:54 +0000
-#@@ -290,3 +290,11 @@
-# --disable_query_log
-# --exec $MYSQL --server-arg=no-defaults test -e "quit"
-# --enable_query_log
-#+
-#+#
-#+# Bug #27884: mysql --html does not quote HTML special characters in output
-#+#
-#+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
-#+
-#+--echo
-#+--echo End of 5.1 tests
-#
diff --git a/07210_all_encode_html_entities_testcase-5.0.72.patch b/07210_all_encode_html_entities_testcase-5.0.72.patch
deleted file mode 100644
index 36a7563..0000000
--- a/07210_all_encode_html_entities_testcase-5.0.72.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-When using the commandline client and --html, HTML entities are not encoded,
-leading to a potential XSS.
-
-This is the testcase portion from the original patch, ported to 5.0.72.
-
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-X-Patch-URL: http://bugs.mysql.com/file.php?id=9232
-MySQL-Bug: 27884
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=27884
-Gentoo-Bug: 240407
-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=240407
-
-diff -Nuar --exclude '*rej' --exclude '*.orig' mysql.orig/mysql-test/r/mysql.result mysql/mysql-test/r/mysql.result
---- mysql.orig/mysql-test/r/mysql.result 2008-10-24 10:37:54.000000000 -0700
-+++ mysql/mysql-test/r/mysql.result 2008-11-29 02:26:34.934351498 -0800
-@@ -180,4 +180,5 @@
- 1
- This is a file starting with UTF8 BOM 0xEFBBBF
- This is a file starting with UTF8 BOM 0xEFBBBF
-+<TABLE BORDER=1><TR><TH>&lt;</TH></TR><TR><TD>&lt; &amp; &gt;</TD></TR></TABLE>
- End of 5.0 tests
-diff -Nuar --exclude '*rej' --exclude '*.orig' mysql.orig/mysql-test/t/mysql.test mysql/mysql-test/t/mysql.test
---- mysql.orig/mysql-test/t/mysql.test 2008-10-24 10:37:54.000000000 -0700
-+++ mysql/mysql-test/t/mysql.test 2008-11-29 02:27:20.390073639 -0800
-@@ -290,4 +290,9 @@
- --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1
- remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql;
-
-+#
-+# Bug #27884: mysql --html does not quote HTML special characters in output
-+#
-+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
-+
- --echo End of 5.0 tests
diff --git a/07210_all_encode_html_entities_testcase-5.0.76.patch b/07210_all_encode_html_entities_testcase-5.0.76.patch
deleted file mode 100644
index ac0a6cf..0000000
--- a/07210_all_encode_html_entities_testcase-5.0.76.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-When using the commandline client and --html, HTML entities are not encoded,
-leading to a potential XSS.
-
-This is the testcase portion from the original patch, ported to 5.0.72.
-
-Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-X-Patch-URL: http://bugs.mysql.com/file.php?id=9232
-MySQL-Bug: 27884
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=27884
-Gentoo-Bug: 240407
-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=240407
-
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysql-test/r/mysql.result mysql/mysql-test/r/mysql.result
---- mysql.orig/mysql-test/r/mysql.result 2009-01-15 10:45:22.000000000 -0800
-+++ mysql/mysql-test/r/mysql.result 2009-02-10 19:27:04.046576272 -0800
-@@ -186,4 +186,5 @@
- 2
- 2
- 2
-+<TABLE BORDER=1><TR><TH>&lt;</TH></TR><TR><TD>&lt; &amp; &gt;</TD></TR></TABLE>
- End of 5.0 tests
-diff -Nuar --exclude '*.orig' --exclude '*.rej' mysql.orig/mysql-test/t/mysql.test mysql/mysql-test/t/mysql.test
---- mysql.orig/mysql-test/t/mysql.test 2009-01-15 10:44:56.000000000 -0800
-+++ mysql/mysql-test/t/mysql.test 2009-02-10 19:26:33.346202977 -0800
-@@ -309,4 +309,10 @@
- --exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
- remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
-
-+#
-+# Bug #27884: mysql --html does not quote HTML special characters in output
-+#
-+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
-+
-+--echo
- --echo End of 5.0 tests
diff --git a/07270_all_charset_boot_fix-5.1.43.patch b/07270_all_charset_boot_fix-5.1.43.patch
deleted file mode 100644
index aba2f29..0000000
--- a/07270_all_charset_boot_fix-5.1.43.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-Revert the changes from upstream bug 45058 for charset boot that broke akonadi.
-
-X-Patch-URL: https://bugzilla.redhat.com/attachment.cgi?id=395215&action=diff&context=patch&collapsed=&headers=1&format=raw
-X-Redhat-Bug-URL: https://bugzilla.redhat.com/show_bug.cgi?id=566547#c11
-
---- mysql-5.1.44.orig/include/my_sys.h 2010-02-04 06:37:06.000000000 -0500
-+++ mysql-5.1.44.orig/include/my_sys.h 2010-02-19 23:13:48.000000000 -0500
-@@ -951,6 +951,7 @@
- CHARSET_INFO *default_cl,
- CHARSET_INFO **cl);
-
-+extern void free_charsets(void);
- extern char *get_charsets_dir(char *buf);
- extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
- extern my_bool init_compiled_charsets(myf flags);
---- mysql-5.1.44.orig/libmysql/libmysql.c 2010-02-04 06:37:07.000000000 -0500
-+++ mysql-5.1.44.orig/libmysql/libmysql.c 2010-02-19 23:13:48.000000000 -0500
-@@ -211,6 +211,7 @@
- }
- else
- {
-+ free_charsets();
- mysql_thread_end();
- }
-
---- mysql-5.1.44.orig/mysys/charset.c 2010-02-04 06:38:50.000000000 -0500
-+++ mysql-5.1.44.orig/mysys/charset.c 2010-02-19 23:13:48.000000000 -0500
-@@ -322,6 +321,7 @@
- #define MY_CHARSET_INDEX "Index.xml"
-
- const char *charsets_dir= NULL;
-+static int charset_initialized=0;
-
-
- static my_bool my_read_charset_file(const char *filename, myf myflags)
-@@ -399,37 +399,63 @@
- }
-
-
--static my_pthread_once_t charsets_initialized= MY_PTHREAD_ONCE_INIT;
--
--static void init_available_charsets(void)
-+#ifdef __NETWARE__
-+my_bool STDCALL init_available_charsets(myf myflags)
-+#else
-+static my_bool init_available_charsets(myf myflags)
-+#endif
- {
- char fname[FN_REFLEN + sizeof(MY_CHARSET_INDEX)];
-- CHARSET_INFO **cs;
--
-- bzero(&all_charsets,sizeof(all_charsets));
-- init_compiled_charsets(MYF(0));
--
-- /* Copy compiled charsets */
-- for (cs=all_charsets;
-- cs < all_charsets+array_elements(all_charsets)-1 ;
-- cs++)
-+ my_bool error=FALSE;
-+ /*
-+ We have to use charset_initialized to not lock on THR_LOCK_charset
-+ inside get_internal_charset...
-+ */
-+ if (!charset_initialized)
- {
-- if (*cs)
-+ CHARSET_INFO **cs;
-+ /*
-+ To make things thread safe we are not allowing other threads to interfere
-+ while we may changing the cs_info_table
-+ */
-+ pthread_mutex_lock(&THR_LOCK_charset);
-+ if (!charset_initialized)
- {
-- if (cs[0]->ctype)
-- if (init_state_maps(*cs))
-- *cs= NULL;
-+ bzero(&all_charsets,sizeof(all_charsets));
-+ init_compiled_charsets(myflags);
-+
-+ /* Copy compiled charsets */
-+ for (cs=all_charsets;
-+ cs < all_charsets+array_elements(all_charsets)-1 ;
-+ cs++)
-+ {
-+ if (*cs)
-+ {
-+ if (cs[0]->ctype)
-+ if (init_state_maps(*cs))
-+ *cs= NULL;
-+ }
-+ }
-+
-+ strmov(get_charsets_dir(fname), MY_CHARSET_INDEX);
-+ error= my_read_charset_file(fname,myflags);
-+ charset_initialized=1;
- }
-+ pthread_mutex_unlock(&THR_LOCK_charset);
- }
--
-- strmov(get_charsets_dir(fname), MY_CHARSET_INDEX);
-- my_read_charset_file(fname, MYF(0));
-+ return error;
-+}
-+
-+
-+void free_charsets(void)
-+{
-+ charset_initialized=0;
- }
-
-
- uint get_collation_number(const char *name)
- {
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ init_available_charsets(MYF(0));
- return get_collation_number_internal(name);
- }
-
-@@ -437,7 +463,7 @@
- uint get_charset_number(const char *charset_name, uint cs_flags)
- {
- CHARSET_INFO **cs;
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ init_available_charsets(MYF(0));
-
- for (cs= all_charsets;
- cs < all_charsets+array_elements(all_charsets)-1 ;
-@@ -454,7 +480,7 @@
- const char *get_charset_name(uint charset_number)
- {
- CHARSET_INFO *cs;
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ init_available_charsets(MYF(0));
-
- cs=all_charsets[charset_number];
- if (cs && (cs->number == charset_number) && cs->name )
-@@ -512,7 +538,7 @@
- if (cs_number == default_charset_info->number)
- return default_charset_info;
-
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ (void) init_available_charsets(MYF(0)); /* If it isn't initialized */
-
- if (!cs_number || cs_number >= array_elements(all_charsets)-1)
- return NULL;
-@@ -534,7 +560,7 @@
- {
- uint cs_number;
- CHARSET_INFO *cs;
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ (void) init_available_charsets(MYF(0)); /* If it isn't initialized */
-
- cs_number=get_collation_number(cs_name);
- cs= cs_number ? get_internal_charset(cs_number,flags) : NULL;
-@@ -559,7 +585,7 @@
- DBUG_ENTER("get_charset_by_csname");
- DBUG_PRINT("enter",("name: '%s'", cs_name));
-
-- my_pthread_once(&charsets_initialized, init_available_charsets);
-+ (void) init_available_charsets(MYF(0)); /* If it isn't initialized */
-
- cs_number= get_charset_number(cs_name, cs_flags);
- cs= cs_number ? get_internal_charset(cs_number, flags) : NULL;
---- mysql-5.1.44.orig/mysys/my_init.c 2010-02-04 06:38:51.000000000 -0500
-+++ mysql-5.1.44.orig/mysys/my_init.c 2010-02-19 23:13:48.000000000 -0500
-@@ -165,6 +165,7 @@
- my_print_open_files();
- }
- }
-+ free_charsets();
- my_error_unregister_all();
- my_once_free();
-
---- mysql-5.1.44.orig/netware/libmysqlmain.c 2010-02-04 06:38:51.000000000 -0500
-+++ mysql-5.1.44.orig/netware/libmysqlmain.c 2010-02-19 23:13:48.000000000 -0500
-@@ -18,7 +18,7 @@
-
- #include "my_global.h"
-
--void init_available_charsets(void);
-+my_bool init_available_charsets(myf myflags);
-
- /* this function is required so that global memory is allocated against this
- library nlm, and not against a paticular client */
-@@ -31,7 +31,7 @@
- {
- mysql_server_init(0, NULL, NULL);
-
-- init_available_charsets();
-+ init_available_charsets(MYF(0));
-
- return 0;
- }
---- mysql-5.1.44.orig/sql/mysqld.cc 2010-02-04 06:39:50.000000000 -0500
-+++ mysql-5.1.44.orig/sql/mysqld.cc 2010-02-19 23:13:48.000000000 -0500
-@@ -1287,6 +1287,7 @@
- lex_free(); /* Free some memory */
- item_create_cleanup();
- set_var_free();
-+ free_charsets();
- if (!opt_noacl)
- {
- #ifdef HAVE_DLOPEN
diff --git a/07270_all_charset_boot_fix-5.1.44.patch b/07270_all_charset_boot_fix-5.1.44.patch
deleted file mode 100644
index 69ea2a3..0000000
--- a/07270_all_charset_boot_fix-5.1.44.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-This patch is for testing only, it's proposed by upstream MySQL.
-
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=45058
-MySQL-Bug: 45058
-
-=== modified file 'include/my_sys.h'
---- include/my_sys.h 2009-12-12 18:11:25 +0000
-+++ include/my_sys.h 2010-02-23 01:58:03 +0000
-@@ -950,7 +950,7 @@ extern my_bool resolve_charset(const cha
- extern my_bool resolve_collation(const char *cl_name,
- CHARSET_INFO *default_cl,
- CHARSET_INFO **cl);
--
-+extern void free_charsets(void);
- extern char *get_charsets_dir(char *buf);
- extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
- extern my_bool init_compiled_charsets(myf flags);
-
-=== modified file 'libmysql/libmysql.c'
---- libmysql/libmysql.c 2009-12-18 18:44:24 +0000
-+++ libmysql/libmysql.c 2010-02-23 01:58:23 +0000
-@@ -211,6 +211,7 @@ void STDCALL mysql_server_end()
- }
- else
- {
-+ free_charsets();
- mysql_thread_end();
- }
-
-
-=== modified file 'mysys/charset.c'
---- mysys/charset.c 2009-12-15 09:48:29 +0000
-+++ mysys/charset.c 2010-02-23 01:59:13 +0000
-@@ -427,6 +427,11 @@ static void init_available_charsets(void
- }
-
-
-+void free_charsets(void)
-+{
-+ charsets_initialized= MY_PTHREAD_ONCE_INIT;
-+}
-+
- uint get_collation_number(const char *name)
- {
- my_pthread_once(&charsets_initialized, init_available_charsets);
-
-=== modified file 'mysys/my_init.c'
---- mysys/my_init.c 2009-12-12 18:11:25 +0000
-+++ mysys/my_init.c 2010-02-23 01:59:31 +0000
-@@ -165,6 +165,7 @@ void my_end(int infoflag)
- my_print_open_files();
- }
- }
-+ free_charsets();
- my_error_unregister_all();
- my_once_free();
-
-
-=== modified file 'sql/mysqld.cc'
---- sql/mysqld.cc 2010-02-05 12:55:20 +0000
-+++ sql/mysqld.cc 2010-02-23 01:59:49 +0000
-@@ -1287,6 +1287,7 @@ void clean_up(bool print_message)
- lex_free(); /* Free some memory */
- item_create_cleanup();
- set_var_free();
-+ free_charsets();
- if (!opt_noacl)
- {
- #ifdef HAVE_DLOPEN
-
diff --git a/07271_all_charset_init_fix-5.1.44.patch b/07271_all_charset_init_fix-5.1.44.patch
deleted file mode 100644
index 0ab1a08..0000000
--- a/07271_all_charset_init_fix-5.1.44.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-Workaround the pthread_once_t static initialization. Per the POSIX standard,
-reinitialization of a pthread_once is a gray area, but it is needed to
-supportsubsequent initializations of the client library (upstream bug 45058).
-
-Gentoo-Bug: 310535
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=310535
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=45058
-MySQL-Bug: 45058
-
---- mysys/charset.c 2010-03-21 12:08:59.000000000 +0100
-+++ mysys/charset.c 2010-03-21 12:13:53.000000000 +0100
-@@ -400,6 +400,7 @@ static void *cs_alloc(size_t size)
-
-
- static my_pthread_once_t charsets_initialized= MY_PTHREAD_ONCE_INIT;
-+static my_pthread_once_t charsets_template= MY_PTHREAD_ONCE_INIT;
-
- static void init_available_charsets(void)
- {
-@@ -429,7 +430,7 @@ static void init_available_charsets(void
-
- void free_charsets(void)
- {
-- charsets_initialized= MY_PTHREAD_ONCE_INIT;
-+ charsets_initialized= charsets_template;
- }
-
- uint get_collation_number(const char *name)
diff --git a/07280_all_stdbool-maria-5.1.42.patch b/07280_all_stdbool-maria-5.1.42.patch
deleted file mode 100644
index 925fd4b..0000000
--- a/07280_all_stdbool-maria-5.1.42.patch
+++ /dev/null
@@ -1,98 +0,0 @@
-GCC4.4 header requirements.
-
-X-Gentoo-Bug: 30522
-X-Gentoo-Patch: http://bugs.gentoo.org/attachment.cgi?id=220053&action=view
-X-Ported: from 07280_all_stdbool-5.1.44.patch
-X-Ported: from 07280_all_stdbool-5.0.90.patch
-
-diff -Nuar --exclude '*.orig' mysql/extra/replace.c mysql.new/extra/replace.c
---- mysql/extra/replace.c 2010-01-31 04:17:57.000000000 -0500
-+++ mysql.new/extra/replace.c 2010-02-24 10:42:32.055074861 -0500
-@@ -40,6 +40,7 @@
- */
-
- #define DONT_USE_RAID
-+#include <stdbool.h>
- #include <my_global.h>
- #include <m_ctype.h>
- #include <my_sys.h>
-diff -Nuar --exclude '*.orig' mysql/include/my_getopt.h mysql.new/include/my_getopt.h
---- mysql/include/my_getopt.h 2010-01-31 04:17:59.000000000 -0500
-+++ mysql.new/include/my_getopt.h 2010-02-24 10:41:32.365074952 -0500
-@@ -16,6 +16,8 @@
- #ifndef _my_getopt_h
- #define _my_getopt_h
-
-+#include <stdbool.h>
-+
- C_MODE_START
-
- #define GET_NO_ARG 1
-diff -Nuar --exclude '*.orig' mysql/include/my_time.h mysql.new/include/my_time.h
---- mysql/include/my_time.h 2010-01-31 04:17:59.000000000 -0500
-+++ mysql.new/include/my_time.h 2010-02-24 10:41:58.705074961 -0500
-@@ -20,6 +20,9 @@
-
- #ifndef _my_time_h_
- #define _my_time_h_
-+
-+#include <stdbool.h>
-+
- #include "my_global.h"
- #include "mysql_time.h"
-
-diff -Nuar --exclude '*.orig' mysql/mysys/thr_lock.c mysql.new/mysys/thr_lock.c
---- mysql/mysys/thr_lock.c 2010-01-31 04:18:19.000000000 -0500
-+++ mysql.new/mysys/thr_lock.c 2010-02-24 10:19:11.045074691 -0500
-@@ -80,6 +80,8 @@
- #define FORCE_DBUG_OFF
- #endif
-
-+#include <stdbool.h>
-+
- #include "mysys_priv.h"
-
- #ifdef THREAD
-diff -Nuar --exclude '*.orig' mysql/regex/reginit.c mysql.new/regex/reginit.c
---- mysql/regex/reginit.c 2010-01-31 04:18:19.000000000 -0500
-+++ mysql.new/regex/reginit.c 2010-02-24 10:43:07.695074821 -0500
-@@ -1,5 +1,6 @@
- /* Init cclasses array from ctypes */
-
-+#include <stdbool.h>
- #include <my_global.h>
- #include <m_ctype.h>
- #include <m_string.h>
-diff -Nuar --exclude '*.orig' mysql/storage/heap/hp_update.c mysql.new/storage/heap/hp_update.c
---- mysql/storage/heap/hp_update.c 2010-01-31 04:18:23.000000000 -0500
-+++ mysql.new/storage/heap/hp_update.c 2010-02-24 10:44:03.015074446 -0500
-@@ -15,6 +15,7 @@
-
- /* Update current record in heap-database */
-
-+#include <stdbool.h>
- #include "heapdef.h"
-
- int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
-diff -Nuar --exclude '*.orig' mysql/storage/myisam/myisamdef.h mysql.new/storage/myisam/myisamdef.h
---- mysql/storage/myisam/myisamdef.h 2010-01-31 04:18:26.000000000 -0500
-+++ mysql.new/storage/myisam/myisamdef.h 2010-02-24 10:44:37.345074924 -0500
-@@ -15,6 +15,7 @@
-
- /* This file is included by all internal myisam files */
-
-+#include <stdbool.h>
- #include "myisam.h" /* Structs & some defines */
- #include "myisampack.h" /* packing of keys */
- #include <my_tree.h>
-diff -Nuar --exclude '*.orig' mysql/vio/viosslfactories.c mysql.new/vio/viosslfactories.c
---- mysql/vio/viosslfactories.c 2010-01-31 04:18:34.000000000 -0500
-+++ mysql.new/vio/viosslfactories.c 2010-02-24 10:44:56.245075119 -0500
-@@ -13,6 +13,7 @@
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-+#include <stdbool.h>
- #include "vio_priv.h"
-
- #ifdef HAVE_OPENSSL
diff --git a/07290_all_myisam_cast_warning_issue_gcc43.patch b/07290_all_myisam_cast_warning_issue_gcc43.patch
deleted file mode 100644
index 7c74e4b..0000000
--- a/07290_all_myisam_cast_warning_issue_gcc43.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-Gentoo-Bug: 308999
-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=308999
-MySQL-Bug: 31171
-MySQL-Bug-URL: http://bugs.mysql.com/bug.php?id=31171
-X-Patch-URL: http://lists.mysql.com/commits/38217
-
-From: Date: November 21 2007 5:52pm
-Subject: bk commit into 5.1 tree (gkodinov:1.2635) BUG#31171
-List-Archive: http://lists.mysql.com/commits/38217
-X-Bug: 31171
-Message-Id: <20071121165244.2547B1EF944@macbook.gmz>
-
-Below is the list of changes that have just been committed into a local
-5.1 repository of kgeorge. When kgeorge does a push these changes will
-be propagated to the main repository and, within 24 hours after the
-push, to the public repository.
-For information on how to access the public repository
-see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
-
-ChangeSet@stripped, 2007-11-21 18:52:38+02:00, gkodinov@stripped +1 -0
- Bug #31171: test alter_table, fulltext2, ps, sp fail,
- "Table is already up to date" vs. "OK"
-
- On MacOSX 10.5 when you cast something to "bool"
- (the built in C type) it takes values 0 or 1
- instead of 0-255 as it seems to be on older compilers.
- Fixed by removing the typecast (not needed).
- No test case needed : there are tests that test it.
-
- storage/myisam/mi_open.c@stripped, 2007-11-21 18:52:37+02:00, gkodinov@stripped +1 -1
- Bug #31171: don't typecast when not needed
-
-diff -Nrup a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
---- a/storage/myisam/mi_open.c 2007-08-13 16:11:16 +03:00
-+++ b/storage/myisam/mi_open.c 2007-11-21 18:52:37 +02:00
-@@ -916,7 +916,7 @@ uchar *mi_state_info_read(uchar *ptr, MI
- key_blocks=state->header.max_block_size_index;
-
- state->open_count = mi_uint2korr(ptr); ptr +=2;
-- state->changed= (bool) *ptr++;
-+ state->changed= *ptr++;
- state->sortkey = (uint) *ptr++;
- state->state.records= mi_rowkorr(ptr); ptr +=8;
- state->state.del = mi_rowkorr(ptr); ptr +=8;
diff --git a/07300_all_mysql_embedded_compilefix-5.0.91.patch b/07300_all_mysql_embedded_compilefix-5.0.91.patch
deleted file mode 100644
index e1ef0e5..0000000
--- a/07300_all_mysql_embedded_compilefix-5.0.91.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -Nuar mysql-5.0.91.orig//sql/sql_parse.cc mysql-5.0.91//sql/sql_parse.cc
---- mysql-5.0.91.orig//sql/sql_parse.cc 2010-05-05 14:07:10.000000000 +0000
-+++ mysql-5.0.91//sql/sql_parse.cc 2010-05-21 20:29:16.714903163 +0000
-@@ -499,7 +499,9 @@
- big packets indefinitely, this is a previously established behavior
- that needs to be preserved as to not break backwards compatibility.
- */
-+#if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
- thd->net.skip_big_packet= TRUE;
-+#endif
- /* Ready to handle queries */
- DBUG_RETURN(0);
- }
diff --git a/07310_all_mysql_gcc45-disable-abicheck.patch b/07310_all_mysql_gcc45-disable-abicheck.patch
deleted file mode 100644
index 4306b06..0000000
--- a/07310_all_mysql_gcc45-disable-abicheck.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-
-X-Gentoo-Bug: 312435
-X-Upstream-Bug: 52514
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=312435
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=52514
-
---- mysql-5.1.45/Makefile.am.orig 2010-03-31 10:52:25.000000000 -0400
-+++ mysql-5.1.45/Makefile.am 2010-03-31 10:55:05.000000000 -0400
-@@ -312,24 +312,7 @@
- $(MAKE) abi_headers="$^" do_abi_check
-
- do_abi_check:
-- set -ex; \
-- for file in $(abi_headers); do \
-- @CC@ -E -nostdinc -dI \
-- -I$(top_srcdir)/include \
-- -I$(top_srcdir)/include/mysql \
-- -I$(top_srcdir)/sql \
-- -I$(top_builddir)/include \
-- -I$(top_builddir)/include/mysql \
-- -I$(top_builddir)/sql \
-- $$file 2>/dev/null | \
-- @SED@ -e '/^# /d' \
-- -e '/^[ ]*$$/d' \
-- -e '/^#pragma GCC set_debug_pwd/d' \
-- -e '/^#ident/d' > \
-- $(top_builddir)/abi_check.out; \
-- @DIFF@ -w $$file.pp $(top_builddir)/abi_check.out; \
-- @RM@ $(top_builddir)/abi_check.out; \
-- done
-+ echo "Skipping do_abi_check"
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
diff --git a/07320_all_mysql_mycompiler_header.patch b/07320_all_mysql_mycompiler_header.patch
deleted file mode 100644
index 4272e67..0000000
--- a/07320_all_mysql_mycompiler_header.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-
-X-Gentoo-Bug: 333923
-X-Upstream-Bug: 55846
-X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=333923
-X-Upstream-Bug-URL: http://bugs.mysql.com/bug.php?id=55846
-X-Upstream-Patch-URL: http://lists.mysql.com/commits/116644?f=plain
-
-diff -Naur mysql-5.1.50.orig/include/Makefile.am mysql-5.1.50/include/Makefile.am
---- mysql-5.1.50.orig/include/Makefile.am 2010-08-03 18:24:29.000000000 +0100
-+++ mysql-5.1.50/include/Makefile.am 2010-08-24 11:57:01.000000000 +0100
-@@ -23,7 +23,7 @@
- pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
- my_xml.h mysql_embed.h \
- my_pthread.h my_no_pthread.h \
-- decimal.h errmsg.h my_global.h my_net.h \
-+ decimal.h errmsg.h my_compiler.h my_global.h my_net.h \
- my_getopt.h sslopt-longopts.h my_dir.h \
- sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
- m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
-@@ -37,7 +37,7 @@
- my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
- thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
- my_handler.h my_time.h my_vle.h my_user.h \
-- my_libwrap.h my_stacktrace.h my_compiler.h
-+ my_libwrap.h my_stacktrace.h
-
- EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp
-
diff --git a/07330_all_mysql_itemfunc_stacksize_bug57386.patch b/07330_all_mysql_itemfunc_stacksize_bug57386.patch
deleted file mode 100644
index c729cd1..0000000
--- a/07330_all_mysql_itemfunc_stacksize_bug57386.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From: Date: October 29 2010 5:08am
-Subject: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3548) Bug#57386
-List-Archive: http://lists.mysql.com/commits/122257
-X-Bug: 57386
-Message-Id: <201010290309.o9SM9w7v013620@acsinet15.oracle.com>
-MIME-Version: 1.0
-Content-Type: multipart/mixed; boundary="===============1022272001=="
-
---===============1022272001==
-MIME-Version: 1.0
-Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7bit
-Content-Disposition: inline
-
-#At file:///Users/shulga/projects/mysql/5.1-bugteam-bug57386/ based on revid:anitha.gopi@stripped
-
- 3548 Dmitry Shulga 2010-10-29
- Fixed Bug#57386 - main.execution_constants segfault on MIPS64EL.
- @ sql/item_func.cc
- Item_func::fix_fields modified: increased minimal required stack
- size in call to check_stack_overrun().
-
- modified:
- sql/item_func.cc
-=== modified file 'sql/item_func.cc'
---- a/sql/item_func.cc 2010-10-05 08:11:56 +0000
-+++ b/sql/item_func.cc 2010-10-29 03:08:46 +0000
-@@ -157,7 +157,14 @@ Item_func::fix_fields(THD *thd, Item **r
- used_tables_cache= not_null_tables_cache= 0;
- const_item_cache=1;
-
-- if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
-+ /*
-+ Increase stack limit to STACK_MIN_SIZE * 2 since
-+ on some platforms recursive call to fix_fields
-+ required more than STACK_MIN_SIZE bytes (e.g. for
-+ MIPS, where needs about 22kB for one recursive
-+ call to Item_func::fix_fields)
-+ */
-+ if (check_stack_overrun(thd, STACK_MIN_SIZE * 2, buff))
- return TRUE; // Fatal error if flag is set!
- if (arg_count)
- { // Print purify happy
-
-
---===============1022272001==
-MIME-Version: 1.0
-Content-Type: text/bzr-bundle; charset="us-ascii";
- name="bzr/dmitry.shulga@stripped"
-Content-Transfer-Encoding: 7bit
-Content-Disposition: inline
-
-# Bazaar merge directive format 2 (Bazaar 0.90)
-# revision_id: dmitry.shulga@stripped\
-# k5ndh8ifz4f01dvw
-# target_branch: file:///Users/shulga/projects/mysql/5.1-bugteam-\
-# bug57386/
-# testament_sha1: 4a208317c130fa9ea6aa883ce51a26aa4a2b9943
-# timestamp: 2010-10-29 10:09:01 +0700
-# base_revision_id: anitha.gopi@stripped\
-# h9gdxjzhjv8zxse9
-#
-# Begin bundle
-IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZqHn5kAAc3fgEAQWHf/938v
-TBC////wUASeiaU662zQAANCET1NNTzVHqfpTwkG1M1NqMjIPQj1GgEKZMSPUeRpNPUDahoGgAAA
-ADSTRknpoTT0mgGgMgAAAABzTEwEaYEYRgAAACYRgJJATQp4QaAjQyj0aU9NQepk0NND9UOXsxn2
-0b6/4dY7Lv6rPvXHRkb4UwA3TdGDO2fvmSTwPnkitDGm/1ymZjDgOK2mTwpLFoGX762n2JW5Tl1Q
-GdnfO2aKG1mdcZvgm6wpQZgoJXLigYDgxGOXLJS+fNbcEMF7yPI+3mszadEJPnvU4vkEH85JZ4FL
-RTIVoLCqVT7quhcDiGO1Ml83O8l3SF0yJPll3RRZsHZN0TnswjBOQomkTkGwTBrU1JrDR3pFcgmq
-VOnYjy4xEubAo4BYkukKc6jIKE8VYSeaDAhVDAkigedHAdlXFOLRphFUcwgVmgWqC2YkSuwR52Ff
-TGrMrblZsL1gwnk8xmrkGmHGHB/VU2WIKDu6Q7t++bvoTqpsdqNtCW0L1UsFVnYW+Ky13wEkT1po
-F/AL4fJJkzCr6gGBZ3Y0GaLllQl6M8ZvEVy+OM5Vs8W+VSc4pR5p9LddV6fVCyrCKmxvv7lhWr0+
-U4xGHaTlYeCxu7lKyyenB6yIq7PcQsjEdmgJ5SC3KVxtilmfSJwX4kROuNEoFIuAqNxD5JCkCU8D
-ZmhIr1g/dUfAZ2LrAbRY1/YPzPdVW8eTcoOqZxfGQTob/MaHRUuUY069dNRFcX2VkeMjM/STeVG7
-8KGhfEh3FwU34VnVRh/aOpBPDnRRX+rqt/yW1LF/ByNR9ukB5+T0uQuyTOEWDfGrmYuIA0aqM8Qc
-AYJ0kiOgxMRHUsgkKGo6R7NqDbq8thqdk5JtwPUAwCYgzxJA22EJnIVMvaEphwuT2NYwFEjs8qiI
-G+3DtcUrv1O/StSK99ag+SoPFvPoe5yGxroxSVguK+qlt1tVy5ccMnxQbW4K34/Q8nHsUCWuGYYW
-lh0CVuENAwxhjxxZqqFS7Id2dho3kdE5DI/t1qxSvNyZZ2OmuOm6Z4wpsVA0QV8I7Ml7i3D8fqdx
-8eZvyoVHSNpmbzX059G9BivvHg/KidUlQVmpvgBxXIU8t2apVZabu8XqnvXAGLHnLxX5yE2tT3MY
-ZLE19moGzhPXit4oInE1yNWDviGFnhb592uVFa205BT1sXrioIJmZdXGfyXouAVi4ebwavaHj+C3
-WL1O8Lge5e3hteuZcAy2Ad9gb3lfsIg1SUp8VCNZAi3U8RaN1XlMpQrNasnFzrhmTna9qZOVIpRl
-7uR8hSkzze0k3lbHOiEXJyw5A2Y51a0jc3Zuoh3SEi5MqzqBaFvZAO2Cw+Xw4lWIX7mYHk/AGUK9
-kZU0qhKpXDGTk4F2OdnLTSSRk+3wcTqxcrm3Z4XXqZmGnkaVU8ZJuEWNMHNUQx7U1+O5i/iKGkLz
-RG07Glz5tXY3BXkig7VEO1NnWOXLNO2LtBpE3CSPAz/bEsrJJ/p+MN23MYzC8MArAaTJ2Utnh7sc
-joB332Fqek3IwbV/yfksDFPO0MBeqNjadXRYK9WKjUW9eagnqcxmQPdlRZxaK1mU/Zf+LuSKcKEh
-NQ8/Mg==
-
-
---===============1022272001==--
diff --git a/07340_all_mysql_hardened_x86_strings-5.1.69.patch b/07340_all_mysql_hardened_x86_strings-5.1.69.patch
deleted file mode 100644
index dd6ba9e..0000000
--- a/07340_all_mysql_hardened_x86_strings-5.1.69.patch
+++ /dev/null
@@ -1,424 +0,0 @@
-As part of fixing the TEXTRELs, we must remove this file seperately because
-applying a move of .s -> .S on a case-insensitive file-system will cause patch
-to break.
-
-diff -urN a/strings/strings-x86.s b/strings/strings-x86.s
---- a/strings/strings-x86.s 2010-11-09 21:29:32.192000076 +0100
-+++ b/strings/strings-x86.s 1970-01-01 01:00:00.000000000 +0100
-@@ -1,416 +0,0 @@
--# Copyright (c) 2000, 2002-2004 MySQL AB
--# 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
--
--# Optimized string functions Intel 80x86 (gcc/gas syntax)
--
-- .file "strings.s"
-- .version "1.00"
--
--.text
--
--# Move a alligned, not overlapped, by (long) divided memory area
--# Args: to,from,length
--
--.globl bmove_align
-- .type bmove_align,@function
--bmove_align:
-- movl %edi,%edx
-- push %esi
-- movl 4(%esp),%edi # to
-- movl 8(%esp),%esi # from
-- movl 12(%esp),%ecx # length
-- addw $3,%cx # fix if not divisible with long
-- shrw $2,%cx
-- jz .ba_20
-- .p2align 4,,7
--.ba_10:
-- movl -4(%esi,%ecx),%eax
-- movl %eax,-4(%edi,%ecx)
-- decl %ecx
-- jnz .ba_10
--.ba_20: pop %esi
-- movl %edx,%edi
-- ret
--
--.bmove_align_end:
-- .size bmove_align,.bmove_align_end-bmove_align
--
-- # Move a string from higher to lower
-- # Arg from_end+1,to_end+1,length
--
--.globl bmove_upp
-- .type bmove_upp,@function
--bmove_upp:
-- movl %edi,%edx # Remember %edi
-- push %esi
-- movl 8(%esp),%edi # dst
-- movl 16(%esp),%ecx # length
-- movl 12(%esp),%esi # source
-- test %ecx,%ecx
-- jz .bu_20
-- subl %ecx,%esi # To start of strings
-- subl %ecx,%edi
--
-- .p2align 4,,7
--.bu_10: movb -1(%esi,%ecx),%al
-- movb %al,-1(%edi,%ecx)
-- decl %ecx
-- jnz .bu_10
--.bu_20: pop %esi
-- movl %edx,%edi
-- ret
--
--.bmove_upp_end:
-- .size bmove_upp,.bmove_upp_end-bmove_upp
--
-- # Append fillchars to string
-- # Args: dest,len,fill
--
--.globl strappend
-- .type strappend,@function
--strappend:
-- pushl %edi
-- movl 8(%esp),%edi # Memory pointer
-- movl 12(%esp),%ecx # Length
-- clrl %eax # Find end of string
-- repne
-- scasb
-- jnz sa_99 # String to long, shorten it
-- movzb 16(%esp),%eax # Fillchar
-- decl %edi # Point at end null
-- incl %ecx # rep made one dec for null-char
--
-- movb %al,%ah # (2) Set up a 32 bit pattern.
-- movw %ax,%dx # (2)
-- shll $16,%eax # (3)
-- movw %dx,%ax # (2) %eax has the 32 bit pattern.
--
-- movl %ecx,%edx # (2) Save the count of bytes.
-- shrl $2,%ecx # (2) Number of dwords.
-- rep
-- stosl # (5 + 5n)
-- movb $3,%cl # (2)
-- and %edx,%ecx # (2) Fill in the odd bytes
-- rep
-- stosb # Move last bytes if any
--
--sa_99: movb $0,(%edi) # End of string
-- popl %edi
-- ret
--.strappend_end:
-- .size strappend,.strappend_end-strappend
--
-- # Find if string contains any char in another string
-- # Arg: str,set
-- # Ret: Pointer to first found char in str
--
--.globl strcont
-- .type strcont,@function
--strcont:
-- movl %edi,%edx
-- pushl %esi
-- movl 8(%esp),%esi # str
-- movl 12(%esp),%ecx # set
-- clrb %ah # For endtest
-- jmp sc_60
--
--sc_10: scasb
-- jz sc_fo # Found char
--sc_20: cmp (%edi),%ah # Test if null
-- jnz sc_10 # Not end of set yet
-- incl %esi # Next char in str
--sc_60: movl %ecx,%edi # %edi = Set
-- movb (%esi),%al # Test if this char exist
-- andb %al,%al
-- jnz sc_20 # Not end of string
-- clrl %esi # Return Null
--sc_fo: movl %esi,%eax # Char found here
-- movl %edx,%edi # Restore
-- popl %esi
-- ret
--.strcont_end:
-- .size strcont,.strcont_end-strcont
--
-- # Find end of string
-- # Arg: str
-- # ret: Pointer to end null
--
--.globl strend
-- .type strend,@function
--strend:
-- movl %edi,%edx # Save
-- movl 4(%esp),%edi # str
-- clrl %eax # Find end of string
-- movl %eax,%ecx
-- decl %ecx # ECX = -1
-- repne
-- scasb
-- movl %edi,%eax
-- decl %eax # End of string
-- movl %edx,%edi # Restore
-- ret
--.strend_end:
-- .size strend,.strend_end-strend
--
-- # Make a string with len fill-chars and endnull
-- # Args: dest,len,fill
-- # Ret: dest+len
--
--.globl strfill
-- .type strfill,@function
--strfill:
-- pushl %edi
-- movl 8(%esp),%edi # Memory pointer
-- movl 12(%esp),%ecx # Length
-- movzb 16(%esp),%eax # Fill
--
-- movb %al,%ah # (2) Set up a 32 bit pattern
-- movw %ax,%dx # (2)
-- shll $16,%eax # (3)
-- movw %dx,%ax # (2) %eax has the 32 bit pattern.
--
-- movl %ecx,%edx # (2) Save the count of bytes.
-- shrl $2,%ecx # (2) Number of dwords.
-- rep
-- stosl # (5 + 5n)
-- movb $3,%cl # (2)
-- and %edx,%ecx # (2) Fill in the odd bytes
-- rep
-- stosb # Move last bytes if any
--
-- movb %cl,(%edi) # End NULL
-- movl %edi,%eax # End i %eax
-- popl %edi
-- ret
--.strfill_end:
-- .size strfill,.strfill_end-strfill
--
--
-- # Find a char in or end of a string
-- # Arg: str,char
-- # Ret: pointer to found char or NullS
--
--.globl strcend
-- .type strcend,@function
--strcend:
-- movl %edi,%edx
-- movl 4(%esp),%edi # str
-- movb 8(%esp),%ah # search
-- clrb %al # for scasb to find end
--
--se_10: cmpb (%edi),%ah
-- jz se_20 # Found char
-- scasb
-- jnz se_10 # Not end
-- dec %edi # Not found, point at end of string
--se_20: movl %edi,%eax
-- movl %edx,%edi # Restore
-- ret
--.strcend_end:
-- .size strcend,.strcend_end-strcend
--
-- # Test if string has a given suffix
--
--.globl is_prefix
-- .type is_prefix,@function
--is_prefix:
-- movl %edi,%edx # Save %edi
-- pushl %esi # and %esi
-- movl 12(%esp),%esi # get suffix
-- movl 8(%esp),%edi # s1
-- movl $1,%eax # Ok and zero-test
--ip_10: cmpb (%esi),%ah
-- jz suf_ok # End of string/ found suffix
-- cmpsb # Compare strings
-- jz ip_10 # Same, possible prefix
-- xor %eax,%eax # Not suffix
--suf_ok: popl %esi
-- movl %edx,%edi
-- ret
--.is_prefix_end:
-- .size is_prefix,.is_prefix_end-is_prefix
--
-- # Find a substring in string
-- # Arg: str,search
--
--.globl strstr
-- .type strstr,@function
--
--strstr:
-- pushl %edi
-- pushl %esi
-- movl 12(%esp),%esi # str
-- movl 16(%esp),%edi # search
-- movl %edi,%ecx
-- incl %ecx # %ecx = search+1
-- movb (%edi),%ah # %ah = First char in search
-- jmp sf_10
--
--sf_00: movl %edx,%esi # si = Current str-pos
--sf_10: movb (%esi),%al # Test if this char exist
-- andb %al,%al
-- jz sf_90 # End of string, didn't find search
-- incl %esi
-- cmpb %al,%ah
-- jnz sf_10 # Didn't find first char, continue
-- movl %esi,%edx # Save str-pos in %edx
-- movl %ecx,%edi
--sf_20: cmpb $0,(%edi)
-- jz sf_fo # Found substring
-- cmpsb
-- jz sf_20 # Char ok
-- jmp sf_00 # Next str-pos
--
--sf_90: movl $1,%edx # Return Null
--sf_fo: movl %edx,%eax # Char found here
-- decl %eax # Pointed one after
-- popl %esi
-- popl %edi
-- ret
--.strstr_end:
-- .size strstr,.strstr_end-strstr
--
--
-- # Find a substring in string, return index
-- # Arg: str,search
--
--.globl strinstr
-- .type strinstr,@function
--
--strinstr:
-- pushl %ebp
-- movl %esp,%ebp
-- pushl 12(%ebp) # search
-- pushl 8(%ebp) # str
-- call strstr
-- add $8,%esp
-- or %eax,%eax
-- jz si_99 # Not found, return NULL
-- sub 8(%ebp),%eax # Pos from start
-- inc %eax # And first pos = 1
--si_99: popl %ebp
-- ret
--.strinstr_end:
-- .size strinstr,.strinstr_end-strinstr
--
-- # Make a string of len length from another string
-- # Arg: dst,src,length
-- # ret: end of dst
--
--.globl strmake
-- .type strmake,@function
--
--strmake:
-- pushl %edi
-- pushl %esi
-- mov 12(%esp),%edi # dst
-- movl $0,%edx
-- movl 20(%esp),%ecx # length
-- movl 16(%esp),%esi # src
-- cmpl %edx,%ecx
-- jz sm_90
--sm_00: movb (%esi,%edx),%al
-- cmpb $0,%al
-- jz sm_90
-- movb %al,(%edi,%edx)
-- incl %edx
-- cmpl %edx,%ecx
-- jnz sm_00
--sm_90: movb $0,(%edi,%edx)
--sm_99: lea (%edi,%edx),%eax # Return pointer to end null
-- pop %esi
-- pop %edi
-- ret
--.strmake_end:
-- .size strmake,.strmake_end-strmake
--
-- # Move a string with max len chars
-- # arg: dst,src,len
-- # ret: pos to first null or dst+len
--
--.globl strnmov
-- .type strnmov,@function
--strnmov:
-- pushl %edi
-- pushl %esi
-- movl 12(%esp),%edi # dst
-- movl 16(%esp),%esi # src
-- movl 20(%esp),%ecx # Length of memory-area
-- jecxz snm_99 # Nothing to do
-- clrb %al # For test of end-null
--
--snm_10: cmpb (%esi),%al # Next char to move
-- movsb # move arg
-- jz snm_20 # last char, fill with null
-- loop snm_10 # Continue moving
-- incl %edi # Point two after last
--snm_20: decl %edi # Point at first null (or last+1)
--snm_99: movl %edi,%eax # Pointer at last char
-- popl %esi
-- popl %edi
-- ret
--.strnmov_end:
-- .size strnmov,.strnmov_end-strnmov
--
--
--.globl strmov
-- .type strmov,@function
--strmov:
-- movl %esi,%ecx # Save old %esi and %edi
-- movl %edi,%edx
-- movl 8(%esp),%esi # get source pointer (s2)
-- movl 4(%esp),%edi # %edi -> s1
--smo_10: movb (%esi),%al
-- movsb # move arg
-- andb %al,%al
-- jnz smo_10 # Not last
-- movl %edi,%eax
-- dec %eax
-- movl %ecx,%esi # Restore
-- movl %edx,%edi
-- ret
--.strmov_end:
-- .size strmov,.strmov_end-strmov
--
--.globl strxmov
-- .type strxmov,@function
--strxmov:
-- movl %ebx,%edx # Save %ebx, %esi and %edi
-- mov %esi,%ecx
-- push %edi
-- leal 8(%esp),%ebx # Get destination
-- movl (%ebx),%edi
-- xorb %al,%al
-- jmp next_str # Handle source ebx+4
--
--start_str:
-- movsb
-- cmpb -1(%edi),%al
-- jne start_str
-- decl %edi # Don't copy last null
--
--next_str:
-- addl $4,%ebx
-- movl (%ebx),%esi
-- orl %esi,%esi
-- jne start_str
-- movb %al,0(%edi) # Force last to ASCII 0
--
-- movl %edi,%eax # Return ptr to ASCII 0
-- pop %edi # Restore registers
-- movl %ecx,%esi
-- movl %edx,%ebx
-- ret
--.strxmov_end:
-- .size strxmov,.strxmov_end-strxmov
diff --git a/07340_all_mysql_hardened_x86_strings.patch b/07340_all_mysql_hardened_x86_strings.patch
deleted file mode 100644
index df0235d..0000000
--- a/07340_all_mysql_hardened_x86_strings.patch
+++ /dev/null
@@ -1,424 +0,0 @@
-As part of fixing the TEXTRELs, we must remove this file seperately because
-applying a move of .s -> .S on a case-insensitive file-system will cause patch
-to break.
-
-diff -urN a/strings/strings-x86.s b/strings/strings-x86.s
---- a/strings/strings-x86.s 2010-11-09 21:29:32.192000076 +0100
-+++ b/strings/strings-x86.s 1970-01-01 01:00:00.000000000 +0100
-@@ -1,416 +0,0 @@
--# Copyright (C) 2000 MySQL AB
--# 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
--
--# Optimized string functions Intel 80x86 (gcc/gas syntax)
--
-- .file "strings.s"
-- .version "1.00"
--
--.text
--
--# Move a alligned, not overlapped, by (long) divided memory area
--# Args: to,from,length
--
--.globl bmove_align
-- .type bmove_align,@function
--bmove_align:
-- movl %edi,%edx
-- push %esi
-- movl 4(%esp),%edi # to
-- movl 8(%esp),%esi # from
-- movl 12(%esp),%ecx # length
-- addw $3,%cx # fix if not divisible with long
-- shrw $2,%cx
-- jz .ba_20
-- .p2align 4,,7
--.ba_10:
-- movl -4(%esi,%ecx),%eax
-- movl %eax,-4(%edi,%ecx)
-- decl %ecx
-- jnz .ba_10
--.ba_20: pop %esi
-- movl %edx,%edi
-- ret
--
--.bmove_align_end:
-- .size bmove_align,.bmove_align_end-bmove_align
--
-- # Move a string from higher to lower
-- # Arg from_end+1,to_end+1,length
--
--.globl bmove_upp
-- .type bmove_upp,@function
--bmove_upp:
-- movl %edi,%edx # Remember %edi
-- push %esi
-- movl 8(%esp),%edi # dst
-- movl 16(%esp),%ecx # length
-- movl 12(%esp),%esi # source
-- test %ecx,%ecx
-- jz .bu_20
-- subl %ecx,%esi # To start of strings
-- subl %ecx,%edi
--
-- .p2align 4,,7
--.bu_10: movb -1(%esi,%ecx),%al
-- movb %al,-1(%edi,%ecx)
-- decl %ecx
-- jnz .bu_10
--.bu_20: pop %esi
-- movl %edx,%edi
-- ret
--
--.bmove_upp_end:
-- .size bmove_upp,.bmove_upp_end-bmove_upp
--
-- # Append fillchars to string
-- # Args: dest,len,fill
--
--.globl strappend
-- .type strappend,@function
--strappend:
-- pushl %edi
-- movl 8(%esp),%edi # Memory pointer
-- movl 12(%esp),%ecx # Length
-- clrl %eax # Find end of string
-- repne
-- scasb
-- jnz sa_99 # String to long, shorten it
-- movzb 16(%esp),%eax # Fillchar
-- decl %edi # Point at end null
-- incl %ecx # rep made one dec for null-char
--
-- movb %al,%ah # (2) Set up a 32 bit pattern.
-- movw %ax,%dx # (2)
-- shll $16,%eax # (3)
-- movw %dx,%ax # (2) %eax has the 32 bit pattern.
--
-- movl %ecx,%edx # (2) Save the count of bytes.
-- shrl $2,%ecx # (2) Number of dwords.
-- rep
-- stosl # (5 + 5n)
-- movb $3,%cl # (2)
-- and %edx,%ecx # (2) Fill in the odd bytes
-- rep
-- stosb # Move last bytes if any
--
--sa_99: movb $0,(%edi) # End of string
-- popl %edi
-- ret
--.strappend_end:
-- .size strappend,.strappend_end-strappend
--
-- # Find if string contains any char in another string
-- # Arg: str,set
-- # Ret: Pointer to first found char in str
--
--.globl strcont
-- .type strcont,@function
--strcont:
-- movl %edi,%edx
-- pushl %esi
-- movl 8(%esp),%esi # str
-- movl 12(%esp),%ecx # set
-- clrb %ah # For endtest
-- jmp sc_60
--
--sc_10: scasb
-- jz sc_fo # Found char
--sc_20: cmp (%edi),%ah # Test if null
-- jnz sc_10 # Not end of set yet
-- incl %esi # Next char in str
--sc_60: movl %ecx,%edi # %edi = Set
-- movb (%esi),%al # Test if this char exist
-- andb %al,%al
-- jnz sc_20 # Not end of string
-- clrl %esi # Return Null
--sc_fo: movl %esi,%eax # Char found here
-- movl %edx,%edi # Restore
-- popl %esi
-- ret
--.strcont_end:
-- .size strcont,.strcont_end-strcont
--
-- # Find end of string
-- # Arg: str
-- # ret: Pointer to end null
--
--.globl strend
-- .type strend,@function
--strend:
-- movl %edi,%edx # Save
-- movl 4(%esp),%edi # str
-- clrl %eax # Find end of string
-- movl %eax,%ecx
-- decl %ecx # ECX = -1
-- repne
-- scasb
-- movl %edi,%eax
-- decl %eax # End of string
-- movl %edx,%edi # Restore
-- ret
--.strend_end:
-- .size strend,.strend_end-strend
--
-- # Make a string with len fill-chars and endnull
-- # Args: dest,len,fill
-- # Ret: dest+len
--
--.globl strfill
-- .type strfill,@function
--strfill:
-- pushl %edi
-- movl 8(%esp),%edi # Memory pointer
-- movl 12(%esp),%ecx # Length
-- movzb 16(%esp),%eax # Fill
--
-- movb %al,%ah # (2) Set up a 32 bit pattern
-- movw %ax,%dx # (2)
-- shll $16,%eax # (3)
-- movw %dx,%ax # (2) %eax has the 32 bit pattern.
--
-- movl %ecx,%edx # (2) Save the count of bytes.
-- shrl $2,%ecx # (2) Number of dwords.
-- rep
-- stosl # (5 + 5n)
-- movb $3,%cl # (2)
-- and %edx,%ecx # (2) Fill in the odd bytes
-- rep
-- stosb # Move last bytes if any
--
-- movb %cl,(%edi) # End NULL
-- movl %edi,%eax # End i %eax
-- popl %edi
-- ret
--.strfill_end:
-- .size strfill,.strfill_end-strfill
--
--
-- # Find a char in or end of a string
-- # Arg: str,char
-- # Ret: pointer to found char or NullS
--
--.globl strcend
-- .type strcend,@function
--strcend:
-- movl %edi,%edx
-- movl 4(%esp),%edi # str
-- movb 8(%esp),%ah # search
-- clrb %al # for scasb to find end
--
--se_10: cmpb (%edi),%ah
-- jz se_20 # Found char
-- scasb
-- jnz se_10 # Not end
-- dec %edi # Not found, point at end of string
--se_20: movl %edi,%eax
-- movl %edx,%edi # Restore
-- ret
--.strcend_end:
-- .size strcend,.strcend_end-strcend
--
-- # Test if string has a given suffix
--
--.globl is_prefix
-- .type is_prefix,@function
--is_prefix:
-- movl %edi,%edx # Save %edi
-- pushl %esi # and %esi
-- movl 12(%esp),%esi # get suffix
-- movl 8(%esp),%edi # s1
-- movl $1,%eax # Ok and zero-test
--ip_10: cmpb (%esi),%ah
-- jz suf_ok # End of string/ found suffix
-- cmpsb # Compare strings
-- jz ip_10 # Same, possible prefix
-- xor %eax,%eax # Not suffix
--suf_ok: popl %esi
-- movl %edx,%edi
-- ret
--.is_prefix_end:
-- .size is_prefix,.is_prefix_end-is_prefix
--
-- # Find a substring in string
-- # Arg: str,search
--
--.globl strstr
-- .type strstr,@function
--
--strstr:
-- pushl %edi
-- pushl %esi
-- movl 12(%esp),%esi # str
-- movl 16(%esp),%edi # search
-- movl %edi,%ecx
-- incl %ecx # %ecx = search+1
-- movb (%edi),%ah # %ah = First char in search
-- jmp sf_10
--
--sf_00: movl %edx,%esi # si = Current str-pos
--sf_10: movb (%esi),%al # Test if this char exist
-- andb %al,%al
-- jz sf_90 # End of string, didn't find search
-- incl %esi
-- cmpb %al,%ah
-- jnz sf_10 # Didn't find first char, continue
-- movl %esi,%edx # Save str-pos in %edx
-- movl %ecx,%edi
--sf_20: cmpb $0,(%edi)
-- jz sf_fo # Found substring
-- cmpsb
-- jz sf_20 # Char ok
-- jmp sf_00 # Next str-pos
--
--sf_90: movl $1,%edx # Return Null
--sf_fo: movl %edx,%eax # Char found here
-- decl %eax # Pointed one after
-- popl %esi
-- popl %edi
-- ret
--.strstr_end:
-- .size strstr,.strstr_end-strstr
--
--
-- # Find a substring in string, return index
-- # Arg: str,search
--
--.globl strinstr
-- .type strinstr,@function
--
--strinstr:
-- pushl %ebp
-- movl %esp,%ebp
-- pushl 12(%ebp) # search
-- pushl 8(%ebp) # str
-- call strstr
-- add $8,%esp
-- or %eax,%eax
-- jz si_99 # Not found, return NULL
-- sub 8(%ebp),%eax # Pos from start
-- inc %eax # And first pos = 1
--si_99: popl %ebp
-- ret
--.strinstr_end:
-- .size strinstr,.strinstr_end-strinstr
--
-- # Make a string of len length from another string
-- # Arg: dst,src,length
-- # ret: end of dst
--
--.globl strmake
-- .type strmake,@function
--
--strmake:
-- pushl %edi
-- pushl %esi
-- mov 12(%esp),%edi # dst
-- movl $0,%edx
-- movl 20(%esp),%ecx # length
-- movl 16(%esp),%esi # src
-- cmpl %edx,%ecx
-- jz sm_90
--sm_00: movb (%esi,%edx),%al
-- cmpb $0,%al
-- jz sm_90
-- movb %al,(%edi,%edx)
-- incl %edx
-- cmpl %edx,%ecx
-- jnz sm_00
--sm_90: movb $0,(%edi,%edx)
--sm_99: lea (%edi,%edx),%eax # Return pointer to end null
-- pop %esi
-- pop %edi
-- ret
--.strmake_end:
-- .size strmake,.strmake_end-strmake
--
-- # Move a string with max len chars
-- # arg: dst,src,len
-- # ret: pos to first null or dst+len
--
--.globl strnmov
-- .type strnmov,@function
--strnmov:
-- pushl %edi
-- pushl %esi
-- movl 12(%esp),%edi # dst
-- movl 16(%esp),%esi # src
-- movl 20(%esp),%ecx # Length of memory-area
-- jecxz snm_99 # Nothing to do
-- clrb %al # For test of end-null
--
--snm_10: cmpb (%esi),%al # Next char to move
-- movsb # move arg
-- jz snm_20 # last char, fill with null
-- loop snm_10 # Continue moving
-- incl %edi # Point two after last
--snm_20: decl %edi # Point at first null (or last+1)
--snm_99: movl %edi,%eax # Pointer at last char
-- popl %esi
-- popl %edi
-- ret
--.strnmov_end:
-- .size strnmov,.strnmov_end-strnmov
--
--
--.globl strmov
-- .type strmov,@function
--strmov:
-- movl %esi,%ecx # Save old %esi and %edi
-- movl %edi,%edx
-- movl 8(%esp),%esi # get source pointer (s2)
-- movl 4(%esp),%edi # %edi -> s1
--smo_10: movb (%esi),%al
-- movsb # move arg
-- andb %al,%al
-- jnz smo_10 # Not last
-- movl %edi,%eax
-- dec %eax
-- movl %ecx,%esi # Restore
-- movl %edx,%edi
-- ret
--.strmov_end:
-- .size strmov,.strmov_end-strmov
--
--.globl strxmov
-- .type strxmov,@function
--strxmov:
-- movl %ebx,%edx # Save %ebx, %esi and %edi
-- mov %esi,%ecx
-- push %edi
-- leal 8(%esp),%ebx # Get destination
-- movl (%ebx),%edi
-- xorb %al,%al
-- jmp next_str # Handle source ebx+4
--
--start_str:
-- movsb
-- cmpb -1(%edi),%al
-- jne start_str
-- decl %edi # Don't copy last null
--
--next_str:
-- addl $4,%ebx
-- movl (%ebx),%esi
-- orl %esi,%esi
-- jne start_str
-- movb %al,0(%edi) # Force last to ASCII 0
--
-- movl %edi,%eax # Return ptr to ASCII 0
-- pop %edi # Restore registers
-- movl %ecx,%esi
-- movl %edx,%ebx
-- ret
--.strxmov_end:
-- .size strxmov,.strxmov_end-strxmov
diff --git a/07341_all_mariadb_hardened_x86_strings.patch b/07341_all_mariadb_hardened_x86_strings.patch
deleted file mode 100644
index 7e86f7f..0000000
--- a/07341_all_mariadb_hardened_x86_strings.patch
+++ /dev/null
@@ -1,517 +0,0 @@
-2010-11-10 Magnus Granberg <zorry@gento.org>, Francisco Blas Izquierdo Riera <franxisco1988@mixmail.com>
-
- #344031
- * configure.in: Rename strings-x86.s to strings-x86.S
- * strings/Makefile.am Likewise.
- * strings/Makefile.in Likewise.
- * strings/strings-x86.S Copy of strings-x86.s to support -fPIC
-
-diff -urN a/configure.in b/configure.in
---- a/configure.in 2010-11-10 00:23:45.287000082 +0100
-+++ b/configure.in 2010-11-10 00:30:47.681000059 +0100
-@@ -698,7 +698,7 @@
-
- AC_MSG_CHECKING(if we should use assembler functions)
- # For now we only support assembler on i386 and sparc systems
--AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $CCAS $CCASFLAGS -c strings/strings-x86.s -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
-+AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $CCAS $CCASFLAGS -c strings/strings-x86.S -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
- AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
- AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9")
- AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "")
-diff -urN a/strings/Makefile.am b/strings/Makefile.am
---- a/strings/Makefile.am 2010-11-10 00:23:45.421000083 +0100
-+++ b/strings/Makefile.am 2010-11-10 00:31:23.489000090 +0100
-@@ -20,7 +20,7 @@
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
--ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-+ASRCS = strings-x86.S longlong2str-x86.s my_strtoll10-x86.s
- CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov.c strmov_overlapp.c
- else
- if ASSEMBLER_sparc32
-@@ -44,7 +44,7 @@
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
- ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c \
- ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c \
-- xml.c decimal.c strto.c strings-x86.s \
-+ xml.c decimal.c strto.c strings-x86.S \
- longlong2str.c longlong2str-x86.s longlong2str_asm.c \
- my_strtoll10.c my_strtoll10-x86.s \
- strxmov.c bmove_upp.c strappend.c strcont.c strend.c \
-diff -urN a/strings/Makefile.in b/strings/Makefile.in
---- a/strings/Makefile.in 2010-11-10 00:23:45.423000082 +0100
-+++ b/strings/Makefile.in 2010-11-10 00:29:17.547000090 +0100
-@@ -104,7 +104,7 @@
- libmystrings_la_DEPENDENCIES =
- am__libmystrings_la_SOURCES_DIST = bmove_upp-sparc.s strappend-sparc.s \
- strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
-- strnmov-sparc.s strstr-sparc.s strings-x86.s \
-+ strnmov-sparc.s strstr-sparc.s strings-x86.S \
- longlong2str-x86.s my_strtoll10-x86.s strxmov.c bmove_upp.c \
- strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c \
- strstr.c strinstr.c strmake.c strnmov.c strmov.c \
-@@ -637,7 +637,7 @@
- @ASSEMBLER_sparc32_TRUE@@ASSEMBLER_x86_FALSE@ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
-
- # Exact one of ASSEMBLER_X
--@ASSEMBLER_x86_TRUE@ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-+@ASSEMBLER_x86_TRUE@ASRCS = strings-x86.S longlong2str-x86.s my_strtoll10-x86.s
- # These file MUST all be on the same line!! Otherwise automake
- # generats a very broken makefile
- @ASSEMBLER_sparc32_FALSE@@ASSEMBLER_x86_FALSE@CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c strmov_overlapp.c
-@@ -649,7 +649,7 @@
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
- ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c \
- ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c \
-- xml.c decimal.c strto.c strings-x86.s \
-+ xml.c decimal.c strto.c strings-x86.S \
- longlong2str.c longlong2str-x86.s longlong2str_asm.c \
- my_strtoll10.c my_strtoll10-x86.s \
- strxmov.c bmove_upp.c strappend.c strcont.c strend.c \
-diff -urN a/strings/strings-x86.S b/strings/strings-x86.S
---- a/strings/strings-x86.S 1970-01-01 01:00:00.000000000 +0100
-+++ b/strings/strings-x86.S 2010-11-10 00:29:17.547000090 +0100
-@@ -0,0 +1,442 @@
-+# Copyright (C) 2000 MySQL AB
-+# 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
-+
-+# Optimized string functions Intel 80x86 (gcc/gas syntax)
-+
-+ .file "strings.S"
-+ .version "1.01"
-+
-+.text
-+
-+# Move a alligned, not overlapped, by (long) divided memory area
-+# Args: to,from,length
-+
-+.globl bmove_align
-+ .type bmove_align,@function
-+bmove_align:
-+ movl %edi,%edx
-+ push %esi
-+ movl 4(%esp),%edi # to
-+ movl 8(%esp),%esi # from
-+ movl 12(%esp),%ecx # length
-+ addw $3,%cx # fix if not divisible with long
-+ shrw $2,%cx
-+ jz .ba_20
-+ .p2align 4,,7
-+.ba_10:
-+ movl -4(%esi,%ecx),%eax
-+ movl %eax,-4(%edi,%ecx)
-+ decl %ecx
-+ jnz .ba_10
-+.ba_20: pop %esi
-+ movl %edx,%edi
-+ ret
-+
-+.bmove_align_end:
-+ .size bmove_align,.bmove_align_end-bmove_align
-+
-+ # Move a string from higher to lower
-+ # Arg from_end+1,to_end+1,length
-+
-+.globl bmove_upp
-+ .type bmove_upp,@function
-+bmove_upp:
-+ movl %edi,%edx # Remember %edi
-+ push %esi
-+ movl 8(%esp),%edi # dst
-+ movl 16(%esp),%ecx # length
-+ movl 12(%esp),%esi # source
-+ test %ecx,%ecx
-+ jz .bu_20
-+ subl %ecx,%esi # To start of strings
-+ subl %ecx,%edi
-+
-+ .p2align 4,,7
-+.bu_10: movb -1(%esi,%ecx),%al
-+ movb %al,-1(%edi,%ecx)
-+ decl %ecx
-+ jnz .bu_10
-+.bu_20: pop %esi
-+ movl %edx,%edi
-+ ret
-+
-+.bmove_upp_end:
-+ .size bmove_upp,.bmove_upp_end-bmove_upp
-+
-+ # Append fillchars to string
-+ # Args: dest,len,fill
-+
-+.globl strappend
-+ .type strappend,@function
-+strappend:
-+ pushl %edi
-+ movl 8(%esp),%edi # Memory pointer
-+ movl 12(%esp),%ecx # Length
-+ clrl %eax # Find end of string
-+ repne
-+ scasb
-+ jnz sa_99 # String to long, shorten it
-+ movzb 16(%esp),%eax # Fillchar
-+ decl %edi # Point at end null
-+ incl %ecx # rep made one dec for null-char
-+
-+ movb %al,%ah # (2) Set up a 32 bit pattern.
-+ movw %ax,%dx # (2)
-+ shll $16,%eax # (3)
-+ movw %dx,%ax # (2) %eax has the 32 bit pattern.
-+
-+ movl %ecx,%edx # (2) Save the count of bytes.
-+ shrl $2,%ecx # (2) Number of dwords.
-+ rep
-+ stosl # (5 + 5n)
-+ movb $3,%cl # (2)
-+ and %edx,%ecx # (2) Fill in the odd bytes
-+ rep
-+ stosb # Move last bytes if any
-+
-+sa_99: movb $0,(%edi) # End of string
-+ popl %edi
-+ ret
-+.strappend_end:
-+ .size strappend,.strappend_end-strappend
-+
-+ # Find if string contains any char in another string
-+ # Arg: str,set
-+ # Ret: Pointer to first found char in str
-+
-+.globl strcont
-+ .type strcont,@function
-+strcont:
-+ movl %edi,%edx
-+ pushl %esi
-+ movl 8(%esp),%esi # str
-+ movl 12(%esp),%ecx # set
-+ clrb %ah # For endtest
-+ jmp sc_60
-+
-+sc_10: scasb
-+ jz sc_fo # Found char
-+sc_20: cmp (%edi),%ah # Test if null
-+ jnz sc_10 # Not end of set yet
-+ incl %esi # Next char in str
-+sc_60: movl %ecx,%edi # %edi = Set
-+ movb (%esi),%al # Test if this char exist
-+ andb %al,%al
-+ jnz sc_20 # Not end of string
-+ clrl %esi # Return Null
-+sc_fo: movl %esi,%eax # Char found here
-+ movl %edx,%edi # Restore
-+ popl %esi
-+ ret
-+.strcont_end:
-+ .size strcont,.strcont_end-strcont
-+
-+ # Find end of string
-+ # Arg: str
-+ # ret: Pointer to end null
-+
-+.globl strend
-+ .type strend,@function
-+strend:
-+ movl %edi,%edx # Save
-+ movl 4(%esp),%edi # str
-+ clrl %eax # Find end of string
-+ movl %eax,%ecx
-+ decl %ecx # ECX = -1
-+ repne
-+ scasb
-+ movl %edi,%eax
-+ decl %eax # End of string
-+ movl %edx,%edi # Restore
-+ ret
-+.strend_end:
-+ .size strend,.strend_end-strend
-+
-+ # Make a string with len fill-chars and endnull
-+ # Args: dest,len,fill
-+ # Ret: dest+len
-+
-+.globl strfill
-+ .type strfill,@function
-+strfill:
-+ pushl %edi
-+ movl 8(%esp),%edi # Memory pointer
-+ movl 12(%esp),%ecx # Length
-+ movzb 16(%esp),%eax # Fill
-+
-+ movb %al,%ah # (2) Set up a 32 bit pattern
-+ movw %ax,%dx # (2)
-+ shll $16,%eax # (3)
-+ movw %dx,%ax # (2) %eax has the 32 bit pattern.
-+
-+ movl %ecx,%edx # (2) Save the count of bytes.
-+ shrl $2,%ecx # (2) Number of dwords.
-+ rep
-+ stosl # (5 + 5n)
-+ movb $3,%cl # (2)
-+ and %edx,%ecx # (2) Fill in the odd bytes
-+ rep
-+ stosb # Move last bytes if any
-+
-+ movb %cl,(%edi) # End NULL
-+ movl %edi,%eax # End i %eax
-+ popl %edi
-+ ret
-+.strfill_end:
-+ .size strfill,.strfill_end-strfill
-+
-+
-+ # Find a char in or end of a string
-+ # Arg: str,char
-+ # Ret: pointer to found char or NullS
-+
-+.globl strcend
-+ .type strcend,@function
-+strcend:
-+ movl %edi,%edx
-+ movl 4(%esp),%edi # str
-+ movb 8(%esp),%ah # search
-+ clrb %al # for scasb to find end
-+
-+se_10: cmpb (%edi),%ah
-+ jz se_20 # Found char
-+ scasb
-+ jnz se_10 # Not end
-+ dec %edi # Not found, point at end of string
-+se_20: movl %edi,%eax
-+ movl %edx,%edi # Restore
-+ ret
-+.strcend_end:
-+ .size strcend,.strcend_end-strcend
-+
-+ # Test if string has a given suffix
-+
-+.globl is_prefix
-+ .type is_prefix,@function
-+is_prefix:
-+ movl %edi,%edx # Save %edi
-+ pushl %esi # and %esi
-+ movl 12(%esp),%esi # get suffix
-+ movl 8(%esp),%edi # s1
-+ movl $1,%eax # Ok and zero-test
-+ip_10: cmpb (%esi),%ah
-+ jz suf_ok # End of string/ found suffix
-+ cmpsb # Compare strings
-+ jz ip_10 # Same, possible prefix
-+ xor %eax,%eax # Not suffix
-+suf_ok: popl %esi
-+ movl %edx,%edi
-+ ret
-+.is_prefix_end:
-+ .size is_prefix,.is_prefix_end-is_prefix
-+
-+ # Find a substring in string
-+ # Arg: str,search
-+
-+.globl strstr
-+ .type strstr,@function
-+
-+strstr:
-+ pushl %edi
-+ pushl %esi
-+ movl 12(%esp),%esi # str
-+ movl 16(%esp),%edi # search
-+ movl %edi,%ecx
-+ incl %ecx # %ecx = search+1
-+ movb (%edi),%ah # %ah = First char in search
-+ jmp sf_10
-+
-+sf_00: movl %edx,%esi # si = Current str-pos
-+sf_10: movb (%esi),%al # Test if this char exist
-+ andb %al,%al
-+ jz sf_90 # End of string, didn't find search
-+ incl %esi
-+ cmpb %al,%ah
-+ jnz sf_10 # Didn't find first char, continue
-+ movl %esi,%edx # Save str-pos in %edx
-+ movl %ecx,%edi
-+sf_20: cmpb $0,(%edi)
-+ jz sf_fo # Found substring
-+ cmpsb
-+ jz sf_20 # Char ok
-+ jmp sf_00 # Next str-pos
-+
-+sf_90: movl $1,%edx # Return Null
-+sf_fo: movl %edx,%eax # Char found here
-+ decl %eax # Pointed one after
-+ popl %esi
-+ popl %edi
-+ ret
-+.strstr_end:
-+ .size strstr,.strstr_end-strstr
-+
-+
-+ # Find a substring in string, return index
-+ # Arg: str,search
-+
-+.globl strinstr
-+ .type strinstr,@function
-+
-+strinstr:
-+ pushl %ebp
-+ movl %esp,%ebp
-+#ifdef __PIC__
-+# undef __i686 /* gcc define gets in our way */
-+ pushl %ebx
-+ call __i686.get_pc_thunk.bx
-+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
-+#endif
-+ pushl 12(%ebp) # search
-+ pushl 8(%ebp) # str
-+#ifdef __PIC__
-+ call strstr@PLT /*We need to be sure that ebx point to the got*/
-+#else
-+ call strstr
-+#endif
-+ add $8,%esp
-+ or %eax,%eax
-+ jz si_99 # Not found, return NULL
-+ sub 8(%ebp),%eax # Pos from start
-+ inc %eax # And first pos = 1
-+si_99:
-+#ifdef __PIC__
-+ popl %ebx
-+#endif
-+ popl %ebp
-+ ret
-+.strinstr_end:
-+ .size strinstr,.strinstr_end-strinstr
-+
-+ # Make a string of len length from another string
-+ # Arg: dst,src,length
-+ # ret: end of dst
-+
-+.globl strmake
-+ .type strmake,@function
-+
-+strmake:
-+ pushl %edi
-+ pushl %esi
-+ mov 12(%esp),%edi # dst
-+ movl $0,%edx
-+ movl 20(%esp),%ecx # length
-+ movl 16(%esp),%esi # src
-+ cmpl %edx,%ecx
-+ jz sm_90
-+sm_00: movb (%esi,%edx),%al
-+ cmpb $0,%al
-+ jz sm_90
-+ movb %al,(%edi,%edx)
-+ incl %edx
-+ cmpl %edx,%ecx
-+ jnz sm_00
-+sm_90: movb $0,(%edi,%edx)
-+sm_99: lea (%edi,%edx),%eax # Return pointer to end null
-+ pop %esi
-+ pop %edi
-+ ret
-+.strmake_end:
-+ .size strmake,.strmake_end-strmake
-+
-+ # Move a string with max len chars
-+ # arg: dst,src,len
-+ # ret: pos to first null or dst+len
-+
-+.globl strnmov
-+ .type strnmov,@function
-+strnmov:
-+ pushl %edi
-+ pushl %esi
-+ movl 12(%esp),%edi # dst
-+ movl 16(%esp),%esi # src
-+ movl 20(%esp),%ecx # Length of memory-area
-+ jecxz snm_99 # Nothing to do
-+ clrb %al # For test of end-null
-+
-+snm_10: cmpb (%esi),%al # Next char to move
-+ movsb # move arg
-+ jz snm_20 # last char, fill with null
-+ loop snm_10 # Continue moving
-+ incl %edi # Point two after last
-+snm_20: decl %edi # Point at first null (or last+1)
-+snm_99: movl %edi,%eax # Pointer at last char
-+ popl %esi
-+ popl %edi
-+ ret
-+.strnmov_end:
-+ .size strnmov,.strnmov_end-strnmov
-+
-+
-+.globl strmov
-+ .type strmov,@function
-+strmov:
-+ movl %esi,%ecx # Save old %esi and %edi
-+ movl %edi,%edx
-+ movl 8(%esp),%esi # get source pointer (s2)
-+ movl 4(%esp),%edi # %edi -> s1
-+smo_10: movb (%esi),%al
-+ movsb # move arg
-+ andb %al,%al
-+ jnz smo_10 # Not last
-+ movl %edi,%eax
-+ dec %eax
-+ movl %ecx,%esi # Restore
-+ movl %edx,%edi
-+ ret
-+.strmov_end:
-+ .size strmov,.strmov_end-strmov
-+
-+.globl strxmov
-+ .type strxmov,@function
-+strxmov:
-+ movl %ebx,%edx # Save %ebx, %esi and %edi
-+ mov %esi,%ecx
-+ push %edi
-+ leal 8(%esp),%ebx # Get destination
-+ movl (%ebx),%edi
-+ xorb %al,%al
-+ jmp next_str # Handle source ebx+4
-+
-+start_str:
-+ movsb
-+ cmpb -1(%edi),%al
-+ jne start_str
-+ decl %edi # Don't copy last null
-+
-+next_str:
-+ addl $4,%ebx
-+ movl (%ebx),%esi
-+ orl %esi,%esi
-+ jne start_str
-+ movb %al,0(%edi) # Force last to ASCII 0
-+
-+ movl %edi,%eax # Return ptr to ASCII 0
-+ pop %edi # Restore registers
-+ movl %ecx,%esi
-+ movl %edx,%ebx
-+ ret
-+.strxmov_end:
-+ .size strxmov,.strxmov_end-strxmov
-+
-+#ifdef __PIC__
-+ .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
-+ .globl __i686.get_pc_thunk.bx
-+ .hidden __i686.get_pc_thunk.bx
-+ .type __i686.get_pc_thunk.bx,@function
-+__i686.get_pc_thunk.bx:
-+ movl (%esp), %ebx
-+ ret
-+#endif
-+ .section .note.GNU-stack,"",@progbits
-+
diff --git a/07341_all_mysql_hardened_x86_strings.patch b/07341_all_mysql_hardened_x86_strings.patch
deleted file mode 100644
index f3afb26..0000000
--- a/07341_all_mysql_hardened_x86_strings.patch
+++ /dev/null
@@ -1,517 +0,0 @@
-2010-11-10 Magnus Granberg <zorry@gento.org>, Francisco Blas Izquierdo Riera <franxisco1988@mixmail.com>
-
- #344031
- * configure.in: Rename strings-x86.s to strings-x86.S
- * strings/Makefile.am Likewise.
- * strings/Makefile.in Likewise.
- * strings/strings-x86.S Copy of strings-x86.s to support -fPIC
-
-diff -urN a/configure.in b/configure.in
---- a/configure.in 2010-11-09 21:29:31.806000076 +0100
-+++ b/configure.in 2010-11-09 21:31:55.596000072 +0100
-@@ -673,7 +673,7 @@
-
- AC_MSG_CHECKING(if we should use assembler functions)
- # For now we only support assembler on i386 and sparc systems
--AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $AS strings/strings-x86.s -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
-+AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386" && $AS strings/strings-x86.S -o checkassembler >/dev/null 2>&1 && test -f checkassembler && (rm -f checkassembler; exit 0;))
- AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
- AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9")
- AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "")
-diff -urN a/strings/Makefile.am b/strings/Makefile.am
---- a/strings/Makefile.am 2010-11-09 21:29:32.195000076 +0100
-+++ b/strings/Makefile.am 2010-11-09 21:33:18.545000075 +0100
-@@ -20,7 +20,7 @@
-
- # Exact one of ASSEMBLER_X
- if ASSEMBLER_x86
--ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-+ASRCS = strings-x86.S longlong2str-x86.s my_strtoll10-x86.s
- CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c strmov.c
- else
- if ASSEMBLER_sparc32
-@@ -44,7 +44,7 @@
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
- ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c \
- ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c \
-- xml.c decimal.c strto.c strings-x86.s \
-+ xml.c decimal.c strto.c strings-x86.S \
- longlong2str.c longlong2str-x86.s longlong2str_asm.c \
- my_strtoll10.c my_strtoll10-x86.s \
- strxmov.c bmove_upp.c strappend.c strcont.c strend.c \
-diff -urN a/strings/Makefile.in b/strings/Makefile.in
---- a/strings/Makefile.in 2010-11-09 21:29:32.197000076 +0100
-+++ b/strings/Makefile.in 2010-11-09 21:33:45.348000075 +0100
-@@ -103,7 +103,7 @@
- libmystrings_la_DEPENDENCIES =
- am__libmystrings_la_SOURCES_DIST = bmove_upp-sparc.s strappend-sparc.s \
- strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
-- strnmov-sparc.s strstr-sparc.s strings-x86.s \
-+ strnmov-sparc.s strstr-sparc.s strings-x86.S \
- longlong2str-x86.s my_strtoll10-x86.s strxmov.c bmove_upp.c \
- strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c \
- strstr.c strinstr.c strmake.c strnmov.c strmov.c \
-@@ -621,7 +621,7 @@
- @ASSEMBLER_sparc32_TRUE@@ASSEMBLER_x86_FALSE@ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
-
- # Exact one of ASSEMBLER_X
--@ASSEMBLER_x86_TRUE@ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-+@ASSEMBLER_x86_TRUE@ASRCS = strings-x86.S longlong2str-x86.s my_strtoll10-x86.s
- # These file MUST all be on the same line!! Otherwise automake
- # generats a very broken makefile
- @ASSEMBLER_sparc32_FALSE@@ASSEMBLER_x86_FALSE@CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c
-@@ -633,7 +633,7 @@
- EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-win1250ch.c \
- ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-utf8.c \
- ctype-ucs2.c ctype-uca.c ctype-tis620.c ctype-ujis.c \
-- xml.c decimal.c strto.c strings-x86.s \
-+ xml.c decimal.c strto.c strings-x86.S \
- longlong2str.c longlong2str-x86.s longlong2str_asm.c \
- my_strtoll10.c my_strtoll10-x86.s \
- strxmov.c bmove_upp.c strappend.c strcont.c strend.c \
-diff -urN a/strings/strings-x86.S b/strings/strings-x86.S
---- a/strings/strings-x86.S 1970-01-01 01:00:00.000000000 +0100
-+++ b/strings/strings-x86.S 2010-11-09 22:05:05.084000076 +0100
-@@ -0,0 +1,442 @@
-+# Copyright (C) 2000 MySQL AB
-+# 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
-+
-+# Optimized string functions Intel 80x86 (gcc/gas syntax)
-+
-+ .file "strings.S"
-+ .version "1.01"
-+
-+.text
-+
-+# Move a alligned, not overlapped, by (long) divided memory area
-+# Args: to,from,length
-+
-+.globl bmove_align
-+ .type bmove_align,@function
-+bmove_align:
-+ movl %edi,%edx
-+ push %esi
-+ movl 4(%esp),%edi # to
-+ movl 8(%esp),%esi # from
-+ movl 12(%esp),%ecx # length
-+ addw $3,%cx # fix if not divisible with long
-+ shrw $2,%cx
-+ jz .ba_20
-+ .p2align 4,,7
-+.ba_10:
-+ movl -4(%esi,%ecx),%eax
-+ movl %eax,-4(%edi,%ecx)
-+ decl %ecx
-+ jnz .ba_10
-+.ba_20: pop %esi
-+ movl %edx,%edi
-+ ret
-+
-+.bmove_align_end:
-+ .size bmove_align,.bmove_align_end-bmove_align
-+
-+ # Move a string from higher to lower
-+ # Arg from_end+1,to_end+1,length
-+
-+.globl bmove_upp
-+ .type bmove_upp,@function
-+bmove_upp:
-+ movl %edi,%edx # Remember %edi
-+ push %esi
-+ movl 8(%esp),%edi # dst
-+ movl 16(%esp),%ecx # length
-+ movl 12(%esp),%esi # source
-+ test %ecx,%ecx
-+ jz .bu_20
-+ subl %ecx,%esi # To start of strings
-+ subl %ecx,%edi
-+
-+ .p2align 4,,7
-+.bu_10: movb -1(%esi,%ecx),%al
-+ movb %al,-1(%edi,%ecx)
-+ decl %ecx
-+ jnz .bu_10
-+.bu_20: pop %esi
-+ movl %edx,%edi
-+ ret
-+
-+.bmove_upp_end:
-+ .size bmove_upp,.bmove_upp_end-bmove_upp
-+
-+ # Append fillchars to string
-+ # Args: dest,len,fill
-+
-+.globl strappend
-+ .type strappend,@function
-+strappend:
-+ pushl %edi
-+ movl 8(%esp),%edi # Memory pointer
-+ movl 12(%esp),%ecx # Length
-+ clrl %eax # Find end of string
-+ repne
-+ scasb
-+ jnz sa_99 # String to long, shorten it
-+ movzb 16(%esp),%eax # Fillchar
-+ decl %edi # Point at end null
-+ incl %ecx # rep made one dec for null-char
-+
-+ movb %al,%ah # (2) Set up a 32 bit pattern.
-+ movw %ax,%dx # (2)
-+ shll $16,%eax # (3)
-+ movw %dx,%ax # (2) %eax has the 32 bit pattern.
-+
-+ movl %ecx,%edx # (2) Save the count of bytes.
-+ shrl $2,%ecx # (2) Number of dwords.
-+ rep
-+ stosl # (5 + 5n)
-+ movb $3,%cl # (2)
-+ and %edx,%ecx # (2) Fill in the odd bytes
-+ rep
-+ stosb # Move last bytes if any
-+
-+sa_99: movb $0,(%edi) # End of string
-+ popl %edi
-+ ret
-+.strappend_end:
-+ .size strappend,.strappend_end-strappend
-+
-+ # Find if string contains any char in another string
-+ # Arg: str,set
-+ # Ret: Pointer to first found char in str
-+
-+.globl strcont
-+ .type strcont,@function
-+strcont:
-+ movl %edi,%edx
-+ pushl %esi
-+ movl 8(%esp),%esi # str
-+ movl 12(%esp),%ecx # set
-+ clrb %ah # For endtest
-+ jmp sc_60
-+
-+sc_10: scasb
-+ jz sc_fo # Found char
-+sc_20: cmp (%edi),%ah # Test if null
-+ jnz sc_10 # Not end of set yet
-+ incl %esi # Next char in str
-+sc_60: movl %ecx,%edi # %edi = Set
-+ movb (%esi),%al # Test if this char exist
-+ andb %al,%al
-+ jnz sc_20 # Not end of string
-+ clrl %esi # Return Null
-+sc_fo: movl %esi,%eax # Char found here
-+ movl %edx,%edi # Restore
-+ popl %esi
-+ ret
-+.strcont_end:
-+ .size strcont,.strcont_end-strcont
-+
-+ # Find end of string
-+ # Arg: str
-+ # ret: Pointer to end null
-+
-+.globl strend
-+ .type strend,@function
-+strend:
-+ movl %edi,%edx # Save
-+ movl 4(%esp),%edi # str
-+ clrl %eax # Find end of string
-+ movl %eax,%ecx
-+ decl %ecx # ECX = -1
-+ repne
-+ scasb
-+ movl %edi,%eax
-+ decl %eax # End of string
-+ movl %edx,%edi # Restore
-+ ret
-+.strend_end:
-+ .size strend,.strend_end-strend
-+
-+ # Make a string with len fill-chars and endnull
-+ # Args: dest,len,fill
-+ # Ret: dest+len
-+
-+.globl strfill
-+ .type strfill,@function
-+strfill:
-+ pushl %edi
-+ movl 8(%esp),%edi # Memory pointer
-+ movl 12(%esp),%ecx # Length
-+ movzb 16(%esp),%eax # Fill
-+
-+ movb %al,%ah # (2) Set up a 32 bit pattern
-+ movw %ax,%dx # (2)
-+ shll $16,%eax # (3)
-+ movw %dx,%ax # (2) %eax has the 32 bit pattern.
-+
-+ movl %ecx,%edx # (2) Save the count of bytes.
-+ shrl $2,%ecx # (2) Number of dwords.
-+ rep
-+ stosl # (5 + 5n)
-+ movb $3,%cl # (2)
-+ and %edx,%ecx # (2) Fill in the odd bytes
-+ rep
-+ stosb # Move last bytes if any
-+
-+ movb %cl,(%edi) # End NULL
-+ movl %edi,%eax # End i %eax
-+ popl %edi
-+ ret
-+.strfill_end:
-+ .size strfill,.strfill_end-strfill
-+
-+
-+ # Find a char in or end of a string
-+ # Arg: str,char
-+ # Ret: pointer to found char or NullS
-+
-+.globl strcend
-+ .type strcend,@function
-+strcend:
-+ movl %edi,%edx
-+ movl 4(%esp),%edi # str
-+ movb 8(%esp),%ah # search
-+ clrb %al # for scasb to find end
-+
-+se_10: cmpb (%edi),%ah
-+ jz se_20 # Found char
-+ scasb
-+ jnz se_10 # Not end
-+ dec %edi # Not found, point at end of string
-+se_20: movl %edi,%eax
-+ movl %edx,%edi # Restore
-+ ret
-+.strcend_end:
-+ .size strcend,.strcend_end-strcend
-+
-+ # Test if string has a given suffix
-+
-+.globl is_prefix
-+ .type is_prefix,@function
-+is_prefix:
-+ movl %edi,%edx # Save %edi
-+ pushl %esi # and %esi
-+ movl 12(%esp),%esi # get suffix
-+ movl 8(%esp),%edi # s1
-+ movl $1,%eax # Ok and zero-test
-+ip_10: cmpb (%esi),%ah
-+ jz suf_ok # End of string/ found suffix
-+ cmpsb # Compare strings
-+ jz ip_10 # Same, possible prefix
-+ xor %eax,%eax # Not suffix
-+suf_ok: popl %esi
-+ movl %edx,%edi
-+ ret
-+.is_prefix_end:
-+ .size is_prefix,.is_prefix_end-is_prefix
-+
-+ # Find a substring in string
-+ # Arg: str,search
-+
-+.globl strstr
-+ .type strstr,@function
-+
-+strstr:
-+ pushl %edi
-+ pushl %esi
-+ movl 12(%esp),%esi # str
-+ movl 16(%esp),%edi # search
-+ movl %edi,%ecx
-+ incl %ecx # %ecx = search+1
-+ movb (%edi),%ah # %ah = First char in search
-+ jmp sf_10
-+
-+sf_00: movl %edx,%esi # si = Current str-pos
-+sf_10: movb (%esi),%al # Test if this char exist
-+ andb %al,%al
-+ jz sf_90 # End of string, didn't find search
-+ incl %esi
-+ cmpb %al,%ah
-+ jnz sf_10 # Didn't find first char, continue
-+ movl %esi,%edx # Save str-pos in %edx
-+ movl %ecx,%edi
-+sf_20: cmpb $0,(%edi)
-+ jz sf_fo # Found substring
-+ cmpsb
-+ jz sf_20 # Char ok
-+ jmp sf_00 # Next str-pos
-+
-+sf_90: movl $1,%edx # Return Null
-+sf_fo: movl %edx,%eax # Char found here
-+ decl %eax # Pointed one after
-+ popl %esi
-+ popl %edi
-+ ret
-+.strstr_end:
-+ .size strstr,.strstr_end-strstr
-+
-+
-+ # Find a substring in string, return index
-+ # Arg: str,search
-+
-+.globl strinstr
-+ .type strinstr,@function
-+
-+strinstr:
-+ pushl %ebp
-+ movl %esp,%ebp
-+#ifdef __PIC__
-+# undef __i686 /* gcc define gets in our way */
-+ pushl %ebx
-+ call __i686.get_pc_thunk.bx
-+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
-+#endif
-+ pushl 12(%ebp) # search
-+ pushl 8(%ebp) # str
-+#ifdef __PIC__
-+ call strstr@PLT /*We need to be sure that ebx point to the got*/
-+#else
-+ call strstr
-+#endif
-+ add $8,%esp
-+ or %eax,%eax
-+ jz si_99 # Not found, return NULL
-+ sub 8(%ebp),%eax # Pos from start
-+ inc %eax # And first pos = 1
-+si_99:
-+#ifdef __PIC__
-+ popl %ebx
-+#endif
-+ popl %ebp
-+ ret
-+.strinstr_end:
-+ .size strinstr,.strinstr_end-strinstr
-+
-+ # Make a string of len length from another string
-+ # Arg: dst,src,length
-+ # ret: end of dst
-+
-+.globl strmake
-+ .type strmake,@function
-+
-+strmake:
-+ pushl %edi
-+ pushl %esi
-+ mov 12(%esp),%edi # dst
-+ movl $0,%edx
-+ movl 20(%esp),%ecx # length
-+ movl 16(%esp),%esi # src
-+ cmpl %edx,%ecx
-+ jz sm_90
-+sm_00: movb (%esi,%edx),%al
-+ cmpb $0,%al
-+ jz sm_90
-+ movb %al,(%edi,%edx)
-+ incl %edx
-+ cmpl %edx,%ecx
-+ jnz sm_00
-+sm_90: movb $0,(%edi,%edx)
-+sm_99: lea (%edi,%edx),%eax # Return pointer to end null
-+ pop %esi
-+ pop %edi
-+ ret
-+.strmake_end:
-+ .size strmake,.strmake_end-strmake
-+
-+ # Move a string with max len chars
-+ # arg: dst,src,len
-+ # ret: pos to first null or dst+len
-+
-+.globl strnmov
-+ .type strnmov,@function
-+strnmov:
-+ pushl %edi
-+ pushl %esi
-+ movl 12(%esp),%edi # dst
-+ movl 16(%esp),%esi # src
-+ movl 20(%esp),%ecx # Length of memory-area
-+ jecxz snm_99 # Nothing to do
-+ clrb %al # For test of end-null
-+
-+snm_10: cmpb (%esi),%al # Next char to move
-+ movsb # move arg
-+ jz snm_20 # last char, fill with null
-+ loop snm_10 # Continue moving
-+ incl %edi # Point two after last
-+snm_20: decl %edi # Point at first null (or last+1)
-+snm_99: movl %edi,%eax # Pointer at last char
-+ popl %esi
-+ popl %edi
-+ ret
-+.strnmov_end:
-+ .size strnmov,.strnmov_end-strnmov
-+
-+
-+.globl strmov
-+ .type strmov,@function
-+strmov:
-+ movl %esi,%ecx # Save old %esi and %edi
-+ movl %edi,%edx
-+ movl 8(%esp),%esi # get source pointer (s2)
-+ movl 4(%esp),%edi # %edi -> s1
-+smo_10: movb (%esi),%al
-+ movsb # move arg
-+ andb %al,%al
-+ jnz smo_10 # Not last
-+ movl %edi,%eax
-+ dec %eax
-+ movl %ecx,%esi # Restore
-+ movl %edx,%edi
-+ ret
-+.strmov_end:
-+ .size strmov,.strmov_end-strmov
-+
-+.globl strxmov
-+ .type strxmov,@function
-+strxmov:
-+ movl %ebx,%edx # Save %ebx, %esi and %edi
-+ mov %esi,%ecx
-+ push %edi
-+ leal 8(%esp),%ebx # Get destination
-+ movl (%ebx),%edi
-+ xorb %al,%al
-+ jmp next_str # Handle source ebx+4
-+
-+start_str:
-+ movsb
-+ cmpb -1(%edi),%al
-+ jne start_str
-+ decl %edi # Don't copy last null
-+
-+next_str:
-+ addl $4,%ebx
-+ movl (%ebx),%esi
-+ orl %esi,%esi
-+ jne start_str
-+ movb %al,0(%edi) # Force last to ASCII 0
-+
-+ movl %edi,%eax # Return ptr to ASCII 0
-+ pop %edi # Restore registers
-+ movl %ecx,%esi
-+ movl %edx,%ebx
-+ ret
-+.strxmov_end:
-+ .size strxmov,.strxmov_end-strxmov
-+
-+#ifdef __PIC__
-+ .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
-+ .globl __i686.get_pc_thunk.bx
-+ .hidden __i686.get_pc_thunk.bx
-+ .type __i686.get_pc_thunk.bx,@function
-+__i686.get_pc_thunk.bx:
-+ movl (%esp), %ebx
-+ ret
-+#endif
-+ .section .note.GNU-stack,"",@progbits
-+
diff --git a/07342_all_mysql_auth_bypass-5.1.62.patch b/07342_all_mysql_auth_bypass-5.1.62.patch
deleted file mode 100644
index 63cecf1..0000000
--- a/07342_all_mysql_auth_bypass-5.1.62.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Security bug http://bugs.mysql.com/bug.php?id=64884
-Already fixed in MariaDB 5.1.62+/5.5.23+
-
-Depends on the result of check_scramble being cast to char directly.
-
-diff -Nuar mysql.orig/libmysql/password.c mysql/libmysql/password.c
---- mysql.orig/libmysql/password.c 2012-04-21 10:58:15.485424022 -0700
-+++ mysql/libmysql/password.c 2012-04-21 10:57:34.077773190 -0700
-@@ -531,7 +531,7 @@
- mysql_sha1_reset(&sha1_context);
- mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE);
- mysql_sha1_result(&sha1_context, hash_stage2_reassured);
-- return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE);
-+ return test(memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE));
- }
-
-
-diff -Nuar mysql.orig/sql/password.c mysql/sql/password.c
---- mysql.orig/sql/password.c 2012-04-21 10:58:18.941478337 -0700
-+++ mysql/sql/password.c 2012-04-21 10:57:50.318028470 -0700
-@@ -531,7 +531,7 @@
- mysql_sha1_reset(&sha1_context);
- mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE);
- mysql_sha1_result(&sha1_context, hash_stage2_reassured);
-- return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE);
-+ return test(memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE));
- }
-
-
diff --git a/10010_all_show_patches-percona-5.0.75-b12.patch b/10010_all_show_patches-percona-5.0.75-b12.patch
deleted file mode 120000
index 6d3e037..0000000
--- a/10010_all_show_patches-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/show_patches.patch \ No newline at end of file
diff --git a/10010_all_show_patches-percona-5.0.77-b13.patch b/10010_all_show_patches-percona-5.0.77-b13.patch
deleted file mode 120000
index bb48c02..0000000
--- a/10010_all_show_patches-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/show_patches.patch \ No newline at end of file
diff --git a/10010_all_show_patches-percona-5.0.83-b17-20090706.patch b/10010_all_show_patches-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 202fea4..0000000
--- a/10010_all_show_patches-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/show_patches.patch \ No newline at end of file
diff --git a/10010_all_show_patches-percona-5.0.84-b18-20090811.patch b/10010_all_show_patches-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index bf737a2..0000000
--- a/10010_all_show_patches-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/show_patches.patch \ No newline at end of file
diff --git a/10010_all_show_patches-percona-5.0.87-b20-20091116.patch b/10010_all_show_patches-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 813d5b5..0000000
--- a/10010_all_show_patches-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/show_patches.patch \ No newline at end of file
diff --git a/10020_all_microslow_innodb-percona-5.0.75-b12.patch b/10020_all_microslow_innodb-percona-5.0.75-b12.patch
deleted file mode 120000
index 33fed8a..0000000
--- a/10020_all_microslow_innodb-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/microslow_innodb.patch \ No newline at end of file
diff --git a/10020_all_microslow_innodb-percona-5.0.77-b13.patch b/10020_all_microslow_innodb-percona-5.0.77-b13.patch
deleted file mode 120000
index 261463b..0000000
--- a/10020_all_microslow_innodb-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/microslow_innodb.patch \ No newline at end of file
diff --git a/10020_all_microslow_innodb-percona-5.0.83-b17-20090706.patch b/10020_all_microslow_innodb-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 7c84b41..0000000
--- a/10020_all_microslow_innodb-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/microslow_innodb.patch \ No newline at end of file
diff --git a/10020_all_microslow_innodb-percona-5.0.84-b18-20090811.patch b/10020_all_microslow_innodb-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 9f4798e..0000000
--- a/10020_all_microslow_innodb-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/microslow_innodb.patch \ No newline at end of file
diff --git a/10020_all_microslow_innodb-percona-5.0.87-b20-20091116.patch b/10020_all_microslow_innodb-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index e8004b9..0000000
--- a/10020_all_microslow_innodb-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/microslow_innodb.patch \ No newline at end of file
diff --git a/10021_all_profiling_slow-percona-5.0.83-b17-20090706.patch b/10021_all_profiling_slow-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 039e4e4..0000000
--- a/10021_all_profiling_slow-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/profiling_slow.patch \ No newline at end of file
diff --git a/10021_all_profiling_slow-percona-5.0.84-b18-20090811.patch b/10021_all_profiling_slow-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 12c2607..0000000
--- a/10021_all_profiling_slow-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/profiling_slow.patch \ No newline at end of file
diff --git a/10021_all_profiling_slow-percona-5.0.87-b20-20091116.patch b/10021_all_profiling_slow-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 045f33b..0000000
--- a/10021_all_profiling_slow-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/profiling_slow.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.75-b12.patch b/10030_all_userstatv2-percona-5.0.75-b12.patch
deleted file mode 120000
index 3c8ddd7..0000000
--- a/10030_all_userstatv2-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/userstatv2.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.77-b13.patch b/10030_all_userstatv2-percona-5.0.77-b13.patch
deleted file mode 120000
index bd1cc69..0000000
--- a/10030_all_userstatv2-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/userstatv2.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.83-b17-20090706.patch b/10030_all_userstatv2-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 208ffe5..0000000
--- a/10030_all_userstatv2-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/userstatv2.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.84-b18-20090811.patch b/10030_all_userstatv2-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 4d66cce..0000000
--- a/10030_all_userstatv2-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/userstatv2.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.87-b20-20091116.patch b/10030_all_userstatv2-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index ad42e94..0000000
--- a/10030_all_userstatv2-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/userstatv2.patch \ No newline at end of file
diff --git a/10030_all_userstatv2-percona-5.0.92.patch b/10030_all_userstatv2-percona-5.0.92.patch
deleted file mode 100644
index a60b7e2..0000000
--- a/10030_all_userstatv2-percona-5.0.92.patch
+++ /dev/null
@@ -1,4376 +0,0 @@
-diff -r 592f6c3641ba BUILD/Makefile.in
---- a/BUILD/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/BUILD/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Docs/Makefile.in
---- a/Docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Makefile.in
---- a/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba SSL/Makefile.in
---- a/SSL/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/SSL/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba client/Makefile.in
---- a/client/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/client/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba configure
---- a/configure Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure Wed Jul 29 13:34:11 2009 -0700
-@@ -35347,7 +35347,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38791,7 +38875,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 592f6c3641ba configure.in
---- a/configure.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure.in Wed Jul 29 13:34:11 2009 -0700
-@@ -2136,7 +2136,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2772,7 +2783,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 592f6c3641ba dbug/Makefile.in
---- a/dbug/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/dbug/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/Makefile.in
---- a/extra/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba heap/Makefile.in
---- a/heap/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/heap/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/Makefile.in
---- a/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 13:34:11 2009 -0700
-@@ -25,6 +25,7 @@
- #define USERNAME_LENGTH 16
- #define SERVER_VERSION_LENGTH 60
- #define SQLSTATE_LENGTH 5
-+#define LIST_PROCESS_HOST_LEN 64
-
- /*
- USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
-@@ -106,6 +107,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 592f6c3641ba libmysql/Makefile.in
---- a/libmysql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql_r/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba man/Makefile.in
---- a/man/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/man/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisam/Makefile.in
---- a/myisam/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisam/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisammrg/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 13:34:11 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
-diff -r 592f6c3641ba mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 13:34:11 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 592f6c3641ba mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 13:34:11 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 592f6c3641ba mysys/Makefile.in
---- a/mysys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/Makefile.in
---- a/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba netware/Makefile.in
---- a/netware/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/netware/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Wed Jul 29 13:34:11 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 592f6c3641ba pstack/Makefile.in
---- a/pstack/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/aout/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba regex/Makefile.in
---- a/regex/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/regex/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba scripts/Makefile.in
---- a/scripts/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/scripts/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/Makefile.in
---- a/server-tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/Makefile.in
---- a/sql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -3341,6 +3341,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3613,6 +3615,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3661,6 +3665,8 @@
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -4092,6 +4098,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 592f6c3641ba sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_myisam.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1521,13 +1523,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1538,6 +1544,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1548,6 +1561,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1558,6 +1578,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1568,6 +1595,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1578,6 +1612,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1588,6 +1629,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1598,6 +1646,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1614,6 +1669,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1631,6 +1693,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1645,6 +1708,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 592f6c3641ba sql/handler.cc
---- a/sql/handler.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 592f6c3641ba sql/handler.h
---- a/sql/handler.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.h Wed Jul 29 13:34:11 2009 -0700
-@@ -32,6 +32,10 @@
- #define USING_TRANSACTIONS
- #endif
-
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
-+#endif
-+
- // the following is for checking tables
-
- #define HA_ADMIN_ALREADY_DONE 1
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 592f6c3641ba sql/lex.h
---- a/sql/lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 592f6c3641ba sql/log.cc
---- a/sql/log.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/log.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 592f6c3641ba sql/mysql_priv.h
---- a/sql/mysql_priv.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysql_priv.h Wed Jul 29 13:34:11 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 592f6c3641ba sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 592f6c3641ba sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 592f6c3641ba sql/share/Makefile.in
---- a/sql/share/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/share/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/sql_base.cc
---- a/sql/sql_base.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_base.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 592f6c3641ba sql/sql_class.cc
---- a/sql/sql_class.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 592f6c3641ba sql/sql_class.h
---- a/sql/sql_class.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.h Wed Jul 29 13:34:11 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,8 +1943,14 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-
-+ char *get_client_host_port(THD *client);
-+
- public:
- /**
- Add an internal error handler to the thread execution context.
-@@ -1935,6 +1993,10 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 592f6c3641ba sql/sql_delete.cc
---- a/sql/sql_delete.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_delete.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -887,6 +888,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 592f6c3641ba sql/sql_insert.cc
---- a/sql/sql_insert.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_insert.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -990,6 +990,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3094,6 +3095,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 592f6c3641ba sql/sql_lex.h
---- a/sql/sql_lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 592f6c3641ba sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -146,6 +152,17 @@
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
- #endif
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,"%s",ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- (net->vio && net->error && net->report_error))
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4539,6 +4994,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4847,6 +5311,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5691,6 +6156,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5726,6 +6192,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5758,11 +6225,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5796,6 +6267,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5828,6 +6300,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5859,6 +6332,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5912,8 +6391,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5930,9 +6409,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6442,6 +6924,30 @@
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
- LEX *lex= thd->lex;
-@@ -6520,6 +7026,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7531,8 +8074,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 592f6c3641ba sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_prepare.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -81,6 +81,9 @@
- #include <mysql_com.h>
- #endif
-
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- /* A result class used to send cursor rows using the binary protocol. */
-
- class Select_fetch_protocol_prep: public select_send
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2503,6 +2717,43 @@
-
- send_ok(thd);
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-diff -r 592f6c3641ba sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", USERNAME_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,6 +4912,8 @@
- get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0},
- {"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_constraints_record, 3, 4, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TABLE_NAMES", table_names_fields_info, create_schema_table,
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
-@@ -4550,6 +4920,8 @@
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 592f6c3641ba sql/sql_update.cc
---- a/sql/sql_update.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_update.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 592f6c3641ba sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 13:34:11 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 592f6c3641ba sql/structs.h
---- a/sql/structs.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/structs.h Wed Jul 29 13:34:11 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 592f6c3641ba sql/table.h
---- a/sql/table.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/table.h Wed Jul 29 13:34:11 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 592f6c3641ba strings/Makefile.in
---- a/strings/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/strings/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/Makefile.in
---- a/support-files/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tests/Makefile.in
---- a/tests/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tests/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tools/Makefile.in
---- a/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba vio/Makefile.in
---- a/vio/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/vio/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba win/Makefile.in
---- a/win/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/win/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba zlib/Makefile.in
---- a/zlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/zlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -Nur a/include/mysql_com.h b/include/mysql_com.h
---- a/include/mysql_com.h 2010-05-22 00:26:45.000000000 -0700
-+++ b/include/mysql_com.h 2010-05-22 00:27:14.000000000 -0700
-@@ -228,7 +228,7 @@
-
- my_bool report_error; /* We should report error (we have unreported error) */
- my_bool return_errno;
--#if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
-+#if defined(MYSQL_SERVER)
- /*
- Controls whether a big packet should be skipped.
-
diff --git a/10040_all_microsec_process-percona-5.0.75-b12.patch b/10040_all_microsec_process-percona-5.0.75-b12.patch
deleted file mode 120000
index c8f69f0..0000000
--- a/10040_all_microsec_process-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/microsec_process.patch \ No newline at end of file
diff --git a/10040_all_microsec_process-percona-5.0.77-b13.patch b/10040_all_microsec_process-percona-5.0.77-b13.patch
deleted file mode 120000
index 7c859c0..0000000
--- a/10040_all_microsec_process-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/microsec_process.patch \ No newline at end of file
diff --git a/10040_all_microsec_process-percona-5.0.83-b17-20090706.patch b/10040_all_microsec_process-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 9b330cb..0000000
--- a/10040_all_microsec_process-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/microsec_process.patch \ No newline at end of file
diff --git a/10040_all_microsec_process-percona-5.0.84-b18-20090811.patch b/10040_all_microsec_process-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index ac192fb..0000000
--- a/10040_all_microsec_process-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/microsec_process.patch \ No newline at end of file
diff --git a/10040_all_microsec_process-percona-5.0.87-b20-20091116.patch b/10040_all_microsec_process-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 6de8adf..0000000
--- a/10040_all_microsec_process-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/microsec_process.patch \ No newline at end of file
diff --git a/10050_all_innodb_io_patches-percona-5.0.75-b12.patch b/10050_all_innodb_io_patches-percona-5.0.75-b12.patch
deleted file mode 120000
index 9849e2f..0000000
--- a/10050_all_innodb_io_patches-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_io_patches.patch \ No newline at end of file
diff --git a/10050_all_innodb_io_patches-percona-5.0.77-b13.patch b/10050_all_innodb_io_patches-percona-5.0.77-b13.patch
deleted file mode 120000
index aaa0d8d..0000000
--- a/10050_all_innodb_io_patches-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_io_patches.patch \ No newline at end of file
diff --git a/10050_all_innodb_io_patches-percona-5.0.83-b17-20090706.patch b/10050_all_innodb_io_patches-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 7725a8e..0000000
--- a/10050_all_innodb_io_patches-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_io_patches.patch \ No newline at end of file
diff --git a/10050_all_innodb_io_patches-percona-5.0.84-b18-20090811.patch b/10050_all_innodb_io_patches-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index b054cbe..0000000
--- a/10050_all_innodb_io_patches-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_io_patches.patch \ No newline at end of file
diff --git a/10050_all_innodb_io_patches-percona-5.0.87-b20-20091116.patch b/10050_all_innodb_io_patches-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 92d581b..0000000
--- a/10050_all_innodb_io_patches-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_io_patches.patch \ No newline at end of file
diff --git a/10060_all_mirror_binlog-percona-5.0.75-b12.patch b/10060_all_mirror_binlog-percona-5.0.75-b12.patch
deleted file mode 120000
index a39d817..0000000
--- a/10060_all_mirror_binlog-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/mirror_binlog.patch \ No newline at end of file
diff --git a/10060_all_mirror_binlog-percona-5.0.77-b13.patch b/10060_all_mirror_binlog-percona-5.0.77-b13.patch
deleted file mode 120000
index 09813cd..0000000
--- a/10060_all_mirror_binlog-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/mirror_binlog.patch \ No newline at end of file
diff --git a/10060_all_mirror_binlog-percona-5.0.83-b17-20090706.patch b/10060_all_mirror_binlog-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 0b1da0b..0000000
--- a/10060_all_mirror_binlog-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/mirror_binlog.patch \ No newline at end of file
diff --git a/10070_all_mysqld_safe_syslog-percona-5.0.75-b12.patch b/10070_all_mysqld_safe_syslog-percona-5.0.75-b12.patch
deleted file mode 120000
index c7ebf48..0000000
--- a/10070_all_mysqld_safe_syslog-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/mysqld_safe_syslog.patch \ No newline at end of file
diff --git a/10070_all_mysqld_safe_syslog-percona-5.0.77-b13.patch b/10070_all_mysqld_safe_syslog-percona-5.0.77-b13.patch
deleted file mode 120000
index e2cf563..0000000
--- a/10070_all_mysqld_safe_syslog-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/mysqld_safe_syslog.patch \ No newline at end of file
diff --git a/10070_all_mysqld_safe_syslog-percona-5.0.83-b17-20090706.patch b/10070_all_mysqld_safe_syslog-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 280dff2..0000000
--- a/10070_all_mysqld_safe_syslog-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/mysqld_safe_syslog.patch \ No newline at end of file
diff --git a/10070_all_mysqld_safe_syslog-percona-5.0.84-b18-20090811.patch b/10070_all_mysqld_safe_syslog-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index e1f7aa1..0000000
--- a/10070_all_mysqld_safe_syslog-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/mysqld_safe_syslog.patch \ No newline at end of file
diff --git a/10070_all_mysqld_safe_syslog-percona-5.0.87-b20-20091116.patch b/10070_all_mysqld_safe_syslog-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 1822a80..0000000
--- a/10070_all_mysqld_safe_syslog-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/mysqld_safe_syslog.patch \ No newline at end of file
diff --git a/10080_all_innodb_locks_held-percona-5.0.75-b12.patch b/10080_all_innodb_locks_held-percona-5.0.75-b12.patch
deleted file mode 120000
index 0678e1c..0000000
--- a/10080_all_innodb_locks_held-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_locks_held.patch \ No newline at end of file
diff --git a/10080_all_innodb_locks_held-percona-5.0.77-b13.patch b/10080_all_innodb_locks_held-percona-5.0.77-b13.patch
deleted file mode 120000
index 7dde94b..0000000
--- a/10080_all_innodb_locks_held-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_locks_held.patch \ No newline at end of file
diff --git a/10080_all_innodb_locks_held-percona-5.0.83-b17-20090706.patch b/10080_all_innodb_locks_held-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 9b0c326..0000000
--- a/10080_all_innodb_locks_held-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_locks_held.patch \ No newline at end of file
diff --git a/10080_all_innodb_locks_held-percona-5.0.84-b18-20090811.patch b/10080_all_innodb_locks_held-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index c3a573f..0000000
--- a/10080_all_innodb_locks_held-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_locks_held.patch \ No newline at end of file
diff --git a/10080_all_innodb_locks_held-percona-5.0.87-b20-20091116.patch b/10080_all_innodb_locks_held-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 52f5b52..0000000
--- a/10080_all_innodb_locks_held-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_locks_held.patch \ No newline at end of file
diff --git a/10090_all_innodb_show_bp-percona-5.0.75-b12.patch b/10090_all_innodb_show_bp-percona-5.0.75-b12.patch
deleted file mode 120000
index d7847b3..0000000
--- a/10090_all_innodb_show_bp-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_show_bp.patch \ No newline at end of file
diff --git a/10090_all_innodb_show_bp-percona-5.0.77-b13.patch b/10090_all_innodb_show_bp-percona-5.0.77-b13.patch
deleted file mode 120000
index fde4eb5..0000000
--- a/10090_all_innodb_show_bp-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_show_bp.patch \ No newline at end of file
diff --git a/10090_all_innodb_show_bp-percona-5.0.83-b17-20090706.patch b/10090_all_innodb_show_bp-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index da563fb..0000000
--- a/10090_all_innodb_show_bp-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_show_bp.patch \ No newline at end of file
diff --git a/10090_all_innodb_show_bp-percona-5.0.84-b18-20090811.patch b/10090_all_innodb_show_bp-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 5ea1f33..0000000
--- a/10090_all_innodb_show_bp-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_show_bp.patch \ No newline at end of file
diff --git a/10090_all_innodb_show_bp-percona-5.0.87-b20-20091116.patch b/10090_all_innodb_show_bp-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 7ce3f11..0000000
--- a/10090_all_innodb_show_bp-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_show_bp.patch \ No newline at end of file
diff --git a/10100_all_innodb_show_hashed_memory-percona-5.0.75-b12.patch b/10100_all_innodb_show_hashed_memory-percona-5.0.75-b12.patch
deleted file mode 120000
index 441c6a0..0000000
--- a/10100_all_innodb_show_hashed_memory-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_show_hashed_memory.patch \ No newline at end of file
diff --git a/10100_all_innodb_show_hashed_memory-percona-5.0.77-b13.patch b/10100_all_innodb_show_hashed_memory-percona-5.0.77-b13.patch
deleted file mode 120000
index c4c5390..0000000
--- a/10100_all_innodb_show_hashed_memory-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_show_hashed_memory.patch \ No newline at end of file
diff --git a/10110_all_innodb_check_fragmentation-percona-5.0.75-b12.patch b/10110_all_innodb_check_fragmentation-percona-5.0.75-b12.patch
deleted file mode 120000
index 6578f9a..0000000
--- a/10110_all_innodb_check_fragmentation-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_check_fragmentation.patch \ No newline at end of file
diff --git a/10110_all_innodb_check_fragmentation-percona-5.0.77-b13.patch b/10110_all_innodb_check_fragmentation-percona-5.0.77-b13.patch
deleted file mode 120000
index 55997a6..0000000
--- a/10110_all_innodb_check_fragmentation-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_check_fragmentation.patch \ No newline at end of file
diff --git a/10110_all_innodb_check_fragmentation-percona-5.0.83-b17-20090706.patch b/10110_all_innodb_check_fragmentation-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index f6f49b4..0000000
--- a/10110_all_innodb_check_fragmentation-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_check_fragmentation.patch \ No newline at end of file
diff --git a/10110_all_innodb_check_fragmentation-percona-5.0.84-b18-20090811.patch b/10110_all_innodb_check_fragmentation-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 37829ec..0000000
--- a/10110_all_innodb_check_fragmentation-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_check_fragmentation.patch \ No newline at end of file
diff --git a/10110_all_innodb_check_fragmentation-percona-5.0.87-b20-20091116.patch b/10110_all_innodb_check_fragmentation-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 0eb1b0c..0000000
--- a/10110_all_innodb_check_fragmentation-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_check_fragmentation.patch \ No newline at end of file
diff --git a/10120_all_innodb_io_pattern-percona-5.0.75-b12.patch b/10120_all_innodb_io_pattern-percona-5.0.75-b12.patch
deleted file mode 120000
index a013002..0000000
--- a/10120_all_innodb_io_pattern-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_io_pattern.patch \ No newline at end of file
diff --git a/10120_all_innodb_io_pattern-percona-5.0.77-b13.patch b/10120_all_innodb_io_pattern-percona-5.0.77-b13.patch
deleted file mode 120000
index 848dbbf..0000000
--- a/10120_all_innodb_io_pattern-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_io_pattern.patch \ No newline at end of file
diff --git a/10120_all_innodb_io_pattern-percona-5.0.83-b17-20090706.patch b/10120_all_innodb_io_pattern-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index b3a266b..0000000
--- a/10120_all_innodb_io_pattern-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_io_pattern.patch \ No newline at end of file
diff --git a/10120_all_innodb_io_pattern-percona-5.0.84-b18-20090811.patch b/10120_all_innodb_io_pattern-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index b8cedab..0000000
--- a/10120_all_innodb_io_pattern-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_io_pattern.patch \ No newline at end of file
diff --git a/10120_all_innodb_io_pattern-percona-5.0.87-b20-20091116.patch b/10120_all_innodb_io_pattern-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 089c34e..0000000
--- a/10120_all_innodb_io_pattern-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_io_pattern.patch \ No newline at end of file
diff --git a/10130_all_innodb_fsync_source-percona-5.0.75-b12.patch b/10130_all_innodb_fsync_source-percona-5.0.75-b12.patch
deleted file mode 120000
index d39fd46..0000000
--- a/10130_all_innodb_fsync_source-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_fsync_source.patch \ No newline at end of file
diff --git a/10130_all_innodb_fsync_source-percona-5.0.77-b13.patch b/10130_all_innodb_fsync_source-percona-5.0.77-b13.patch
deleted file mode 120000
index faea48b..0000000
--- a/10130_all_innodb_fsync_source-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_fsync_source.patch \ No newline at end of file
diff --git a/10130_all_innodb_fsync_source-percona-5.0.83-b17-20090706.patch b/10130_all_innodb_fsync_source-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index eaa83be..0000000
--- a/10130_all_innodb_fsync_source-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_fsync_source.patch \ No newline at end of file
diff --git a/10130_all_innodb_fsync_source-percona-5.0.84-b18-20090811.patch b/10130_all_innodb_fsync_source-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 724bce7..0000000
--- a/10130_all_innodb_fsync_source-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_fsync_source.patch \ No newline at end of file
diff --git a/10130_all_innodb_fsync_source-percona-5.0.87-b20-20091116.patch b/10130_all_innodb_fsync_source-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index db591b8..0000000
--- a/10130_all_innodb_fsync_source-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_fsync_source.patch \ No newline at end of file
diff --git a/10139_all_innodb_show_hashed_memory-percona-5.0.83-b17-20090706.patch b/10139_all_innodb_show_hashed_memory-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 8d14834..0000000
--- a/10139_all_innodb_show_hashed_memory-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_show_hashed_memory.patch \ No newline at end of file
diff --git a/10139_all_innodb_show_hashed_memory-percona-5.0.84-b18-20090811.patch b/10139_all_innodb_show_hashed_memory-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index b986805..0000000
--- a/10139_all_innodb_show_hashed_memory-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_show_hashed_memory.patch \ No newline at end of file
diff --git a/10139_all_innodb_show_hashed_memory-percona-5.0.87-b20-20091116.patch b/10139_all_innodb_show_hashed_memory-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 5a8ea3a..0000000
--- a/10139_all_innodb_show_hashed_memory-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_show_hashed_memory.patch \ No newline at end of file
diff --git a/10140_all_innodb_dict_size_limit-percona-5.0.77-b13.patch b/10140_all_innodb_dict_size_limit-percona-5.0.77-b13.patch
deleted file mode 120000
index 49981c0..0000000
--- a/10140_all_innodb_dict_size_limit-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_dict_size_limit.patch \ No newline at end of file
diff --git a/10140_all_innodb_dict_size_limit-percona-5.0.83-b17-20090706.patch b/10140_all_innodb_dict_size_limit-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index c450280..0000000
--- a/10140_all_innodb_dict_size_limit-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_dict_size_limit.patch \ No newline at end of file
diff --git a/10140_all_innodb_dict_size_limit-percona-5.0.84-b18-20090811.patch b/10140_all_innodb_dict_size_limit-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 3b6e261..0000000
--- a/10140_all_innodb_dict_size_limit-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_dict_size_limit.patch \ No newline at end of file
diff --git a/10140_all_innodb_dict_size_limit-percona-5.0.87-b20-20091116.patch b/10140_all_innodb_dict_size_limit-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index e416868..0000000
--- a/10140_all_innodb_dict_size_limit-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_dict_size_limit.patch \ No newline at end of file
diff --git a/10160_all_innodb_extra_rseg-percona-5.0.83-b17-20090706.patch b/10160_all_innodb_extra_rseg-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 998a4a1..0000000
--- a/10160_all_innodb_extra_rseg-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_extra_rseg.patch \ No newline at end of file
diff --git a/10160_all_innodb_extra_rseg-percona-5.0.84-b18-20090811.patch b/10160_all_innodb_extra_rseg-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index e0ac577..0000000
--- a/10160_all_innodb_extra_rseg-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_extra_rseg.patch \ No newline at end of file
diff --git a/10160_all_innodb_extra_rseg-percona-5.0.87-b20-20091116.patch b/10160_all_innodb_extra_rseg-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index caefb6a..0000000
--- a/10160_all_innodb_extra_rseg-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_extra_rseg.patch \ No newline at end of file
diff --git a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.83-b17-20090706.patch b/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index d8228e3..0000000
--- a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_thread_concurrency_timer_based.patch \ No newline at end of file
diff --git a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.84-b18-20090811.patch b/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 52506b9..0000000
--- a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_thread_concurrency_timer_based.patch \ No newline at end of file
diff --git a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.87-b20-20091116.patch b/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 1119406..0000000
--- a/10170_all_innodb_thread_concurrency_timer_based-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_thread_concurrency_timer_based.patch \ No newline at end of file
diff --git a/10200_all_mysql-test-percona-5.0.83-b17-20090706.patch b/10200_all_mysql-test-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 8e35ecb..0000000
--- a/10200_all_mysql-test-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/mysql-test.patch \ No newline at end of file
diff --git a/10200_all_mysql-test-percona-5.0.84-b18-20090811.patch b/10200_all_mysql-test-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 0fb84ed..0000000
--- a/10200_all_mysql-test-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/mysql-test.patch \ No newline at end of file
diff --git a/10200_all_mysql-test-percona-5.0.87-b20-20091116.patch b/10200_all_mysql-test-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 5c88636..0000000
--- a/10200_all_mysql-test-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/mysql-test.patch \ No newline at end of file
diff --git a/10500_all_innodb_use_sys_malloc-percona-5.0.84-b18-20090811.patch b/10500_all_innodb_use_sys_malloc-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 30a5e99..0000000
--- a/10500_all_innodb_use_sys_malloc-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_use_sys_malloc.patch \ No newline at end of file
diff --git a/10500_all_innodb_use_sys_malloc-percona-5.0.87-b20-20091116.patch b/10500_all_innodb_use_sys_malloc-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 3c28678..0000000
--- a/10500_all_innodb_use_sys_malloc-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_use_sys_malloc.patch \ No newline at end of file
diff --git a/10510_all_innodb_recovery_patches-percona-5.0.84-b18-20090811.patch b/10510_all_innodb_recovery_patches-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 2c7076a..0000000
--- a/10510_all_innodb_recovery_patches-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_recovery_patches.patch \ No newline at end of file
diff --git a/10510_all_innodb_recovery_patches-percona-5.0.87-b20-20091116.patch b/10510_all_innodb_recovery_patches-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 129ad7f..0000000
--- a/10510_all_innodb_recovery_patches-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_recovery_patches.patch \ No newline at end of file
diff --git a/10511_all_innodb_misc_patch-percona-5.0.87-b20-20091116.patch b/10511_all_innodb_misc_patch-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 873770f..0000000
--- a/10511_all_innodb_misc_patch-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_misc_patch.patch \ No newline at end of file
diff --git a/10520_all_innodb_split_buf_pool_mutex-percona-5.0.84-b18-20090811.patch b/10520_all_innodb_split_buf_pool_mutex-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 0994931..0000000
--- a/10520_all_innodb_split_buf_pool_mutex-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_split_buf_pool_mutex.patch \ No newline at end of file
diff --git a/10520_all_innodb_split_buf_pool_mutex-percona-5.0.87-b20-20091116.patch b/10520_all_innodb_split_buf_pool_mutex-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index 1e8a088..0000000
--- a/10520_all_innodb_split_buf_pool_mutex-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_split_buf_pool_mutex.patch \ No newline at end of file
diff --git a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.75-b12.patch b/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.75-b12.patch
deleted file mode 120000
index 743e85f..0000000
--- a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/split_buf_pool_mutex_fixed_optimistic_safe.patch \ No newline at end of file
diff --git a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.77-b13.patch b/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.77-b13.patch
deleted file mode 120000
index 49ca8a2..0000000
--- a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/split_buf_pool_mutex_fixed_optimistic_safe.patch \ No newline at end of file
diff --git a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.83-b17-20090706.patch b/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 3279329..0000000
--- a/11000_all_split_buf_pool_mutex_fixed_optimistic_safe-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/split_buf_pool_mutex_fixed_optimistic_safe.patch \ No newline at end of file
diff --git a/11010_all_innodb_rw_lock-percona-5.0.75-b12.patch b/11010_all_innodb_rw_lock-percona-5.0.75-b12.patch
deleted file mode 120000
index 761fdaa..0000000
--- a/11010_all_innodb_rw_lock-percona-5.0.75-b12.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.75-b12/innodb_rw_lock.patch \ No newline at end of file
diff --git a/11010_all_innodb_rw_lock-percona-5.0.77-b13.patch b/11010_all_innodb_rw_lock-percona-5.0.77-b13.patch
deleted file mode 120000
index cdb0560..0000000
--- a/11010_all_innodb_rw_lock-percona-5.0.77-b13.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.77-b13/innodb_rw_lock.patch \ No newline at end of file
diff --git a/11010_all_innodb_rw_lock-percona-5.0.83-b17-20090706.patch b/11010_all_innodb_rw_lock-percona-5.0.83-b17-20090706.patch
deleted file mode 120000
index 1608c2c..0000000
--- a/11010_all_innodb_rw_lock-percona-5.0.83-b17-20090706.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.83-b17-20090706/innodb_rw_lock.patch \ No newline at end of file
diff --git a/11010_all_innodb_rw_lock-percona-5.0.84-b18-20090811.patch b/11010_all_innodb_rw_lock-percona-5.0.84-b18-20090811.patch
deleted file mode 120000
index 069b8cb..0000000
--- a/11010_all_innodb_rw_lock-percona-5.0.84-b18-20090811.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.84-b18-20090811/innodb_rw_lock.patch \ No newline at end of file
diff --git a/11010_all_innodb_rw_lock-percona-5.0.87-b20-20091116.patch b/11010_all_innodb_rw_lock-percona-5.0.87-b20-20091116.patch
deleted file mode 120000
index fc5fd23..0000000
--- a/11010_all_innodb_rw_lock-percona-5.0.87-b20-20091116.patch
+++ /dev/null
@@ -1 +0,0 @@
-percona/5.0.87-b20-20091116/innodb_rw_lock.patch \ No newline at end of file
diff --git a/15000_all_mariadb_libevent-system_5.1.42.patch b/15000_all_mariadb_libevent-system_5.1.42.patch
deleted file mode 100644
index 1978cef..0000000
--- a/15000_all_mariadb_libevent-system_5.1.42.patch
+++ /dev/null
@@ -1,92 +0,0 @@
---- config/ac-macros/libevent.m4 2010-01-31 04:17:56.000000000 -0500
-+++ config/ac-macros/libevent.m4 2010-01-31 04:17:56.000000000 -0500
-@@ -14,13 +14,6 @@
-
- libevent_libs="\$(top_builddir)/extra/libevent/libevent.a"
- libevent_includes="-I\$(top_srcdir)/extra/libevent"
-- libevent_test_option="--mysqld=--thread-handling=pool-of-threads"
-- AC_SUBST(libevent_libs)
-- AC_SUBST(libevent_includes)
-- AC_SUBST(libevent_test_option)
--
-- AC_DEFINE([HAVE_LIBEVENT], [1], [If we want to use libevent and have connection pooling])
-- AC_MSG_RESULT([using bundled libevent])
-
- dnl Get the upstream file with the original libevent configure macros.
- dnl Use builtin include for this, to work around path problems in old versions of aclocal.
-@@ -39,17 +32,64 @@
-
- AC_CONFIG_FILES(extra/libevent/Makefile)
-
-- AC_MSG_CHECKING(for libevent)
-+ AC_MSG_NOTICE([checking what libevent library to use])
-+
- AC_ARG_WITH([libevent],
-- [ --with-libevent use libevent and have connection pooling],
-- [with_libevent=$withval],
-- [with_libevent=no]
-- )
--
-- if test "$with_libevent" != "no"; then
-- MYSQL_USE_BUNDLED_LIBEVENT
-- else
-- AC_MSG_RESULT([disabled])
-+ AC_HELP_STRING([--with-libevent=yes|no|bundled|DIR],
-+ [Use libevent and have connection pooling.
-+ A location of libevent library can be specified.
-+ Given DIR, libevent library is
-+ assumed to be in $DIR/lib and header files
-+ in $DIR/include.]),
-+ [with_libevent=${withval}],
-+ [with_libevent=no])
-+
-+ case "$with_libevent" in
-+ "no")
-+ with_libevent=disabled
-+ ;;
-+ "bundled")
-+ MYSQL_USE_BUNDLED_LIBEVENT
-+ ;;
-+ "" | "yes")
-+ libevent_includes=""
-+ libevent_libs="-levent"
-+ AC_CHECK_LIB(event, evutil_socketpair,[with_libevent=system],
-+ [with_libevent=bundled])
-+ AC_CHECK_HEADER(evutil.h,,[with_libevent=bundled])
-+ if test "$with_libevent" = "bundled"; then
-+ MYSQL_USE_BUNDLED_LIBEVENT
-+ fi
-+ ;;
-+ *)
-+ # Test for libevent using all known library file endings
-+ if test \( -f "$with_libevent/lib/libevent.a" -o \
-+ -f "$with_libevent/lib/libevent.so" -o \
-+ -f "$with_libevent/lib/libevent.sl" -o \
-+ -f "$with_libevent/lib/libevent.dylib" \) \
-+ -a -f "$with_libevent/include/evutil.h"; then
-+ libevent_includes="-I$with_libevent/include"
-+ libevent_libs="-L$with_libevent/lib -levent"
-+ AC_CHECK_LIB(event, evutil_socketpair,[with_libevent=$with_libevent],
-+ [with_libevent=no], [$libevent_libs])
-+ else
-+ with_libevent=no
-+ fi
-+ if test "$with_libevent" = "no"; then
-+ AC_MSG_ERROR([libevent headers or binaries were not found])
-+ fi
-+ ;;
-+ esac
-+ AC_MSG_CHECKING(for libevent)
-+ AC_MSG_RESULT([$with_libevent])
-+
-+ if test "$with_libevent" != "disabled"; then
-+ libevent_test_option="--mysqld=--thread-handling=pool-of-threads"
-+ AC_SUBST(libevent_libs)
-+ AC_SUBST(libevent_includes)
-+ AC_SUBST(libevent_test_option)
-+ AC_DEFINE([HAVE_LIBEVENT], [1], [If we want to use libevent and have connection pooling])
- fi
-- AM_CONDITIONAL([HAVE_LIBEVENT], [ test "$with_libevent" != "no" ])
-+ AM_CONDITIONAL([HAVE_LIBEVENT], [ test "$with_libevent" != "disabled" ])
- ])
-+
diff --git a/21000_all_sql-5.1.62.patch b/21000_all_sql-5.1.62.patch
deleted file mode 100644
index a763955..0000000
--- a/21000_all_sql-5.1.62.patch
+++ /dev/null
@@ -1,3199 +0,0 @@
-=== modified file 'include/my_sys.h'
---- include/my_sys.h 2011-11-21 17:13:14 +0000
-+++ include/my_sys.h 2012-08-24 08:06:16 +0000
-@@ -806,6 +806,8 @@
- extern void my_b_seek(IO_CACHE *info,my_off_t pos);
- extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
- extern my_off_t my_b_filelength(IO_CACHE *info);
-+extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
-+ size_t len);
- extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
- extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
- extern int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-
-=== modified file 'mysql-test/r/func_compress.result'
---- mysql-test/r/func_compress.result 2009-06-19 09:29:21 +0000
-+++ mysql-test/r/func_compress.result 2012-08-24 08:06:16 +0000
-@@ -11,7 +11,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))`
-+Note 1003 select uncompress(compress((@`test_compress_string`))) AS `uncompress(compress(@test_compress_string))`
- select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
- uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
- 1
-@@ -19,7 +19,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
-+Note 1003 select (uncompressed_length(compress((@`test_compress_string`))) = length((@`test_compress_string`))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
- select uncompressed_length(compress(@test_compress_string));
- uncompressed_length(compress(@test_compress_string))
- 117
-
-=== modified file 'mysql-test/r/mysqlbinlog.result'
---- mysql-test/r/mysqlbinlog.result 2011-03-25 14:16:13 +0000
-+++ mysql-test/r/mysqlbinlog.result 2012-08-24 08:06:16 +0000
-@@ -18,7 +18,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -64,7 +64,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -97,7 +97,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -119,7 +119,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -165,7 +165,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -198,7 +198,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -220,7 +220,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844556/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-@@ -239,7 +239,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844556/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-@@ -299,7 +299,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -349,7 +349,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -484,7 +484,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1253783037/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -581,22 +581,22 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
- /*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t1 VALUES(40)
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- ROLLBACK TO mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("after rollback to")
- /*!*/;
-@@ -624,7 +624,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog2.result'
---- mysql-test/r/mysqlbinlog2.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/mysqlbinlog2.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -62,7 +62,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -101,7 +101,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -127,7 +127,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -162,7 +162,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -185,7 +185,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -215,7 +215,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -246,7 +246,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -281,7 +281,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -304,7 +304,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -335,7 +335,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -358,7 +358,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -377,7 +377,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -399,7 +399,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -445,7 +445,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -468,7 +468,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -490,7 +490,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -520,7 +520,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -563,7 +563,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -601,7 +601,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -627,7 +627,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -661,7 +661,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -684,7 +684,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -714,7 +714,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -744,7 +744,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -779,7 +779,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -802,7 +802,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -833,7 +833,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -855,7 +855,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -874,7 +874,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -896,7 +896,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -942,7 +942,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -965,7 +965,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -987,7 +987,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1017,7 +1017,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row.result'
---- mysql-test/r/mysqlbinlog_row.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row.result 2012-08-24 08:06:16 +0000
-@@ -336,7 +336,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_innodb.result'
---- mysql-test/r/mysqlbinlog_row_innodb.result 2010-03-22 12:10:18 +0000
-+++ mysql-test/r/mysqlbinlog_row_innodb.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3876,7 +3876,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4243,7 +4243,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4804,7 +4804,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_myisam.result'
---- mysql-test/r/mysqlbinlog_row_myisam.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row_myisam.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3898,7 +3898,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4271,7 +4271,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4842,7 +4842,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_trans.result'
---- mysql-test/r/mysqlbinlog_row_trans.result 2009-08-27 09:32:27 +0000
-+++ mysql-test/r/mysqlbinlog_row_trans.result 2012-08-24 08:06:16 +0000
-@@ -132,7 +132,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/user_var-binlog.result'
---- mysql-test/r/user_var-binlog.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/user_var-binlog.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/variables.result'
---- mysql-test/r/variables.result 2011-05-02 17:58:45 +0000
-+++ mysql-test/r/variables.result 2012-08-24 08:06:16 +0000
-@@ -76,7 +76,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
-+Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@`t1`) AS `@t1`,(@`t2`) AS `@t2`,(@`t3`) AS `@t3`
- select @t5;
- @t5
- 1.23456
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_base64_flag.result'
---- mysql-test/suite/binlog/r/binlog_base64_flag.result 2011-02-23 09:31:37 +0000
-+++ mysql-test/suite/binlog/r/binlog_base64_flag.result 2012-08-24 08:06:16 +0000
-@@ -35,7 +35,7 @@
- # at 4
- <#>ROLLBACK/*!*/;
- # at 102
--<#>use test/*!*/;
-+<#>use `test`/*!*/;
- SET TIMESTAMP=1196959712/*!*/;
- <#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
- SET @@session.sql_mode=0/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
---- mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2008-10-23 19:27:09 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2012-08-24 08:06:16 +0000
-@@ -13,7 +13,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
---- mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2010-09-02 13:05:06 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2012-08-24 08:06:16 +0000
-@@ -631,7 +631,7 @@
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- /* the output must denote there is the query */;
- drop trigger trg_del_t2;
-@@ -869,7 +869,7 @@
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- drop trigger trg_del_t2;
- drop table t1,t2,t3,t4,t5;
-
-=== added file 'mysql-test/suite/rpl/r/rpl_mdev382.result'
---- mysql-test/suite/rpl/r/rpl_mdev382.result 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/r/rpl_mdev382.result 2012-08-24 08:06:16 +0000
-@@ -0,0 +1,275 @@
-+include/master-slave.inc
-+[connection master]
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+Warnings:
-+Warning 1196 Some non-transactional changed tables couldn't be rolled back
-+insert into t1 values (3);
-+commit;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
-+master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
-+master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
-+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
-+master-bin.000001 # Query # # use `test`; insert into t2 values (1)
-+master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
-+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values(10)
-+master-bin.000001 # Query # # SAVEPOINT "a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(11)
-+master-bin.000001 # Query # # SAVEPOINT "a""a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(12)
-+master-bin.000001 # Query # # SAVEPOINT b
-+master-bin.000001 # Query # # use `test`; insert into t1 values(13)
-+master-bin.000001 # Query # # SAVEPOINT "b""b"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(14)
-+master-bin.000001 # Query # # SAVEPOINT `c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(15)
-+master-bin.000001 # Query # # SAVEPOINT `c``c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(16)
-+master-bin.000001 # Query # # SAVEPOINT d
-+master-bin.000001 # Query # # use `test`; insert into t1 values(17)
-+master-bin.000001 # Query # # SAVEPOINT `d``d`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(18)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+*** Test correct USE statement in SHOW BINLOG EVENTS ***
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+DROP TABLE t1;
-+use test;
-+***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+truncate `t``1`;
-+use test;
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+truncate `t``1`
-+/*!*/;
-+use `test`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+drop table t1,t2;
-+*** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
-+FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=concat((@`b`),'| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|',(@`b`)) ;file_id=#
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+DROP TABLE t1;
-+*** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+master-bin.000001 # User var # # @`a``1`=-9223372036854775808
-+master-bin.000001 # User var # # @`a``2`=42
-+master-bin.000001 # User var # # @`a``3`=9223372036854775807
-+master-bin.000001 # User var # # @`a``4`=-1
-+master-bin.000001 # User var # # @`b```=-1.2345601234568e+125
-+master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
-+master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+/*!*/;
-+SET @`a``1`:=-9223372036854775808/*!*/;
-+SET @`a``2`:=42/*!*/;
-+SET @`a``3`:=9223372036854775807/*!*/;
-+SET @`a``4`:=-1/*!*/;
-+SET @`b```:=-1.2345601234568e+125/*!*/;
-+SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
-+SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+a1 a2 a3 a4 b c d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+-9223372036854775807 4200 9223372036854775806 0 -6.17280061728394e+124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+DROP TABLE t1;
-+*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+include/stop_slave.inc
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+a`
-+1
-+2
-+5
-+set timestamp=1000000000;
-+# The table should be empty on the master.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+# The DELETE statement should be correctly quoted
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
-+include/start_slave.inc
-+# The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+include/rpl_end.inc
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
---- mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2012-08-24 08:06:16 +0000
-@@ -153,7 +153,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -175,7 +175,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -284,7 +284,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -316,7 +316,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
---- mysql-test/suite/rpl/r/rpl_sp.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_sp.result 2012-08-24 08:06:16 +0000
-@@ -627,7 +627,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest1
- /*!*/;
--use mysqltest1/*!*/;
-+use `mysqltest1`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t1 (a varchar(100))
- /*!*/;
-@@ -840,7 +840,7 @@
- SET TIMESTAMP=t/*!*/;
- drop user "zedjzlcsjhd"@127.0.0.1
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- drop function if exists f1
- /*!*/;
-@@ -925,7 +925,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest2
- /*!*/;
--use mysqltest2/*!*/;
-+use `mysqltest2`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t ( t integer )
- /*!*/;
-@@ -943,7 +943,7 @@
- return 0;
- end
- /*!*/;
--use mysqltest/*!*/;
-+use `mysqltest`/*!*/;
- SET TIMESTAMP=t/*!*/;
- SELECT `mysqltest2`.`f1`()
- /*!*/;
-@@ -953,14 +953,14 @@
- SET TIMESTAMP=t/*!*/;
- drop database mysqltest2
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
- begin
- select 1;
- end
- /*!*/;
--use mysql/*!*/;
-+use `mysql`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
- `label`:
-
-=== added file 'mysql-test/suite/rpl/t/rpl_mdev382.test'
---- mysql-test/suite/rpl/t/rpl_mdev382.test 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/t/rpl_mdev382.test 2012-08-24 08:06:16 +0000
-@@ -0,0 +1,249 @@
-+--source include/have_innodb.inc
-+--source include/not_windows.inc
-+--source include/have_binlog_format_statement.inc
-+--source include/master-slave.inc
-+
-+# MDEV-382: multiple SQL injections in replication code.
-+
-+# Test previous SQL injection attack against binlog for SAVEPOINT statement.
-+# The test would cause syntax error on slave due to improper quoting of
-+# the savepoint name.
-+connection master;
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (3);
-+commit;
-+
-+--source include/show_binlog_events.inc
-+
-+# This failed due to syntax error in query when the bug was not fixed.
-+sync_slave_with_master;
-+connection slave;
-+
-+# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+
-+--source include/show_binlog_events.inc
-+
-+--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+--source include/show_binlog_events.inc
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+--source include/show_binlog_events.inc
-+set sql_quote_show_create = 1;
-+--source include/show_binlog_events.inc
-+DROP TABLE t1;
-+
-+use test;
-+
-+--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
-+--write_file $load_file
-+'fo\\o','bar'
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+ `c``3` VARCHAR(7));
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+
-+SELECT * FROM `t``1`;
-+# Also test when code prefixes table name with database.
-+truncate `t``1`;
-+use test;
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+connection master;
-+
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+--remove_file $load_file
-+
-+connection master;
-+drop table t1,t2;
-+
-+
-+--echo *** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
-+--write_file $load_file
-+1,X
-+2,A
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+# The bug was that the SET expression was truncated to 256 bytes, so test with
-+# an expression longer than that.
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$load_file' INTO TABLE t1
-+ FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+
-+SELECT * FROM t1 ORDER BY a;
-+--source include/show_binlog_events.inc
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM t1 ORDER BY a;
-+
-+connection master;
-+--remove_file $load_file
-+DROP TABLE t1;
-+
-+
-+--echo *** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+
-+connection master;
-+DROP TABLE t1;
-+
-+
-+--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+
-+# Let's keep the slave stopped during master restart, to avoid any potential
-+# races between slave reconnect and master restart.
-+connection slave;
-+--source include/stop_slave.inc
-+
-+connection master;
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+
-+# Restart the master mysqld.
-+# This will cause an implicit truncation of the memory-based table, which will
-+# cause logging of an explicit DELETE FROM to binlog.
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+wait-rpl_mdev382.test
-+EOF
-+
-+--shutdown_server 30
-+
-+--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+restart-rpl_mdev382.test
-+EOF
-+
-+connection default;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+# rpl_end.inc needs to use the connection server_1
-+connection server_1;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+connection master;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+set timestamp=1000000000;
-+
-+--echo # The table should be empty on the master.
-+let $binlog_file= master-bin.000002;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+--echo # The DELETE statement should be correctly quoted
-+--source include/show_binlog_events.inc
-+
-+connection slave;
-+--source include/start_slave.inc
-+
-+connection master;
-+sync_slave_with_master;
-+connection slave;
-+--echo # The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+connection master;
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+sync_slave_with_master;
-+
-+
-+connection master;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+
-+
-+--source include/rpl_end.inc
-
-=== modified file 'mysys/mf_iocache2.c'
---- mysys/mf_iocache2.c 2011-11-21 17:13:14 +0000
-+++ mysys/mf_iocache2.c 2012-08-24 08:06:16 +0000
-@@ -284,6 +284,40 @@
- }
-
-
-+size_t
-+my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len)
-+{
-+ const uchar *start;
-+ const uchar *p= (const uchar *)str;
-+ const uchar *end= p + len;
-+ size_t count;
-+ size_t total= 0;
-+
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ for (;;)
-+ {
-+ start= p;
-+ while (p < end && *p != '`')
-+ ++p;
-+ count= p - start;
-+ if (count && my_b_write(info, start, count))
-+ return (size_t)-1;
-+ total+= count;
-+ if (p >= end)
-+ break;
-+ if (my_b_write(info, (uchar *)"``", 2))
-+ return (size_t)-1;
-+ total+= 2;
-+ ++p;
-+ }
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ return total;
-+}
-+
- /*
- Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
- Used for logging in MySQL
-@@ -308,6 +342,7 @@
- uint minimum_width_sign;
- uint precision; /* as yet unimplemented for anything but %b */
- my_bool is_zero_padded;
-+ my_bool backtick_quoting;
-
- /*
- Store the location of the beginning of a format directive, for the
-@@ -342,6 +377,7 @@
- fmt++;
-
- is_zero_padded= FALSE;
-+ backtick_quoting= FALSE;
- minimum_width_sign= 1;
- minimum_width= 0;
- precision= 0;
-@@ -354,6 +390,8 @@
- minimum_width_sign= -1; fmt++; goto process_flags;
- case '0':
- is_zero_padded= TRUE; fmt++; goto process_flags;
-+ case '`':
-+ backtick_quoting= TRUE; fmt++; goto process_flags;
- case '#':
- /** @todo Implement "#" conversion flag. */ fmt++; goto process_flags;
- case ' ':
-@@ -397,9 +435,19 @@
- reg2 char *par = va_arg(args, char *);
- size_t length2 = strlen(par);
- /* TODO: implement precision */
-- out_length+= length2;
-- if (my_b_write(info, (uchar*) par, length2))
-- goto err;
-+ if (backtick_quoting)
-+ {
-+ size_t total= my_b_write_backtick_quote(info, (uchar *) par, length2);
-+ if (total == (size_t)-1)
-+ goto err;
-+ out_length+= total;
-+ }
-+ else
-+ {
-+ out_length+= length2;
-+ if (my_b_write(info, (uchar*) par, length2))
-+ goto err;
-+ }
- }
- else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
- {
-
-=== modified file 'sql/ha_ndbcluster_binlog.cc'
---- sql/ha_ndbcluster_binlog.cc 2011-11-21 17:13:14 +0000
-+++ sql/ha_ndbcluster_binlog.cc 2012-08-24 08:06:16 +0000
-@@ -1268,7 +1268,9 @@
- DBUG_RETURN(0);
- }
-
-- char tmp_buf2[FN_REFLEN];
-+ char tmp_buf2_mem[FN_REFLEN];
-+ String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
-+ tmp_buf2.length(0);
- const char *type_str;
- switch (type)
- {
-@@ -1277,17 +1279,24 @@
- if (thd->lex->sql_command == SQLCOM_DROP_DB)
- DBUG_RETURN(0);
- /* redo the drop table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "drop table `",
-- table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("drop table "));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "drop table";
- break;
- case SOT_RENAME_TABLE:
- /* redo the rename table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "rename table `",
-- db, ".", table_name, "` to `",
-- new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("rename table "));
-+ append_identifier(thd, &tmp_buf2, db, strlen(db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ tmp_buf2.append(STRING_WITH_LEN(" to "));
-+ append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "rename table";
- break;
- case SOT_CREATE_TABLE:
-
-=== modified file 'sql/item.cc'
---- sql/item.cc 2012-05-17 10:12:33 +0000
-+++ sql/item.cc 2012-08-24 08:06:16 +0000
-@@ -749,15 +749,31 @@
- if (!my_charset_same(cs, system_charset_info))
- {
- size_t res_length;
-- name= sql_strmake_with_convert(str, name_length= length, cs,
-+ name= sql_strmake_with_convert(str, length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
-+ name_length= res_length;
- }
- else
- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
- }
-
-
-+void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
-+{
-+ if (!my_charset_same(cs, system_charset_info))
-+ {
-+ size_t res_length;
-+ name= sql_strmake_with_convert(str, length, cs,
-+ UINT_MAX, system_charset_info,
-+ &res_length);
-+ name_length= res_length;
-+ }
-+ else
-+ name= sql_strmake(str, (name_length= length));
-+}
-+
-+
- /**
- @details
- This function is called when:
-
-=== modified file 'sql/item.h'
---- sql/item.h 2012-05-17 10:12:33 +0000
-+++ sql/item.h 2012-08-24 08:06:16 +0000
-@@ -554,6 +554,7 @@
- #endif
- } /*lint -e1509 */
- void set_name(const char *str, uint length, CHARSET_INFO *cs);
-+ void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
- void rename(char *new_name);
- void init_make_field(Send_field *tmp_field,enum enum_field_types type);
- virtual void cleanup();
-
-=== modified file 'sql/item_func.cc'
---- sql/item_func.cc 2011-11-21 17:13:14 +0000
-+++ sql/item_func.cc 2012-08-24 08:06:16 +0000
-@@ -4743,7 +4743,7 @@
- void Item_func_get_user_var::print(String *str, enum_query_type query_type)
- {
- str->append(STRING_WITH_LEN("(@"));
-- str->append(name.str,name.length);
-+ append_identifier(current_thd, str, name.str, name.length);
- str->append(')');
- }
-
-@@ -4841,10 +4841,10 @@
- }
-
-
--void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
-+void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
- {
- str->append('@');
-- str->append(name.str,name.length);
-+ append_identifier(thd, str, name.str, name.length);
- }
-
-
-
-=== modified file 'sql/item_func.h'
---- sql/item_func.h 2011-11-21 17:13:14 +0000
-+++ sql/item_func.h 2012-08-24 08:06:16 +0000
-@@ -1503,7 +1503,7 @@
- my_decimal *val_decimal(my_decimal *decimal_buffer);
- /* fix_fields() binds variable name with its entry structure */
- bool fix_fields(THD *thd, Item **ref);
-- virtual void print(String *str, enum_query_type query_type);
-+ void print_for_load(THD *thd, String *str);
- void set_null_value(CHARSET_INFO* cs);
- void set_value(const char *str, uint length, CHARSET_INFO* cs);
- };
-
-=== modified file 'sql/log.cc'
---- sql/log.cc 2012-05-17 10:12:33 +0000
-+++ sql/log.cc 2012-08-24 08:06:16 +0000
-@@ -38,6 +38,7 @@
- #endif
-
- #include <mysql/plugin.h>
-+#include "sql_show.h"
-
- /* max size of the log message */
- #define MAX_LOG_BUFFER_SIZE 1024
-@@ -1726,9 +1727,8 @@
-
- String log_query;
- if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
-@@ -1750,9 +1750,8 @@
- {
- String log_query;
- if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- Query_log_event qinfo(thd, log_query.c_ptr_safe(), log_query.length(),
-
-=== modified file 'sql/log_event.cc'
---- sql/log_event.cc 2012-05-17 10:12:33 +0000
-+++ sql/log_event.cc 2012-08-24 08:06:16 +0000
-@@ -34,6 +34,7 @@
- #include "rpl_utility.h"
- #include "rpl_record.h"
- #include <my_dir.h>
-+#include "sql_show.h"
-
- #endif /* MYSQL_CLIENT */
-
-@@ -413,29 +414,28 @@
- pretty_print_str()
- */
-
--static char *pretty_print_str(char *packet, const char *str, int len)
-+static void
-+pretty_print_str(String *packet, const char *str, int len)
- {
- const char *end= str + len;
-- char *pos= packet;
-- *pos++= '\'';
-+ packet->append(STRING_WITH_LEN("'"));
- while (str < end)
- {
- char c;
- switch ((c=*str++)) {
-- case '\n': *pos++= '\\'; *pos++= 'n'; break;
-- case '\r': *pos++= '\\'; *pos++= 'r'; break;
-- case '\\': *pos++= '\\'; *pos++= '\\'; break;
-- case '\b': *pos++= '\\'; *pos++= 'b'; break;
-- case '\t': *pos++= '\\'; *pos++= 't'; break;
-- case '\'': *pos++= '\\'; *pos++= '\''; break;
-- case 0 : *pos++= '\\'; *pos++= '0'; break;
-+ case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
-+ case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
-+ case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
-+ case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
-+ case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
-+ case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
-+ case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
- default:
-- *pos++= c;
-+ packet->append(&c, 1);
- break;
- }
- }
-- *pos++= '\'';
-- return pos;
-+ packet->append(STRING_WITH_LEN("'"));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -861,7 +861,7 @@
- Log_event::pack_info()
- */
-
--void Log_event::pack_info(Protocol *protocol)
-+void Log_event::pack_info(THD *thd, Protocol *protocol)
- {
- protocol->store("", &my_charset_bin);
- }
-@@ -870,7 +870,8 @@
- /**
- Only called by SHOW BINLOG EVENTS
- */
--int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
-+int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos)
- {
- const char *p= strrchr(log_name, FN_LIBCHAR);
- const char *event_type;
-@@ -884,7 +885,7 @@
- protocol->store(event_type, strlen(event_type), &my_charset_bin);
- protocol->store((uint32) server_id);
- protocol->store((ulonglong) log_pos);
-- pack_info(protocol);
-+ pack_info(thd, protocol);
- return protocol->write();
- }
- #endif /* HAVE_REPLICATION */
-@@ -2139,27 +2140,22 @@
- show the catalog ??
- */
-
--void Query_log_event::pack_info(Protocol *protocol)
-+void Query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- // TODO: show the catalog ??
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len);
- if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
- && db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf.append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, &buf, db, db_len);
-+ buf.append("; ");
- }
- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ buf.append(query, q_len);
-+ protocol->store(&buf);
- }
- #endif
-
-@@ -2924,11 +2920,17 @@
- }
- else if (db)
- {
-+ /* Room for expand ` to `` + initial/final ` + \0 */
-+ char buf[FN_REFLEN*2+3];
-+
- different_db= memcmp(print_event_info->db, db, db_len + 1);
- if (different_db)
- memcpy(print_event_info->db, db, db_len + 1);
- if (db[0] && different_db)
-- my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
-+ {
-+ my_snprintf(buf, sizeof(buf), "%`s", db);
-+ my_b_printf(file, "use %s%s\n", buf, print_event_info->delimiter);
-+ }
- }
-
- end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
-@@ -3545,7 +3547,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Start_log_event_v3::pack_info(Protocol *protocol)
-+void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
- pos= strmov(buf, "Server ver: ");
-@@ -4194,131 +4196,115 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--uint Load_log_event::get_query_buffer_length()
--{
-- return
-- 5 + db_len + 3 + // "use DB; "
-- 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
-- 11 + // "CONCURRENT "
-- 7 + // LOCAL
-- 9 + // " REPLACE or IGNORE "
-- 13 + table_name_len*2 + // "INTO TABLE `table`"
-- 21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
-- 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
-- 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
-- 21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
-- 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
-- 15 + 22 + // " IGNORE xxx LINES"
-- 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
--}
--
--
--void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
-- char **end, char **fn_start, char **fn_end)
--{
-- char *pos= buf;
--
-+void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
-+ String *buf, my_off_t *fn_start,
-+ my_off_t *fn_end, const char *qualify_db)
-+{
- if (need_db && db && db_len)
- {
-- pos= strmov(pos, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf->append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, buf, db, db_len);
-+ buf->append(STRING_WITH_LEN("; "));
- }
-
-- pos= strmov(pos, "LOAD DATA ");
-+ buf->append(STRING_WITH_LEN("LOAD DATA "));
-
- if (thd->lex->lock_option == TL_WRITE_CONCURRENT_INSERT)
-- pos= strmov(pos, "CONCURRENT ");
-+ buf->append(STRING_WITH_LEN("CONCURRENT "));
-
- if (fn_start)
-- *fn_start= pos;
-+ *fn_start= buf->length();
-
- if (check_fname_outside_temp_buf())
-- pos= strmov(pos, "LOCAL ");
-- pos= strmov(pos, "INFILE '");
-- memcpy(pos, fname, fname_len);
-- pos= strmov(pos+fname_len, "' ");
-+ buf->append(STRING_WITH_LEN("LOCAL "));
-+ buf->append(STRING_WITH_LEN("INFILE '"));
-+ buf->append_for_single_quote(fname, fname_len);
-+ buf->append(STRING_WITH_LEN("' "));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
-- pos= strmov(pos, "REPLACE ");
-+ buf->append(STRING_WITH_LEN("REPLACE "));
- else if (sql_ex.opt_flags & IGNORE_FLAG)
-- pos= strmov(pos, "IGNORE ");
-+ buf->append(STRING_WITH_LEN("IGNORE "));
-
-- pos= strmov(pos ,"INTO");
-+ buf->append(STRING_WITH_LEN("INTO"));
-
- if (fn_end)
-- *fn_end= pos;
-+ *fn_end= buf->length();
-
-- pos= strmov(pos ," TABLE `");
-- memcpy(pos, table_name, table_name_len);
-- pos+= table_name_len;
-+ buf->append(STRING_WITH_LEN(" TABLE "));
-+ if (qualify_db)
-+ {
-+ append_identifier(thd, buf, qualify_db, strlen(qualify_db));
-+ buf->append(STRING_WITH_LEN("."));
-+ }
-+ append_identifier(thd, buf, table_name, table_name_len);
-
- if (cs != NULL)
- {
-- pos= strmov(pos ,"` CHARACTER SET ");
-- pos= strmov(pos , cs);
-+ buf->append(STRING_WITH_LEN(" CHARACTER SET "));
-+ buf->append(cs, strlen(cs));
- }
-- else
-- pos= strmov(pos, "`");
-
- /* We have to create all optional fields as the default is not empty */
-- pos= strmov(pos, " FIELDS TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
-+ buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
- if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
-- pos= strmov(pos, " OPTIONALLY ");
-- pos= strmov(pos, " ENCLOSED BY ");
-- pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
--
-- pos= strmov(pos, " ESCAPED BY ");
-- pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
--
-- pos= strmov(pos, " LINES TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
-+ buf->append(STRING_WITH_LEN(" OPTIONALLY "));
-+ buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
-+ pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
-+
-+ buf->append(STRING_WITH_LEN(" ESCAPED BY "));
-+ pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
-+
-+ buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
- if (sql_ex.line_start_len)
- {
-- pos= strmov(pos, " STARTING BY ");
-- pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
-+ buf->append(STRING_WITH_LEN(" STARTING BY "));
-+ pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
- }
-
- if ((long) skip_lines > 0)
- {
-- pos= strmov(pos, " IGNORE ");
-- pos= longlong10_to_str((longlong) skip_lines, pos, 10);
-- pos= strmov(pos," LINES ");
-+ char skipbuf[22];
-+ buf->append(STRING_WITH_LEN(" IGNORE "));
-+ longlong10_to_str((longlong) skip_lines, skipbuf, 10);
-+ buf->append(skipbuf);
-+ buf->append(STRING_WITH_LEN(" LINES "));
- }
-
- if (num_fields)
- {
- uint i;
- const char *field= fields;
-- pos= strmov(pos, " (");
-+ buf->append(STRING_WITH_LEN(" ("));
- for (i = 0; i < num_fields; i++)
- {
- if (i)
- {
-- *pos++= ' ';
-- *pos++= ',';
-+ /*
-+ Yes, the space and comma is reversed here. But this is mostly dead
-+ code, at most used when reading really old binlogs from old servers,
-+ so better just leave it as is...
-+ */
-+ buf->append(STRING_WITH_LEN(" ,"));
- }
-- memcpy(pos, field, field_lens[i]);
-- pos+= field_lens[i];
-+ append_identifier(thd, buf, field, field_lens[i]);
- field+= field_lens[i] + 1;
- }
-- *pos++= ')';
-+ buf->append(STRING_WITH_LEN(")"));
- }
--
-- *end= pos;
- }
-
-
--void Load_log_event::pack_info(Protocol *protocol)
-+void Load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *end;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
-
-- if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
-- return;
-- print_query(TRUE, NULL, buf, &end, 0, 0);
-- protocol->store(buf, end-buf, &my_charset_bin);
-- my_free(buf, MYF(0));
-+ query_str.length(0);
-+ print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
-+ protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
- }
- #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-
-@@ -4585,7 +4571,7 @@
- else if (sql_ex.opt_flags & IGNORE_FLAG)
- my_b_printf(&cache,"IGNORE ");
-
-- my_b_printf(&cache, "INTO TABLE `%s`", table_name);
-+ my_b_printf(&cache, "INTO TABLE %`s", table_name);
- my_b_printf(&cache, " FIELDS TERMINATED BY ");
- pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
-
-@@ -4774,16 +4760,20 @@
- else
- {
- char llbuff[22];
-- char *end;
- enum enum_duplicates handle_dup;
- bool ignore= 0;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
- char *load_data_query;
-
-+ query_str.length(0);
- /*
- Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
- and written to slave's binlog if binlogging is on.
- */
-- if (!(load_data_query= (char *)thd->alloc(get_query_buffer_length() + 1)))
-+ print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(),
-+ query_str.length())))
- {
- /*
- This will set thd->fatal_error in case of OOM. So we surely will notice
-@@ -4792,9 +4782,7 @@
- goto error;
- }
-
-- print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
-- *end= 0;
-- thd->set_query(load_data_query, (uint) (end - load_data_query));
-+ thd->set_query(load_data_query, (uint) (query_str.length()));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
- {
-@@ -4959,7 +4947,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rotate_log_event::pack_info(Protocol *protocol)
-+void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], buf[22];
- String tmp(buf1, sizeof(buf1), log_cs);
-@@ -5174,7 +5162,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Intvar_log_event::pack_info(Protocol *protocol)
-+void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256], *pos;
- pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
-@@ -5323,7 +5311,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rand_log_event::pack_info(Protocol *protocol)
-+void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], *pos;
- pos= strmov(buf1,"rand_seed1=");
-@@ -5421,7 +5409,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Xid_log_event::pack_info(Protocol *protocol)
-+void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[128], *pos;
- pos= strmov(buf, "COMMIT /* xid=");
-@@ -5508,69 +5496,109 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void User_var_log_event::pack_info(Protocol* protocol)
-+static bool
-+user_var_append_name_part(THD *thd, String *buf,
-+ const char *name, size_t name_len)
- {
-- char *buf= 0;
-- uint val_offset= 4 + name_len;
-- uint event_len= val_offset;
-+ return buf->append("@") ||
-+ append_identifier(thd, buf, name, name_len) ||
-+ buf->append("=");
-+}
-
-+void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
-+{
- if (is_null)
- {
-- if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
-+ char buf_mem[FN_REFLEN+7];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("NULL"))
- return;
-- strmov(buf + val_offset, "NULL");
-- event_len= val_offset + 4;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
- else
- {
- switch (type) {
- case REAL_RESULT:
-+ {
- double real_val;
-+ char buf2[FLOATING_POINT_BUFFER];
-+ char buf_mem[FN_REFLEN + FLOATING_POINT_BUFFER];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- float8get(real_val, val);
-- if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
-- MYF(MY_WME))))
-- return;
-- event_len+= my_sprintf(buf + val_offset,
-- (buf + val_offset, "%.14g", real_val));
-+ buf.length(0);
-+ my_sprintf(buf2, (buf2, "%.14g", real_val));
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case INT_RESULT:
-- if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
-+ {
-+ char buf2[22];
-+ char buf_mem[FN_REFLEN + 22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2, longlong10_to_str(uint8korr(val), buf2, -10)-buf2))
- return;
-- event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case DECIMAL_RESULT:
- {
-- if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
-- MYF(MY_WME))))
-- return;
-- String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
-+ char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ char buf2[DECIMAL_MAX_STR_LENGTH+1];
-+ String str(buf2, sizeof(buf2), &my_charset_bin);
- my_decimal dec;
-+ buf.length(0);
- binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
- val[1]);
- my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
-- event_len= str.length() + val_offset;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
- }
- case STRING_RESULT:
-+ {
- /* 15 is for 'COLLATE' and other chars */
-- buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
-- MYF(MY_WME));
-+ char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- CHARSET_INFO *cs;
-- if (!buf)
-- return;
-+ buf.length(0);
- if (!(cs= get_charset(charset_number, MYF(0))))
- {
-- strmov(buf+val_offset, "???");
-- event_len+= 3;
-+ if (buf.append("???"))
-+ return;
- }
- else
- {
-- char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
-- p= str_to_hex(p, val, val_len);
-- p= strxmov(p, " COLLATE ", cs->name, NullS);
-- event_len= p-buf;
-+ size_t old_len;
-+ char *beg, *end;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("_") ||
-+ buf.append(cs->csname) ||
-+ buf.append(" "))
-+ return;
-+ old_len= buf.length();
-+ if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
-+ MY_CS_NAME_SIZE))
-+ return;
-+ beg= const_cast<char *>(buf.ptr()) + old_len;
-+ end= str_to_hex(beg, val, val_len);
-+ buf.length(old_len + (end - beg));
-+ if (buf.append(" COLLATE ") ||
-+ buf.append(cs->name))
-+ return;
- }
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
- default:
-@@ -5578,13 +5606,6 @@
- return;
- }
- }
-- buf[0]= '@';
-- buf[1]= '`';
-- memcpy(buf+2, name, name_len);
-- buf[2+name_len]= '`';
-- buf[3+name_len]= '=';
-- protocol->store(buf, event_len, &my_charset_bin);
-- my_free(buf, MYF(0));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -5700,9 +5721,8 @@
- my_b_printf(&cache, "\tUser_var\n");
- }
-
-- my_b_printf(&cache, "SET @`");
-- my_b_write(&cache, (uchar*) name, (uint) (name_len));
-- my_b_printf(&cache, "`");
-+ my_b_printf(&cache, "SET @");
-+ my_b_write_backtick_quote(&cache, name, name_len);
-
- if (is_null)
- {
-@@ -5775,7 +5795,7 @@
- */
- my_b_printf(&cache, ":=???%s\n", print_event_info->delimiter);
- else
-- my_b_printf(&cache, ":=_%s %s COLLATE `%s`%s\n",
-+ my_b_printf(&cache, ":=_%s %s COLLATE %`s%s\n",
- cs->csname, hex_str, cs->name,
- print_event_info->delimiter);
- my_afree(hex_str);
-@@ -5914,7 +5934,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
--void Slave_log_event::pack_info(Protocol *protocol)
-+void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256+HOSTNAME_LENGTH], *pos;
- pos= strmov(buf, "host=");
-@@ -6286,7 +6306,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Create_file_log_event::pack_info(Protocol *protocol)
-+void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos;
- pos= strmov(buf, "db=");
-@@ -6467,7 +6487,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Append_block_log_event::pack_info(Protocol *protocol)
-+void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- uint length;
-@@ -6619,7 +6639,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Delete_file_log_event::pack_info(Protocol *protocol)
-+void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -6717,7 +6737,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_log_event::pack_info(Protocol *protocol)
-+void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -6970,27 +6990,26 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_query_log_event::pack_info(Protocol *protocol)
-+void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ char file_id_buf[22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len + 10 + 21);
- if (db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-- }
-- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- pos= strmov(pos, " ;file_id=");
-- pos= int10_to_str((long) file_id, pos, 10);
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ if (buf.append("use ") ||
-+ append_identifier(thd, &buf, db, db_len) ||
-+ buf.append("; "))
-+ return;
-+ }
-+ if (query && q_len && buf.append(query, q_len))
-+ return;
-+ int10_to_str((long) file_id, file_id_buf, 10);
-+ if (buf.append(" ;file_id=") ||
-+ buf.append(file_id_buf))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
-
-
-@@ -7932,7 +7951,7 @@
- #endif
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rows_log_event::pack_info(Protocol *protocol)
-+void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-@@ -8533,7 +8552,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Table_map_log_event::pack_info(Protocol *protocol)
-+void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes= my_snprintf(buf, sizeof(buf),
-@@ -8554,7 +8573,7 @@
- {
- print_header(&print_event_info->head_cache, print_event_info, TRUE);
- my_b_printf(&print_event_info->head_cache,
-- "\tTable_map: `%s`.`%s` mapped to number %lu\n",
-+ "\tTable_map: %`s.%`s mapped to number %lu\n",
- m_dbnam, m_tblnam, m_table_id);
- print_base64(&print_event_info->body_cache, print_event_info, TRUE);
- }
-@@ -9747,7 +9766,7 @@
-
-
- #ifndef MYSQL_CLIENT
--void Incident_log_event::pack_info(Protocol *protocol)
-+void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes;
-
-=== modified file 'sql/log_event.h'
---- sql/log_event.h 2011-11-21 17:13:14 +0000
-+++ sql/log_event.h 2012-08-24 08:06:16 +0000
-@@ -947,14 +947,15 @@
- */
- static void init_show_field_list(List<Item>* field_list);
- #ifdef HAVE_REPLICATION
-- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
-+ int net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos);
-
- /*
- pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
- a string to display to the user, so it resembles print().
- */
-
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
-
- #endif /* HAVE_REPLICATION */
- virtual const char* get_db()
-@@ -1649,7 +1650,7 @@
- bool using_trans, bool suppress_use, int error);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -1779,7 +1780,7 @@
-
- #ifndef MYSQL_CLIENT
- Slave_log_event(THD* thd_arg, Relay_log_info* rli);
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2012,9 +2013,11 @@
- const Format_description_log_event* description_event);
-
- public:
-- uint get_query_buffer_length();
-- void print_query(bool need_db, const char *cs, char *buf, char **end,
-- char **fn_start, char **fn_end);
-+#ifndef MYSQL_CLIENT
-+ void print_query(THD *thd, bool need_db, const char *cs, String *buf,
-+ my_off_t *fn_start, my_off_t *fn_end,
-+ const char *qualify_db);
-+#endif
- ulong thread_id;
- ulong slave_proxy_id;
- uint32 table_name_len;
-@@ -2062,7 +2065,7 @@
- Name_resolution_context *context);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2161,7 +2164,7 @@
- #ifndef MYSQL_CLIENT
- Start_log_event_v3();
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- Start_log_event_v3() {}
-@@ -2313,7 +2316,7 @@
- :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
- {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2389,7 +2392,7 @@
- :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
- {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2433,7 +2436,7 @@
- #ifndef MYSQL_CLIENT
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2482,7 +2485,7 @@
- :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
- val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
- { is_null= !val; }
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2613,7 +2616,7 @@
- uint ident_len_arg,
- ulonglong pos_arg, uint flags);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2673,7 +2676,7 @@
- uchar* block_arg, uint block_len_arg,
- bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2745,7 +2748,7 @@
- Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
- uint block_len_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- virtual int get_create_or_append() const;
- #endif /* HAVE_REPLICATION */
- #else
-@@ -2786,7 +2789,7 @@
- #ifndef MYSQL_CLIENT
- Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2827,7 +2830,7 @@
- #ifndef MYSQL_CLIENT
- Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2923,7 +2926,7 @@
- bool using_trans, bool suppress_use,
- int errcode);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3368,7 +3371,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3480,7 +3483,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3917,7 +3920,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
-- void pack_info(Protocol*);
-+ void pack_info(THD *thd, Protocol*);
- #endif
-
- Incident_log_event(const char *buf, uint event_len,
-
-=== modified file 'sql/log_event_old.cc'
---- sql/log_event_old.cc 2011-11-21 17:13:14 +0000
-+++ sql/log_event_old.cc 2012-08-24 08:06:16 +0000
-@@ -2003,7 +2003,7 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Old_rows_log_event::pack_info(Protocol *protocol)
-+void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-
-=== modified file 'sql/log_event_old.h'
---- sql/log_event_old.h 2011-02-20 16:51:43 +0000
-+++ sql/log_event_old.h 2012-08-24 08:06:16 +0000
-@@ -108,7 +108,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-
-=== modified file 'sql/mysql_priv.h'
---- sql/mysql_priv.h 2012-05-17 10:12:33 +0000
-+++ sql/mysql_priv.h 2012-08-24 08:06:16 +0000
-@@ -1371,7 +1371,7 @@
- /* sql_show.cc */
- bool mysqld_show_open_tables(THD *thd,const char *wild);
- bool mysqld_show_logs(THD *thd);
--void append_identifier(THD *thd, String *packet, const char *name,
-+bool append_identifier(THD *thd, String *packet, const char *name,
- uint length);
- #endif /* MYSQL_SERVER */
- #if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-
-=== modified file 'sql/sql_base.cc'
---- sql/sql_base.cc 2011-11-30 16:44:51 +0000
-+++ sql/sql_base.cc 2012-08-24 08:06:16 +0000
-@@ -4172,22 +4172,22 @@
- entry->file->implicit_emptied= 0;
- if (mysql_bin_log.is_open())
- {
-- char *query, *end;
-- uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
-- if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
-+ char query_buf[2*FN_REFLEN + 21];
-+ String query(query_buf, sizeof(query_buf), system_charset_info);
-+ query.length(0);
-+ if (query.ptr())
- {
- /* this DELETE FROM is needed even with row-based binlogging */
-- end = strxmov(strmov(query, "DELETE FROM `"),
-- share->db.str,"`.`",share->table_name.str,"`", NullS);
-+ query.append("DELETE FROM ");
-+ append_identifier(thd, &query, share->db.str, share->db.length);
-+ query.append(".");
-+ append_identifier(thd, &query, share->table_name.str,
-+ share->table_name.length);
- int errcode= query_error_code(thd, TRUE);
- if (thd->binlog_query(THD::STMT_QUERY_TYPE,
-- query, (ulong)(end-query),
-+ query.ptr(), query.length(),
- FALSE, FALSE, errcode))
-- {
-- my_free(query, MYF(0));
- goto err;
-- }
-- my_free(query, MYF(0));
- }
- else
- {
-@@ -4197,7 +4197,7 @@
- because of MYF(MY_WME) in my_malloc() above).
- */
- sql_print_error("When opening HEAP table, could not allocate memory "
-- "to write 'DELETE FROM `%s`.`%s`' to the binary log",
-+ "to write 'DELETE FROM %`s.%`s' to the binary log",
- table_list->db, table_list->table_name);
- delete entry->triggers;
- closefrm(entry, 0);
-
-=== modified file 'sql/sql_db.cc'
---- sql/sql_db.cc 2011-11-21 17:13:14 +0000
-+++ sql/sql_db.cc 2012-08-24 08:06:16 +0000
-@@ -612,7 +612,6 @@
- bool silent)
- {
- char path[FN_REFLEN+16];
-- char tmp_query[FN_REFLEN+16];
- long result= 1;
- int error= 0;
- MY_STAT stat_info;
-@@ -719,17 +718,9 @@
- char *query;
- uint query_length;
-
-- if (!thd->query()) // Only in replication
-- {
-- query= tmp_query;
-- query_length= (uint) (strxmov(tmp_query,"create database `",
-- db, "`", NullS) - tmp_query);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-
- ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB,
- query, query_length,
-@@ -989,18 +980,11 @@
- {
- const char *query;
- ulong query_length;
-- if (!thd->query())
-- {
-- /* The client used the old obsolete mysql_drop_db() call */
-- query= path;
-- query_length= (uint) (strxmov(path, "drop database `", db, "`",
-- NullS) - path);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-+
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
-@@ -1041,9 +1025,10 @@
- for (tbl= dropped_tables; tbl; tbl= tbl->next_local)
- {
- uint tbl_name_len;
-+ char quoted_name[FN_REFLEN+3];
-
-- /* 3 for the quotes and the comma*/
-- tbl_name_len= strlen(tbl->table_name) + 3;
-+ my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name);
-+ tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
- if (query_pos + tbl_name_len + 1 >= query_end)
- {
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
-@@ -1055,9 +1040,7 @@
- query_pos= query_data_start;
- }
-
-- *query_pos++ = '`';
-- query_pos= strmov(query_pos,tbl->table_name);
-- *query_pos++ = '`';
-+ query_pos= strmov(query_pos, quoted_name);
- *query_pos++ = ',';
- }
-
-
-=== modified file 'sql/sql_insert.cc'
---- sql/sql_insert.cc 2011-11-23 17:32:14 +0000
-+++ sql/sql_insert.cc 2012-08-24 08:06:16 +0000
-@@ -3457,16 +3457,16 @@
- if (thd->lex->create_select_in_comment)
- query.append(STRING_WITH_LEN("/*! "));
- if (thd->lex->ignore)
-- query.append(STRING_WITH_LEN("INSERT IGNORE INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT IGNORE INTO "));
- else if (thd->lex->duplicates == DUP_REPLACE)
-- query.append(STRING_WITH_LEN("REPLACE INTO `"));
-+ query.append(STRING_WITH_LEN("REPLACE INTO "));
- else
-- query.append(STRING_WITH_LEN("INSERT INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT INTO "));
-
-- query.append(create_table->db, db_len);
-- query.append(STRING_WITH_LEN("`.`"));
-- query.append(create_info->alias, table_len);
-- query.append(STRING_WITH_LEN("` "));
-+ append_identifier(thd, &query, create_table->db, db_len);
-+ query.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &query, create_info->alias, table_len);
-+ query.append(STRING_WITH_LEN(" "));
-
- /*
- The insert items.
-
-=== modified file 'sql/sql_load.cc'
---- sql/sql_load.cc 2012-04-05 08:49:38 +0000
-+++ sql/sql_load.cc 2012-08-24 08:06:16 +0000
-@@ -24,6 +24,7 @@
- #include "sql_repl.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "sql_show.h"
-
- class READ_INFO {
- File file;
-@@ -606,20 +607,28 @@
- bool transactional_table,
- int errcode)
- {
-- char *load_data_query,
-- *end,
-- *fname_start,
-- *fname_end,
-- *p= NULL;
-- size_t pl= 0;
-+ char *load_data_query;
-+ my_off_t fname_start,
-+ fname_end;
- List<Item> fv;
- Item *item, *val;
-- String pfield, pfields;
- int n;
-- const char *tbl= table_name_arg;
- const char *tdb= (thd->db != NULL ? thd->db : db_arg);
-- String string_buf;
--
-+ const char *qualify_db= NULL;
-+ char command_buffer[1024];
-+ String query_str(command_buffer, sizeof(command_buffer),
-+ system_charset_info);
-+
-+ Load_log_event lle(thd, ex, tdb, table_name_arg, fv, duplicates,
-+ ignore, transactional_table);
-+
-+ /*
-+ force in a LOCAL if there was one in the original.
-+ */
-+ if (thd->lex->local_file)
-+ lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+
-+ query_str.length(0);
- if (!thd->db || strcmp(db_arg, thd->db))
- {
- /*
-@@ -627,23 +636,10 @@
- prefix table name with database name so that it
- becomes a FQ name.
- */
-- string_buf.set_charset(system_charset_info);
-- string_buf.append(db_arg);
-- string_buf.append("`");
-- string_buf.append(".");
-- string_buf.append("`");
-- string_buf.append(table_name_arg);
-- tbl= string_buf.c_ptr_safe();
-+ qualify_db= db_arg;
- }
--
-- Load_log_event lle(thd, ex, tdb, tbl, fv, duplicates,
-- ignore, transactional_table);
--
-- /*
-- force in a LOCAL if there was one in the original.
-- */
-- if (thd->lex->local_file)
-- lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+ lle.print_query(thd, FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-+ &query_str, &fname_start, &fname_end, qualify_db);
-
- /*
- prepare fields-list and SET if needed; print_query won't do that for us.
-@@ -652,23 +648,19 @@
- {
- List_iterator<Item> li(thd->lex->field_list);
-
-- pfields.append(" (");
-+ query_str.append(" (");
- n= 0;
-
- while ((item= li++))
- {
- if (n++)
-- pfields.append(", ");
-+ query_str.append(", ");
- if (item->name)
-- {
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- }
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
- else
-- item->print(&pfields, QT_ORDINARY);
-+ ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
- }
-- pfields.append(")");
-+ query_str.append(")");
- }
-
- if (!thd->lex->update_list.is_empty())
-@@ -676,39 +668,26 @@
- List_iterator<Item> lu(thd->lex->update_list);
- List_iterator<Item> lv(thd->lex->value_list);
-
-- pfields.append(" SET ");
-+ query_str.append(" SET ");
- n= 0;
-
- while ((item= lu++))
- {
- val= lv++;
- if (n++)
-- pfields.append(", ");
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- pfields.append("=");
-- val->print(&pfields, QT_ORDINARY);
-+ query_str.append(", ");
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
-+ query_str.append("=");
-+ val->print(&query_str, QT_ORDINARY);
- }
- }
-
-- p= pfields.c_ptr_safe();
-- pl= strlen(p);
--
-- if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(), query_str.length())))
- return TRUE;
-
-- lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-- load_data_query, &end,
-- (char **)&fname_start, (char **)&fname_end);
--
-- strcpy(end, p);
-- end += pl;
--
- Execute_load_query_log_event
-- e(thd, load_data_query, end-load_data_query,
-- (uint) ((char*) fname_start - load_data_query - 1),
-- (uint) ((char*) fname_end - load_data_query),
-+ e(thd, load_data_query, query_str.length(),
-+ (uint) (fname_start - 1), (uint) fname_end,
- (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
- (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
- transactional_table, FALSE, errcode);
-
-=== modified file 'sql/sql_repl.cc'
---- sql/sql_repl.cc 2011-11-21 17:13:14 +0000
-+++ sql/sql_repl.cc 2012-08-24 08:06:16 +0000
-@@ -1554,7 +1554,7 @@
- description_event)); )
- {
- if (event_count >= limit_start &&
-- ev->net_send(protocol, linfo.log_file_name, pos))
-+ ev->net_send(thd, protocol, linfo.log_file_name, pos))
- {
- errmsg = "Net error";
- delete ev;
-
-=== modified file 'sql/sql_show.cc'
---- sql/sql_show.cc 2012-05-17 10:12:33 +0000
-+++ sql/sql_show.cc 2012-08-24 08:06:16 +0000
-@@ -1019,9 +1019,13 @@
- packet target string
- name the identifier to be appended
- name_length length of the appending identifier
-+
-+ RETURN VALUES
-+ true Error
-+ false Ok
- */
-
--void
-+bool
- append_identifier(THD *thd, String *packet, const char *name, uint length)
- {
- const char *name_end;
-@@ -1029,10 +1033,7 @@
- int q= get_quote_char_for_identifier(thd, name, length);
-
- if (q == EOF)
-- {
-- packet->append(name, length, packet->charset());
-- return;
-- }
-+ return packet->append(name, length, packet->charset());
-
- /*
- The identifier must be quoted as it includes a quote character or
-@@ -1041,7 +1042,8 @@
-
- VOID(packet->reserve(length*2 + 2));
- quote_char= (char) q;
-- packet->append(&quote_char, 1, system_charset_info);
-+ if (packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-
- for (name_end= name+length ; name < name_end ; name+= length)
- {
-@@ -1056,11 +1058,13 @@
- */
- if (!length)
- length= 1;
-- if (length == 1 && chr == (uchar) quote_char)
-- packet->append(&quote_char, 1, system_charset_info);
-- packet->append(name, length, system_charset_info);
-+ if (length == 1 && chr == (uchar) quote_char &&
-+ packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-+ if (packet->append(name, length, system_charset_info))
-+ return true;
- }
-- packet->append(&quote_char, 1, system_charset_info);
-+ return packet->append(&quote_char, 1, system_charset_info);
- }
-
-
-
-=== modified file 'sql/sql_string.cc'
---- sql/sql_string.cc 2012-04-05 08:49:38 +0000
-+++ sql/sql_string.cc 2012-08-24 08:06:16 +0000
-@@ -1157,39 +1157,47 @@
-
-
-
--
--void String::print(String *str)
-+/*
-+ Append characters to a single-quoted string '...', escaping special
-+ characters as necessary.
-+ Does not add the enclosing quotes, this is left up to caller.
-+*/
-+void String::append_for_single_quote(const char *st, uint len)
- {
-- char *st= (char*)Ptr, *end= st+str_length;
-+ const char *end= st+len;
- for (; st < end; st++)
- {
- uchar c= *st;
- switch (c)
- {
- case '\\':
-- str->append(STRING_WITH_LEN("\\\\"));
-+ append(STRING_WITH_LEN("\\\\"));
- break;
- case '\0':
-- str->append(STRING_WITH_LEN("\\0"));
-+ append(STRING_WITH_LEN("\\0"));
- break;
- case '\'':
-- str->append(STRING_WITH_LEN("\\'"));
-+ append(STRING_WITH_LEN("\\'"));
- break;
- case '\n':
-- str->append(STRING_WITH_LEN("\\n"));
-+ append(STRING_WITH_LEN("\\n"));
- break;
- case '\r':
-- str->append(STRING_WITH_LEN("\\r"));
-+ append(STRING_WITH_LEN("\\r"));
- break;
- case '\032': // Ctrl-Z
-- str->append(STRING_WITH_LEN("\\Z"));
-+ append(STRING_WITH_LEN("\\Z"));
- break;
- default:
-- str->append(c);
-+ append(c);
- }
- }
- }
-
-+void String::print(String *str)
-+{
-+ str->append_for_single_quote(Ptr, str_length);
-+}
-
- /*
- Exchange state of this object and argument.
-
-=== modified file 'sql/sql_string.h'
---- sql/sql_string.h 2011-11-21 17:13:14 +0000
-+++ sql/sql_string.h 2012-08-24 08:06:16 +0000
-@@ -385,6 +385,7 @@
- return FALSE;
- }
- void print(String *print);
-+ void append_for_single_quote(const char *st, uint len);
-
- /* Swap two string objects. Efficient way to exchange data without memcpy. */
- void swap(String &s);
-
-=== modified file 'sql/sql_table.cc'
---- sql/sql_table.cc 2012-04-05 08:49:38 +0000
-+++ sql/sql_table.cc 2012-08-24 08:06:16 +0000
-@@ -1945,6 +1945,7 @@
- for (table= tables; table; table= table->next_local)
- {
- char *db=table->db;
-+ size_t db_length= table->db_length;
- handlerton *table_type;
- enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN;
-
-@@ -1967,14 +1968,14 @@
- built_tmp_query.append("DROP TEMPORARY TABLE IF EXISTS ");
- }
-
-- built_tmp_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_tmp_query.append(db);
-- built_tmp_query.append("`.`");
-+ append_identifier(thd, &built_tmp_query, db, db_length);
-+ built_tmp_query.append(".");
- }
-- built_tmp_query.append(table->table_name);
-- built_tmp_query.append("`,");
-+ append_identifier(thd, &built_tmp_query, table->table_name,
-+ table->table_name_length);
-+ built_tmp_query.append(",");
- }
-
- continue;
-@@ -2000,15 +2001,15 @@
- Don't write the database name if it is the current one (or if
- thd->db is NULL).
- */
-- built_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_query.append(db);
-- built_query.append("`.`");
-+ append_identifier(thd, &built_query, db, db_length);
-+ built_query.append(".");
- }
-
-- built_query.append(table->table_name);
-- built_query.append("`,");
-+ append_identifier(thd, &built_query, table->table_name,
-+ table->table_name_length);
-+ built_query.append(",");
- }
-
- if (!drop_temporary)
-
-=== modified file 'strings/my_vsnprintf.c'
---- strings/my_vsnprintf.c 2011-11-21 17:13:14 +0000
-+++ strings/my_vsnprintf.c 2012-08-24 08:06:16 +0000
-@@ -19,6 +19,57 @@
- #include <m_ctype.h>
- #include <stdarg.h>
-
-+
-+/**
-+ Returns escaped string
-+
-+ @param cs string charset
-+ @param to buffer where escaped string will be placed
-+ @param end end of buffer
-+ @param par string to escape
-+ @param par_len string length
-+ @param quote_char character for quoting
-+
-+ @retval
-+ position in buffer which points on the end of escaped string
-+*/
-+
-+static char *backtick_string(char *to, char *end, char *par,
-+ size_t par_len, char quote_char)
-+{
-+ char *start= to;
-+ char *par_end= par + par_len;
-+ size_t buff_length= (size_t) (end - to);
-+
-+ if (buff_length <= par_len)
-+ goto err;
-+ *start++= quote_char;
-+
-+ for ( ; par < par_end; ++par)
-+ {
-+ char c= *par;
-+ if (c == quote_char)
-+ {
-+ if (start + 1 >= end)
-+ goto err;
-+ *start++= quote_char;
-+ }
-+ if (start + 1 >= end)
-+ goto err;
-+ *start++= c;
-+ }
-+
-+ if (start + 1 >= end)
-+ goto err;
-+ *start++= quote_char;
-+ return start;
-+
-+err:
-+ *to='\0';
-+ return to;
-+}
-+
-+
- /*
- Limited snprintf() implementations
-
-@@ -45,7 +96,7 @@
- {
- char *start=to, *end=to+n-1;
- size_t length, width;
-- uint pre_zero, have_long;
-+ uint pre_zero, have_long, escaped_arg;
-
- for (; *fmt ; fmt++)
- {
-@@ -61,7 +112,7 @@
- if (*fmt == '-')
- fmt++;
- length= width= 0;
-- pre_zero= have_long= 0;
-+ pre_zero= have_long= escaped_arg= 0;
- if (*fmt == '*')
- {
- fmt++;
-@@ -93,6 +144,11 @@
- fmt++;
- have_long= 1;
- }
-+ if (*fmt == '`')
-+ {
-+ fmt++;
-+ escaped_arg= 1;
-+ }
- if (*fmt == 's') /* String parameter */
- {
- reg2 char *par = va_arg(ap, char *);
-@@ -101,7 +157,10 @@
- plen= (uint) strnlen(par, width);
- if (left_len <= plen)
- plen = left_len - 1;
-- to=strnmov(to,par,plen);
-+ if (escaped_arg)
-+ to= backtick_string(to, end, par, plen, '`');
-+ else
-+ to= strnmov(to,par,plen);
- continue;
- }
- else if (*fmt == 'b') /* Buffer parameter */
-@@ -185,6 +244,70 @@
- return result;
- }
-
-+/**
-+ Writes output to the stream according to a format string.
-+
-+ @param stream file to write to
-+ @param format string format
-+ @param args list of parameters
-+
-+ @retval
-+ number of the characters written.
-+*/
-+
-+int my_vfprintf(FILE *stream, const char* format, va_list args)
-+{
-+ char cvtbuf[1024];
-+ int alloc= 0;
-+ char *p= cvtbuf;
-+ size_t cur_len= sizeof(cvtbuf);
-+ int ret;
-+
-+ /*
-+ We do not know how much buffer we need.
-+ So start with a reasonably-sized stack-allocated buffer, and increase
-+ it exponentially until it is big enough.
-+ */
-+ for (;;)
-+ {
-+ size_t new_len;
-+ size_t actual= my_vsnprintf(p, cur_len, format, args);
-+ if (actual < cur_len - 1)
-+ break;
-+ /*
-+ Not enough space (or just enough with nothing to spare - but we cannot
-+ distinguish this case from the return value). Allocate a bigger buffer
-+ and try again.
-+ */
-+ if (alloc)
-+ (*my_str_free)(p);
-+ else
-+ alloc= 1;
-+ new_len= cur_len*2;
-+ if (new_len < cur_len)
-+ return 0; /* Overflow */
-+ cur_len= new_len;
-+ p= (*my_str_malloc)(cur_len);
-+ if (!p)
-+ return 0;
-+ }
-+ ret= fprintf(stream, "%s", p);
-+ if (alloc)
-+ (*my_str_free)(p);
-+ return ret;
-+}
-+
-+int my_fprintf(FILE *stream, const char* format, ...)
-+{
-+ int result;
-+ va_list args;
-+ va_start(args, format);
-+ result= my_vfprintf(stream, format, args);
-+ va_end(args);
-+ return result;
-+}
-+
-+
- #ifdef MAIN
- #define OVERRUN_SENTRY 250
- static void my_printf(const char * fmt, ...)
-
diff --git a/21000_all_sql-5.2.12.patch b/21000_all_sql-5.2.12.patch
deleted file mode 100644
index fcbac0c..0000000
--- a/21000_all_sql-5.2.12.patch
+++ /dev/null
@@ -1,3234 +0,0 @@
-=== modified file 'client/mysqlbinlog.cc'
---- client/mysqlbinlog.cc 2011-11-24 16:48:58 +0000
-+++ client/mysqlbinlog.cc 2012-08-24 10:32:46 +0000
-@@ -664,7 +664,7 @@
- return;
-
- // In case of rewrite rule print USE statement for db_to
-- fprintf(result_file, "use %s%s\n", db_to, pinfo->delimiter);
-+ my_fprintf(result_file, "use %`s%s\n", db_to, pinfo->delimiter);
-
- // Copy the *original* db to pinfo to suppress emiting
- // of USE stmts by log_event print-functions.
-
-=== modified file 'include/my_sys.h'
---- include/my_sys.h 2011-11-24 16:48:58 +0000
-+++ include/my_sys.h 2012-08-24 10:32:46 +0000
-@@ -676,6 +676,7 @@
- extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
- extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
- extern int my_fclose(FILE *fd,myf MyFlags);
-+extern int my_fprintf(FILE *stream, const char* format, ...);
- extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
- extern int my_chmod(const char *name, mode_t mode, myf my_flags);
- extern int my_sync(File fd, myf my_flags);
-@@ -811,6 +812,8 @@
- extern void my_b_seek(IO_CACHE *info,my_off_t pos);
- extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
- extern my_off_t my_b_filelength(IO_CACHE *info);
-+extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
-+ size_t len);
- extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
- extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
- extern int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-
-=== modified file 'mysql-test/r/func_compress.result'
---- mysql-test/r/func_compress.result 2009-06-19 09:29:21 +0000
-+++ mysql-test/r/func_compress.result 2012-08-24 08:06:16 +0000
-@@ -11,7 +11,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))`
-+Note 1003 select uncompress(compress((@`test_compress_string`))) AS `uncompress(compress(@test_compress_string))`
- select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
- uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
- 1
-@@ -19,7 +19,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
-+Note 1003 select (uncompressed_length(compress((@`test_compress_string`))) = length((@`test_compress_string`))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
- select uncompressed_length(compress(@test_compress_string));
- uncompressed_length(compress(@test_compress_string))
- 117
-
-=== modified file 'mysql-test/r/mysqlbinlog-innodb.result'
---- mysql-test/r/mysqlbinlog-innodb.result 2011-01-13 12:28:36 +0000
-+++ mysql-test/r/mysqlbinlog-innodb.result 2012-08-24 10:32:46 +0000
-@@ -34,7 +34,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-@@ -65,7 +65,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use foo/*!*/;
-+use `foo`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog.result'
---- mysql-test/r/mysqlbinlog.result 2011-03-25 14:16:13 +0000
-+++ mysql-test/r/mysqlbinlog.result 2012-08-24 08:06:16 +0000
-@@ -18,7 +18,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -64,7 +64,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -97,7 +97,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -119,7 +119,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -165,7 +165,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -198,7 +198,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -220,7 +220,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844556/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-@@ -239,7 +239,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844556/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-@@ -299,7 +299,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -349,7 +349,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -484,7 +484,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1253783037/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -581,22 +581,22 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
- /*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t1 VALUES(40)
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- ROLLBACK TO mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("after rollback to")
- /*!*/;
-@@ -624,7 +624,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog2.result'
---- mysql-test/r/mysqlbinlog2.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/mysqlbinlog2.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -62,7 +62,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -101,7 +101,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -127,7 +127,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -162,7 +162,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -185,7 +185,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -215,7 +215,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -246,7 +246,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -281,7 +281,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -304,7 +304,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -335,7 +335,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -358,7 +358,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -377,7 +377,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -399,7 +399,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -445,7 +445,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -468,7 +468,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -490,7 +490,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -520,7 +520,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -563,7 +563,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -601,7 +601,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -627,7 +627,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -661,7 +661,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -684,7 +684,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -714,7 +714,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -744,7 +744,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -779,7 +779,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -802,7 +802,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -833,7 +833,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -855,7 +855,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -874,7 +874,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -896,7 +896,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -942,7 +942,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -965,7 +965,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -987,7 +987,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1017,7 +1017,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row.result'
---- mysql-test/r/mysqlbinlog_row.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row.result 2012-08-24 08:06:16 +0000
-@@ -336,7 +336,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_innodb.result'
---- mysql-test/r/mysqlbinlog_row_innodb.result 2010-03-22 12:10:18 +0000
-+++ mysql-test/r/mysqlbinlog_row_innodb.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3876,7 +3876,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4243,7 +4243,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4804,7 +4804,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_myisam.result'
---- mysql-test/r/mysqlbinlog_row_myisam.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row_myisam.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3898,7 +3898,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4271,7 +4271,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4842,7 +4842,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_trans.result'
---- mysql-test/r/mysqlbinlog_row_trans.result 2009-08-27 09:32:27 +0000
-+++ mysql-test/r/mysqlbinlog_row_trans.result 2012-08-24 08:06:16 +0000
-@@ -132,7 +132,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/user_var-binlog.result'
---- mysql-test/r/user_var-binlog.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/user_var-binlog.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/variables.result'
---- mysql-test/r/variables.result 2011-09-13 15:46:47 +0000
-+++ mysql-test/r/variables.result 2012-08-24 10:32:46 +0000
-@@ -77,7 +77,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
-+Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@`t1`) AS `@t1`,(@`t2`) AS `@t2`,(@`t3`) AS `@t3`
- select @t5;
- @t5
- 1.23456
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_base64_flag.result'
---- mysql-test/suite/binlog/r/binlog_base64_flag.result 2011-02-23 09:31:37 +0000
-+++ mysql-test/suite/binlog/r/binlog_base64_flag.result 2012-08-24 08:06:16 +0000
-@@ -35,7 +35,7 @@
- # at 4
- <#>ROLLBACK/*!*/;
- # at 102
--<#>use test/*!*/;
-+<#>use `test`/*!*/;
- SET TIMESTAMP=1196959712/*!*/;
- <#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
- SET @@session.sql_mode=0/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result'
---- mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2011-01-13 12:28:36 +0000
-+++ mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2012-08-24 10:32:46 +0000
-@@ -35,7 +35,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -72,7 +72,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -115,7 +115,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-@@ -229,7 +229,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -266,7 +266,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -309,7 +309,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
---- mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2008-10-23 19:27:09 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2012-08-24 08:06:16 +0000
-@@ -13,7 +13,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
---- mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2010-09-02 13:05:06 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2012-08-24 08:06:16 +0000
-@@ -631,7 +631,7 @@
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- /* the output must denote there is the query */;
- drop trigger trg_del_t2;
-@@ -869,7 +869,7 @@
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- drop trigger trg_del_t2;
- drop table t1,t2,t3,t4,t5;
-
-=== added file 'mysql-test/suite/rpl/r/rpl_mdev382.result'
---- mysql-test/suite/rpl/r/rpl_mdev382.result 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/r/rpl_mdev382.result 2012-08-24 10:32:46 +0000
-@@ -0,0 +1,302 @@
-+include/master-slave.inc
-+[connection master]
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+Warnings:
-+Warning 1196 Some non-transactional changed tables couldn't be rolled back
-+insert into t1 values (3);
-+commit;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
-+master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
-+master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
-+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
-+master-bin.000001 # Query # # use `test`; insert into t2 values (1)
-+master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
-+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values(10)
-+master-bin.000001 # Query # # SAVEPOINT "a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(11)
-+master-bin.000001 # Query # # SAVEPOINT "a""a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(12)
-+master-bin.000001 # Query # # SAVEPOINT b
-+master-bin.000001 # Query # # use `test`; insert into t1 values(13)
-+master-bin.000001 # Query # # SAVEPOINT "b""b"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(14)
-+master-bin.000001 # Query # # SAVEPOINT `c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(15)
-+master-bin.000001 # Query # # SAVEPOINT `c``c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(16)
-+master-bin.000001 # Query # # SAVEPOINT d
-+master-bin.000001 # Query # # use `test`; insert into t1 values(17)
-+master-bin.000001 # Query # # SAVEPOINT `d``d`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(18)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+*** Test correct USE statement in SHOW BINLOG EVENTS ***
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+DROP TABLE t1;
-+use test;
-+***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+truncate `t``1`;
-+use test;
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+truncate `t``1`
-+/*!*/;
-+use `test`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+drop table t1,t2;
-+*** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
-+FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=concat((@`b`),'| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|',(@`b`)) ;file_id=#
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+DROP TABLE t1;
-+*** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+master-bin.000001 # User var # # @`a``1`=-9223372036854775808
-+master-bin.000001 # User var # # @`a``2`=42
-+master-bin.000001 # User var # # @`a``3`=9223372036854775807
-+master-bin.000001 # User var # # @`a``4`=-1
-+master-bin.000001 # User var # # @`b```=-1.2345601234568e+125
-+master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
-+master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+/*!*/;
-+SET @`a``1`:=-9223372036854775808/*!*/;
-+SET @`a``2`:=42/*!*/;
-+SET @`a``3`:=9223372036854775807/*!*/;
-+SET @`a``4`:=-1/*!*/;
-+SET @`b```:=-1.2345601234568e+125/*!*/;
-+SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
-+SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+a1 a2 a3 a4 b c d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+-9223372036854775807 4200 9223372036854775806 0 -6.17280061728394e+124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+DROP TABLE t1;
-+*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+include/stop_slave.inc
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+a`
-+1
-+2
-+5
-+set timestamp=1000000000;
-+# The table should be empty on the master.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+# The DELETE statement should be correctly quoted
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
-+include/start_slave.inc
-+# The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+*** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+INSERT INTO t1 VALUES(1);
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES(1)
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `ts``et`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+INSERT INTO t1 VALUES(1)
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+DROP TABLE t1;
-+include/rpl_end.inc
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
---- mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2012-08-24 08:06:16 +0000
-@@ -153,7 +153,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -175,7 +175,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -284,7 +284,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -316,7 +316,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
---- mysql-test/suite/rpl/r/rpl_sp.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_sp.result 2012-08-24 08:06:16 +0000
-@@ -627,7 +627,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest1
- /*!*/;
--use mysqltest1/*!*/;
-+use `mysqltest1`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t1 (a varchar(100))
- /*!*/;
-@@ -840,7 +840,7 @@
- SET TIMESTAMP=t/*!*/;
- drop user "zedjzlcsjhd"@127.0.0.1
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- drop function if exists f1
- /*!*/;
-@@ -925,7 +925,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest2
- /*!*/;
--use mysqltest2/*!*/;
-+use `mysqltest2`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t ( t integer )
- /*!*/;
-@@ -943,7 +943,7 @@
- return 0;
- end
- /*!*/;
--use mysqltest/*!*/;
-+use `mysqltest`/*!*/;
- SET TIMESTAMP=t/*!*/;
- SELECT `mysqltest2`.`f1`()
- /*!*/;
-@@ -953,14 +953,14 @@
- SET TIMESTAMP=t/*!*/;
- drop database mysqltest2
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
- begin
- select 1;
- end
- /*!*/;
--use mysql/*!*/;
-+use `mysql`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
- `label`:
-
-=== added file 'mysql-test/suite/rpl/t/rpl_mdev382.test'
---- mysql-test/suite/rpl/t/rpl_mdev382.test 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/t/rpl_mdev382.test 2012-08-24 10:32:46 +0000
-@@ -0,0 +1,257 @@
-+--source include/have_innodb.inc
-+--source include/not_windows.inc
-+--source include/have_binlog_format_statement.inc
-+--source include/master-slave.inc
-+
-+# MDEV-382: multiple SQL injections in replication code.
-+
-+# Test previous SQL injection attack against binlog for SAVEPOINT statement.
-+# The test would cause syntax error on slave due to improper quoting of
-+# the savepoint name.
-+connection master;
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (3);
-+commit;
-+
-+--source include/show_binlog_events.inc
-+
-+# This failed due to syntax error in query when the bug was not fixed.
-+sync_slave_with_master;
-+connection slave;
-+
-+# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+
-+--source include/show_binlog_events.inc
-+
-+--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+--source include/show_binlog_events.inc
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+--source include/show_binlog_events.inc
-+set sql_quote_show_create = 1;
-+--source include/show_binlog_events.inc
-+DROP TABLE t1;
-+
-+use test;
-+
-+--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
-+--write_file $load_file
-+'fo\\o','bar'
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+ `c``3` VARCHAR(7));
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+
-+SELECT * FROM `t``1`;
-+# Also test when code prefixes table name with database.
-+truncate `t``1`;
-+use test;
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+connection master;
-+
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+--remove_file $load_file
-+
-+connection master;
-+drop table t1,t2;
-+
-+
-+--echo *** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
-+--write_file $load_file
-+1,X
-+2,A
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+# The bug was that the SET expression was truncated to 256 bytes, so test with
-+# an expression longer than that.
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$load_file' INTO TABLE t1
-+ FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+
-+SELECT * FROM t1 ORDER BY a;
-+--source include/show_binlog_events.inc
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM t1 ORDER BY a;
-+
-+connection master;
-+--remove_file $load_file
-+DROP TABLE t1;
-+
-+
-+--echo *** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+
-+connection master;
-+DROP TABLE t1;
-+
-+
-+--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+
-+# Let's keep the slave stopped during master restart, to avoid any potential
-+# races between slave reconnect and master restart.
-+connection slave;
-+--source include/stop_slave.inc
-+
-+connection master;
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+
-+# Restart the master mysqld.
-+# This will cause an implicit truncation of the memory-based table, which will
-+# cause logging of an explicit DELETE FROM to binlog.
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+wait-rpl_mdev382.test
-+EOF
-+
-+--shutdown_server 30
-+
-+--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+restart-rpl_mdev382.test
-+EOF
-+
-+connection default;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+# rpl_end.inc needs to use the connection server_1
-+connection server_1;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+connection master;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+set timestamp=1000000000;
-+
-+--echo # The table should be empty on the master.
-+let $binlog_file= master-bin.000002;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+--echo # The DELETE statement should be correctly quoted
-+--source include/show_binlog_events.inc
-+
-+connection slave;
-+--source include/start_slave.inc
-+
-+connection master;
-+sync_slave_with_master;
-+connection slave;
-+--echo # The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+connection master;
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+sync_slave_with_master;
-+
-+
-+connection master;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+
-+--echo *** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+INSERT INTO t1 VALUES(1);
-+--source include/show_binlog_events.inc
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 --rewrite-db='test->ts`et' $MYSQLD_DATADIR/master-bin.000002
-+DROP TABLE t1;
-+
-+--source include/rpl_end.inc
-
-=== modified file 'mysys/mf_iocache2.c'
---- mysys/mf_iocache2.c 2011-11-21 17:13:14 +0000
-+++ mysys/mf_iocache2.c 2012-08-24 10:32:46 +0000
-@@ -284,6 +284,40 @@
- }
-
-
-+size_t
-+my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len)
-+{
-+ const uchar *start;
-+ const uchar *p= (const uchar *)str;
-+ const uchar *end= p + len;
-+ size_t count;
-+ size_t total= 0;
-+
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ for (;;)
-+ {
-+ start= p;
-+ while (p < end && *p != '`')
-+ ++p;
-+ count= p - start;
-+ if (count && my_b_write(info, start, count))
-+ return (size_t)-1;
-+ total+= count;
-+ if (p >= end)
-+ break;
-+ if (my_b_write(info, (uchar *)"``", 2))
-+ return (size_t)-1;
-+ total+= 2;
-+ ++p;
-+ }
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ return total;
-+}
-+
- /*
- Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
- Used for logging in MySQL
-@@ -308,6 +342,7 @@
- uint minimum_width_sign;
- uint precision; /* as yet unimplemented for anything but %b */
- my_bool is_zero_padded;
-+ my_bool backtick_quoting;
-
- /*
- Store the location of the beginning of a format directive, for the
-@@ -342,6 +377,7 @@
- fmt++;
-
- is_zero_padded= FALSE;
-+ backtick_quoting= FALSE;
- minimum_width_sign= 1;
- minimum_width= 0;
- precision= 0;
-@@ -354,6 +390,8 @@
- minimum_width_sign= -1; fmt++; goto process_flags;
- case '0':
- is_zero_padded= TRUE; fmt++; goto process_flags;
-+ case '`':
-+ backtick_quoting= TRUE; fmt++; goto process_flags;
- case '#':
- /** @todo Implement "#" conversion flag. */ fmt++; goto process_flags;
- case ' ':
-@@ -397,9 +435,19 @@
- reg2 char *par = va_arg(args, char *);
- size_t length2 = strlen(par);
- /* TODO: implement precision */
-- out_length+= length2;
-- if (my_b_write(info, (uchar*) par, length2))
-- goto err;
-+ if (backtick_quoting)
-+ {
-+ size_t total= my_b_write_backtick_quote(info, par, length2);
-+ if (total == (size_t)-1)
-+ goto err;
-+ out_length+= total;
-+ }
-+ else
-+ {
-+ out_length+= length2;
-+ if (my_b_write(info, (uchar*) par, length2))
-+ goto err;
-+ }
- }
- else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
- {
-
-=== modified file 'sql/ha_ndbcluster_binlog.cc'
---- sql/ha_ndbcluster_binlog.cc 2011-11-24 16:48:58 +0000
-+++ sql/ha_ndbcluster_binlog.cc 2012-08-24 10:32:46 +0000
-@@ -1268,7 +1268,9 @@
- DBUG_RETURN(0);
- }
-
-- char tmp_buf2[FN_REFLEN];
-+ char tmp_buf2_mem[FN_REFLEN];
-+ String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
-+ tmp_buf2.length(0);
- const char *type_str;
- switch (type)
- {
-@@ -1277,17 +1279,24 @@
- if (thd->lex->sql_command == SQLCOM_DROP_DB)
- DBUG_RETURN(0);
- /* redo the drop table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "drop table `",
-- table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("drop table "));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "drop table";
- break;
- case SOT_RENAME_TABLE:
- /* redo the rename table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "rename table `",
-- db, ".", table_name, "` to `",
-- new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("rename table "));
-+ append_identifier(thd, &tmp_buf2, db, strlen(db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ tmp_buf2.append(STRING_WITH_LEN(" to "));
-+ append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "rename table";
- break;
- case SOT_CREATE_TABLE:
-
-=== modified file 'sql/item.cc'
---- sql/item.cc 2012-05-18 12:23:05 +0000
-+++ sql/item.cc 2012-08-24 10:32:46 +0000
-@@ -769,15 +769,31 @@
- if (!my_charset_same(cs, system_charset_info))
- {
- size_t res_length;
-- name= sql_strmake_with_convert(str, name_length= length, cs,
-+ name= sql_strmake_with_convert(str, length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
-+ name_length= res_length;
- }
- else
- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
- }
-
-
-+void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
-+{
-+ if (!my_charset_same(cs, system_charset_info))
-+ {
-+ size_t res_length;
-+ name= sql_strmake_with_convert(str, length, cs,
-+ UINT_MAX, system_charset_info,
-+ &res_length);
-+ name_length= res_length;
-+ }
-+ else
-+ name= sql_strmake(str, (name_length= length));
-+}
-+
-+
- /**
- @details
- This function is called when:
-
-=== modified file 'sql/item.h'
---- sql/item.h 2012-05-18 12:23:05 +0000
-+++ sql/item.h 2012-08-24 10:32:46 +0000
-@@ -572,6 +572,7 @@
- #endif
- } /*lint -e1509 */
- void set_name(const char *str, uint length, CHARSET_INFO *cs);
-+ void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
- void rename(char *new_name);
- void init_make_field(Send_field *tmp_field,enum enum_field_types type);
- virtual void cleanup();
-
-=== modified file 'sql/item_func.cc'
---- sql/item_func.cc 2012-05-22 05:48:10 +0000
-+++ sql/item_func.cc 2012-08-24 10:32:46 +0000
-@@ -4784,7 +4784,7 @@
- void Item_func_get_user_var::print(String *str, enum_query_type query_type)
- {
- str->append(STRING_WITH_LEN("(@"));
-- str->append(name.str,name.length);
-+ append_identifier(current_thd, str, name.str, name.length);
- str->append(')');
- }
-
-@@ -4882,10 +4882,10 @@
- }
-
-
--void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
-+void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
- {
- str->append('@');
-- str->append(name.str,name.length);
-+ append_identifier(thd, str, name.str, name.length);
- }
-
-
-
-=== modified file 'sql/item_func.h'
---- sql/item_func.h 2011-11-24 16:48:58 +0000
-+++ sql/item_func.h 2012-08-24 10:32:46 +0000
-@@ -1541,7 +1541,7 @@
- my_decimal *val_decimal(my_decimal *decimal_buffer);
- /* fix_fields() binds variable name with its entry structure */
- bool fix_fields(THD *thd, Item **ref);
-- virtual void print(String *str, enum_query_type query_type);
-+ void print_for_load(THD *thd, String *str);
- void set_null_value(CHARSET_INFO* cs);
- void set_value(const char *str, uint length, CHARSET_INFO* cs);
- };
-
-=== modified file 'sql/log.cc'
---- sql/log.cc 2012-05-18 12:23:05 +0000
-+++ sql/log.cc 2012-08-24 10:32:46 +0000
-@@ -38,6 +38,7 @@
- #endif
-
- #include <mysql/plugin.h>
-+#include "sql_show.h"
-
- /* max size of the log message */
- #define MAX_LOG_BUFFER_SIZE 1024
-@@ -1769,9 +1770,8 @@
-
- String log_query;
- if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-@@ -1793,9 +1793,8 @@
- {
- String log_query;
- if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-
-=== modified file 'sql/log_event.cc'
---- sql/log_event.cc 2012-05-18 12:23:05 +0000
-+++ sql/log_event.cc 2012-08-24 10:32:46 +0000
-@@ -34,6 +34,7 @@
- #include "rpl_utility.h"
- #include "rpl_record.h"
- #include <my_dir.h>
-+#include "sql_show.h"
-
- #endif /* MYSQL_CLIENT */
-
-@@ -413,29 +414,28 @@
- pretty_print_str()
- */
-
--static char *pretty_print_str(char *packet, const char *str, int len)
-+static void
-+pretty_print_str(String *packet, const char *str, int len)
- {
- const char *end= str + len;
-- char *pos= packet;
-- *pos++= '\'';
-+ packet->append(STRING_WITH_LEN("'"));
- while (str < end)
- {
- char c;
- switch ((c=*str++)) {
-- case '\n': *pos++= '\\'; *pos++= 'n'; break;
-- case '\r': *pos++= '\\'; *pos++= 'r'; break;
-- case '\\': *pos++= '\\'; *pos++= '\\'; break;
-- case '\b': *pos++= '\\'; *pos++= 'b'; break;
-- case '\t': *pos++= '\\'; *pos++= 't'; break;
-- case '\'': *pos++= '\\'; *pos++= '\''; break;
-- case 0 : *pos++= '\\'; *pos++= '0'; break;
-+ case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
-+ case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
-+ case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
-+ case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
-+ case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
-+ case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
-+ case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
- default:
-- *pos++= c;
-+ packet->append(&c, 1);
- break;
- }
- }
-- *pos++= '\'';
-- return pos;
-+ packet->append(STRING_WITH_LEN("'"));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -861,7 +861,7 @@
- Log_event::pack_info()
- */
-
--void Log_event::pack_info(Protocol *protocol)
-+void Log_event::pack_info(THD *thd, Protocol *protocol)
- {
- protocol->store("", &my_charset_bin);
- }
-@@ -870,7 +870,8 @@
- /**
- Only called by SHOW BINLOG EVENTS
- */
--int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
-+int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos)
- {
- const char *p= strrchr(log_name, FN_LIBCHAR);
- const char *event_type;
-@@ -884,7 +885,7 @@
- protocol->store(event_type, strlen(event_type), &my_charset_bin);
- protocol->store((uint32) server_id);
- protocol->store((ulonglong) log_pos);
-- pack_info(protocol);
-+ pack_info(thd, protocol);
- return protocol->write();
- }
- #endif /* HAVE_REPLICATION */
-@@ -2139,27 +2140,22 @@
- show the catalog ??
- */
-
--void Query_log_event::pack_info(Protocol *protocol)
-+void Query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- // TODO: show the catalog ??
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len);
- if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
- && db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf.append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, &buf, db, db_len);
-+ buf.append("; ");
- }
- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ buf.append(query, q_len);
-+ protocol->store(&buf);
- }
- #endif
-
-@@ -2924,11 +2920,17 @@
- }
- else if (db)
- {
-+ /* Room for expand ` to `` + initial/final ` + \0 */
-+ char buf[FN_REFLEN*2+3];
-+
- different_db= memcmp(print_event_info->db, db, db_len + 1);
- if (different_db)
- memcpy(print_event_info->db, db, db_len + 1);
- if (db[0] && different_db)
-- my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
-+ {
-+ my_snprintf(buf, sizeof(buf), "%`s", db);
-+ my_b_printf(file, "use %s%s\n", buf, print_event_info->delimiter);
-+ }
- }
-
- end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
-@@ -3545,7 +3547,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Start_log_event_v3::pack_info(Protocol *protocol)
-+void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
- pos= strmov(buf, "Server ver: ");
-@@ -4194,131 +4196,115 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--uint Load_log_event::get_query_buffer_length()
--{
-- return
-- 5 + db_len + 3 + // "use DB; "
-- 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
-- 11 + // "CONCURRENT "
-- 7 + // LOCAL
-- 9 + // " REPLACE or IGNORE "
-- 13 + table_name_len*2 + // "INTO TABLE `table`"
-- 21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
-- 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
-- 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
-- 21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
-- 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
-- 15 + 22 + // " IGNORE xxx LINES"
-- 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
--}
--
--
--void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
-- char **end, char **fn_start, char **fn_end)
--{
-- char *pos= buf;
--
-+void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
-+ String *buf, my_off_t *fn_start,
-+ my_off_t *fn_end, const char *qualify_db)
-+{
- if (need_db && db && db_len)
- {
-- pos= strmov(pos, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf->append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, buf, db, db_len);
-+ buf->append(STRING_WITH_LEN("; "));
- }
-
-- pos= strmov(pos, "LOAD DATA ");
-+ buf->append(STRING_WITH_LEN("LOAD DATA "));
-
- if (thd->lex->lock_option == TL_WRITE_CONCURRENT_INSERT)
-- pos= strmov(pos, "CONCURRENT ");
-+ buf->append(STRING_WITH_LEN("CONCURRENT "));
-
- if (fn_start)
-- *fn_start= pos;
-+ *fn_start= buf->length();
-
- if (check_fname_outside_temp_buf())
-- pos= strmov(pos, "LOCAL ");
-- pos= strmov(pos, "INFILE '");
-- memcpy(pos, fname, fname_len);
-- pos= strmov(pos+fname_len, "' ");
-+ buf->append(STRING_WITH_LEN("LOCAL "));
-+ buf->append(STRING_WITH_LEN("INFILE '"));
-+ buf->append_for_single_quote(fname, fname_len);
-+ buf->append(STRING_WITH_LEN("' "));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
-- pos= strmov(pos, "REPLACE ");
-+ buf->append(STRING_WITH_LEN("REPLACE "));
- else if (sql_ex.opt_flags & IGNORE_FLAG)
-- pos= strmov(pos, "IGNORE ");
-+ buf->append(STRING_WITH_LEN("IGNORE "));
-
-- pos= strmov(pos ,"INTO");
-+ buf->append(STRING_WITH_LEN("INTO"));
-
- if (fn_end)
-- *fn_end= pos;
-+ *fn_end= buf->length();
-
-- pos= strmov(pos ," TABLE `");
-- memcpy(pos, table_name, table_name_len);
-- pos+= table_name_len;
-+ buf->append(STRING_WITH_LEN(" TABLE "));
-+ if (qualify_db)
-+ {
-+ append_identifier(thd, buf, qualify_db, strlen(qualify_db));
-+ buf->append(STRING_WITH_LEN("."));
-+ }
-+ append_identifier(thd, buf, table_name, table_name_len);
-
- if (cs != NULL)
- {
-- pos= strmov(pos ,"` CHARACTER SET ");
-- pos= strmov(pos , cs);
-+ buf->append(STRING_WITH_LEN(" CHARACTER SET "));
-+ buf->append(cs, strlen(cs));
- }
-- else
-- pos= strmov(pos, "`");
-
- /* We have to create all optional fields as the default is not empty */
-- pos= strmov(pos, " FIELDS TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
-+ buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
- if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
-- pos= strmov(pos, " OPTIONALLY ");
-- pos= strmov(pos, " ENCLOSED BY ");
-- pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
--
-- pos= strmov(pos, " ESCAPED BY ");
-- pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
--
-- pos= strmov(pos, " LINES TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
-+ buf->append(STRING_WITH_LEN(" OPTIONALLY "));
-+ buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
-+ pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
-+
-+ buf->append(STRING_WITH_LEN(" ESCAPED BY "));
-+ pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
-+
-+ buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
- if (sql_ex.line_start_len)
- {
-- pos= strmov(pos, " STARTING BY ");
-- pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
-+ buf->append(STRING_WITH_LEN(" STARTING BY "));
-+ pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
- }
-
- if ((long) skip_lines > 0)
- {
-- pos= strmov(pos, " IGNORE ");
-- pos= longlong10_to_str((longlong) skip_lines, pos, 10);
-- pos= strmov(pos," LINES ");
-+ char skipbuf[22];
-+ buf->append(STRING_WITH_LEN(" IGNORE "));
-+ longlong10_to_str((longlong) skip_lines, skipbuf, 10);
-+ buf->append(skipbuf);
-+ buf->append(STRING_WITH_LEN(" LINES "));
- }
-
- if (num_fields)
- {
- uint i;
- const char *field= fields;
-- pos= strmov(pos, " (");
-+ buf->append(STRING_WITH_LEN(" ("));
- for (i = 0; i < num_fields; i++)
- {
- if (i)
- {
-- *pos++= ' ';
-- *pos++= ',';
-+ /*
-+ Yes, the space and comma is reversed here. But this is mostly dead
-+ code, at most used when reading really old binlogs from old servers,
-+ so better just leave it as is...
-+ */
-+ buf->append(STRING_WITH_LEN(" ,"));
- }
-- memcpy(pos, field, field_lens[i]);
-- pos+= field_lens[i];
-+ append_identifier(thd, buf, field, field_lens[i]);
- field+= field_lens[i] + 1;
- }
-- *pos++= ')';
-+ buf->append(STRING_WITH_LEN(")"));
- }
--
-- *end= pos;
- }
-
-
--void Load_log_event::pack_info(Protocol *protocol)
-+void Load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *end;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
-
-- if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
-- return;
-- print_query(TRUE, NULL, buf, &end, 0, 0);
-- protocol->store(buf, end-buf, &my_charset_bin);
-- my_free(buf, MYF(0));
-+ query_str.length(0);
-+ print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
-+ protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
- }
- #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-
-@@ -4585,7 +4571,7 @@
- else if (sql_ex.opt_flags & IGNORE_FLAG)
- my_b_printf(&cache,"IGNORE ");
-
-- my_b_printf(&cache, "INTO TABLE `%s`", table_name);
-+ my_b_printf(&cache, "INTO TABLE %`s", table_name);
- my_b_printf(&cache, " FIELDS TERMINATED BY ");
- pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
-
-@@ -4774,16 +4760,20 @@
- else
- {
- char llbuff[22];
-- char *end;
- enum enum_duplicates handle_dup;
- bool ignore= 0;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
- char *load_data_query;
-
-+ query_str.length(0);
- /*
- Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
- and written to slave's binlog if binlogging is on.
- */
-- if (!(load_data_query= (char *)thd->alloc(get_query_buffer_length() + 1)))
-+ print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(),
-+ query_str.length())))
- {
- /*
- This will set thd->fatal_error in case of OOM. So we surely will notice
-@@ -4792,9 +4782,7 @@
- goto error;
- }
-
-- print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
-- *end= 0;
-- thd->set_query(load_data_query, (uint) (end - load_data_query));
-+ thd->set_query(load_data_query, (uint) (query_str.length()));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
- {
-@@ -4959,7 +4947,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rotate_log_event::pack_info(Protocol *protocol)
-+void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], buf[22];
- String tmp(buf1, sizeof(buf1), log_cs);
-@@ -5174,7 +5162,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Intvar_log_event::pack_info(Protocol *protocol)
-+void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256], *pos;
- pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
-@@ -5323,7 +5311,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rand_log_event::pack_info(Protocol *protocol)
-+void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], *pos;
- pos= strmov(buf1,"rand_seed1=");
-@@ -5421,7 +5409,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Xid_log_event::pack_info(Protocol *protocol)
-+void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[128], *pos;
- pos= strmov(buf, "COMMIT /* xid=");
-@@ -5508,69 +5496,109 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void User_var_log_event::pack_info(Protocol* protocol)
-+static bool
-+user_var_append_name_part(THD *thd, String *buf,
-+ const char *name, size_t name_len)
- {
-- char *buf= 0;
-- uint val_offset= 4 + name_len;
-- uint event_len= val_offset;
-+ return buf->append("@") ||
-+ append_identifier(thd, buf, name, name_len) ||
-+ buf->append("=");
-+}
-
-+void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
-+{
- if (is_null)
- {
-- if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
-+ char buf_mem[FN_REFLEN+7];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("NULL"))
- return;
-- strmov(buf + val_offset, "NULL");
-- event_len= val_offset + 4;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
- else
- {
- switch (type) {
- case REAL_RESULT:
-+ {
- double real_val;
-+ char buf2[FLOATING_POINT_BUFFER];
-+ char buf_mem[FN_REFLEN + FLOATING_POINT_BUFFER];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- float8get(real_val, val);
-- if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
-- MYF(MY_WME))))
-- return;
-- event_len+= my_sprintf(buf + val_offset,
-- (buf + val_offset, "%.14g", real_val));
-+ buf.length(0);
-+ my_sprintf(buf2, (buf2, "%.14g", real_val));
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case INT_RESULT:
-- if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
-+ {
-+ char buf2[22];
-+ char buf_mem[FN_REFLEN + 22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2, longlong10_to_str(uint8korr(val), buf2, -10)-buf2))
- return;
-- event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case DECIMAL_RESULT:
- {
-- if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
-- MYF(MY_WME))))
-- return;
-- String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
-+ char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ char buf2[DECIMAL_MAX_STR_LENGTH+1];
-+ String str(buf2, sizeof(buf2), &my_charset_bin);
- my_decimal dec;
-+ buf.length(0);
- binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
- val[1]);
- my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
-- event_len= str.length() + val_offset;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
- }
- case STRING_RESULT:
-+ {
- /* 15 is for 'COLLATE' and other chars */
-- buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
-- MYF(MY_WME));
-+ char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- CHARSET_INFO *cs;
-- if (!buf)
-- return;
-+ buf.length(0);
- if (!(cs= get_charset(charset_number, MYF(0))))
- {
-- strmov(buf+val_offset, "???");
-- event_len+= 3;
-+ if (buf.append("???"))
-+ return;
- }
- else
- {
-- char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
-- p= str_to_hex(p, val, val_len);
-- p= strxmov(p, " COLLATE ", cs->name, NullS);
-- event_len= p-buf;
-+ size_t old_len;
-+ char *beg, *end;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("_") ||
-+ buf.append(cs->csname) ||
-+ buf.append(" "))
-+ return;
-+ old_len= buf.length();
-+ if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
-+ MY_CS_NAME_SIZE))
-+ return;
-+ beg= const_cast<char *>(buf.ptr()) + old_len;
-+ end= str_to_hex(beg, val, val_len);
-+ buf.length(old_len + (end - beg));
-+ if (buf.append(" COLLATE ") ||
-+ buf.append(cs->name))
-+ return;
- }
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
- default:
-@@ -5578,13 +5606,6 @@
- return;
- }
- }
-- buf[0]= '@';
-- buf[1]= '`';
-- memcpy(buf+2, name, name_len);
-- buf[2+name_len]= '`';
-- buf[3+name_len]= '=';
-- protocol->store(buf, event_len, &my_charset_bin);
-- my_free(buf, MYF(0));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -5700,9 +5721,8 @@
- my_b_printf(&cache, "\tUser_var\n");
- }
-
-- my_b_printf(&cache, "SET @`");
-- my_b_write(&cache, (uchar*) name, (uint) (name_len));
-- my_b_printf(&cache, "`");
-+ my_b_printf(&cache, "SET @");
-+ my_b_write_backtick_quote(&cache, name, name_len);
-
- if (is_null)
- {
-@@ -5775,7 +5795,7 @@
- */
- my_b_printf(&cache, ":=???%s\n", print_event_info->delimiter);
- else
-- my_b_printf(&cache, ":=_%s %s COLLATE `%s`%s\n",
-+ my_b_printf(&cache, ":=_%s %s COLLATE %`s%s\n",
- cs->csname, hex_str, cs->name,
- print_event_info->delimiter);
- my_afree(hex_str);
-@@ -5914,7 +5934,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
--void Slave_log_event::pack_info(Protocol *protocol)
-+void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256+HOSTNAME_LENGTH], *pos;
- pos= strmov(buf, "host=");
-@@ -6286,7 +6306,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Create_file_log_event::pack_info(Protocol *protocol)
-+void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos;
- pos= strmov(buf, "db=");
-@@ -6467,7 +6487,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Append_block_log_event::pack_info(Protocol *protocol)
-+void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- uint length;
-@@ -6619,7 +6639,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Delete_file_log_event::pack_info(Protocol *protocol)
-+void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -6717,7 +6737,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_log_event::pack_info(Protocol *protocol)
-+void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -6970,27 +6990,26 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_query_log_event::pack_info(Protocol *protocol)
-+void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ char file_id_buf[22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len + 10 + 21);
- if (db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-- }
-- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- pos= strmov(pos, " ;file_id=");
-- pos= int10_to_str((long) file_id, pos, 10);
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ if (buf.append("use ") ||
-+ append_identifier(thd, &buf, db, db_len) ||
-+ buf.append("; "))
-+ return;
-+ }
-+ if (query && q_len && buf.append(query, q_len))
-+ return;
-+ int10_to_str((long) file_id, file_id_buf, 10);
-+ if (buf.append(" ;file_id=") ||
-+ buf.append(file_id_buf))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
-
-
-@@ -7932,7 +7951,7 @@
- #endif
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rows_log_event::pack_info(Protocol *protocol)
-+void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-@@ -8638,7 +8657,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Table_map_log_event::pack_info(Protocol *protocol)
-+void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes= my_snprintf(buf, sizeof(buf),
-@@ -8659,7 +8678,7 @@
- {
- print_header(&print_event_info->head_cache, print_event_info, TRUE);
- my_b_printf(&print_event_info->head_cache,
-- "\tTable_map: `%s`.`%s` mapped to number %lu\n",
-+ "\tTable_map: %`s.%`s mapped to number %lu\n",
- m_dbnam, m_tblnam, m_table_id);
- print_base64(&print_event_info->body_cache, print_event_info, TRUE);
- }
-@@ -9859,7 +9878,7 @@
-
-
- #ifndef MYSQL_CLIENT
--void Incident_log_event::pack_info(Protocol *protocol)
-+void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes;
-
-=== modified file 'sql/log_event.h'
---- sql/log_event.h 2011-11-24 16:48:58 +0000
-+++ sql/log_event.h 2012-08-24 10:32:46 +0000
-@@ -954,14 +954,15 @@
- */
- static void init_show_field_list(List<Item>* field_list);
- #ifdef HAVE_REPLICATION
-- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
-+ int net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos);
-
- /*
- pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
- a string to display to the user, so it resembles print().
- */
-
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
-
- #endif /* HAVE_REPLICATION */
- virtual const char* get_db()
-@@ -1661,7 +1662,7 @@
- bool using_trans, bool suppress_use, int error);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -1791,7 +1792,7 @@
-
- #ifndef MYSQL_CLIENT
- Slave_log_event(THD* thd_arg, Relay_log_info* rli);
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2024,9 +2025,11 @@
- const Format_description_log_event* description_event);
-
- public:
-- uint get_query_buffer_length();
-- void print_query(bool need_db, const char *cs, char *buf, char **end,
-- char **fn_start, char **fn_end);
-+#ifndef MYSQL_CLIENT
-+ void print_query(THD *thd, bool need_db, const char *cs, String *buf,
-+ my_off_t *fn_start, my_off_t *fn_end,
-+ const char *qualify_db);
-+#endif
- ulong thread_id;
- ulong slave_proxy_id;
- uint32 table_name_len;
-@@ -2074,7 +2077,7 @@
- Name_resolution_context *context);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2173,7 +2176,7 @@
- #ifndef MYSQL_CLIENT
- Start_log_event_v3();
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- Start_log_event_v3() {}
-@@ -2325,7 +2328,7 @@
- :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
- {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2401,7 +2404,7 @@
- :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
- {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2445,7 +2448,7 @@
- #ifndef MYSQL_CLIENT
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2494,7 +2497,7 @@
- :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
- val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
- { is_null= !val; }
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2625,7 +2628,7 @@
- uint ident_len_arg,
- ulonglong pos_arg, uint flags);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2685,7 +2688,7 @@
- uchar* block_arg, uint block_len_arg,
- bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2757,7 +2760,7 @@
- Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
- uint block_len_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- virtual int get_create_or_append() const;
- #endif /* HAVE_REPLICATION */
- #else
-@@ -2798,7 +2801,7 @@
- #ifndef MYSQL_CLIENT
- Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2839,7 +2842,7 @@
- #ifndef MYSQL_CLIENT
- Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2935,7 +2938,7 @@
- bool using_trans, bool suppress_use,
- int errcode);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3382,7 +3385,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3494,7 +3497,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3931,7 +3934,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
-- void pack_info(Protocol*);
-+ void pack_info(THD *thd, Protocol*);
- #endif
-
- Incident_log_event(const char *buf, uint event_len,
-
-=== modified file 'sql/log_event_old.cc'
---- sql/log_event_old.cc 2011-11-24 16:48:58 +0000
-+++ sql/log_event_old.cc 2012-08-24 10:32:46 +0000
-@@ -2008,7 +2008,7 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Old_rows_log_event::pack_info(Protocol *protocol)
-+void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-
-=== modified file 'sql/log_event_old.h'
---- sql/log_event_old.h 2011-02-20 16:51:43 +0000
-+++ sql/log_event_old.h 2012-08-24 08:06:16 +0000
-@@ -108,7 +108,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-
-=== modified file 'sql/mysql_priv.h'
---- sql/mysql_priv.h 2012-05-18 12:23:05 +0000
-+++ sql/mysql_priv.h 2012-08-24 10:32:46 +0000
-@@ -1397,7 +1397,7 @@
- /* sql_show.cc */
- bool mysqld_show_open_tables(THD *thd,const char *wild);
- bool mysqld_show_logs(THD *thd);
--void append_identifier(THD *thd, String *packet, const char *name,
-+bool append_identifier(THD *thd, String *packet, const char *name,
- uint length);
- #endif /* MYSQL_SERVER */
- #if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-
-=== modified file 'sql/sql_base.cc'
---- sql/sql_base.cc 2011-12-29 23:09:20 +0000
-+++ sql/sql_base.cc 2012-08-24 10:32:46 +0000
-@@ -4195,22 +4195,22 @@
- entry->file->implicit_emptied= 0;
- if (mysql_bin_log.is_open())
- {
-- char *query, *end;
-- uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
-- if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
-+ char query_buf[2*FN_REFLEN + 21];
-+ String query(query_buf, sizeof(query_buf), system_charset_info);
-+ query.length(0);
-+ if (query.ptr())
- {
- /* this DELETE FROM is needed even with row-based binlogging */
-- end = strxmov(strmov(query, "DELETE FROM `"),
-- share->db.str,"`.`",share->table_name.str,"`", NullS);
-+ query.append("DELETE FROM ");
-+ append_identifier(thd, &query, share->db.str, share->db.length);
-+ query.append(".");
-+ append_identifier(thd, &query, share->table_name.str,
-+ share->table_name.length);
- int errcode= query_error_code(thd, TRUE);
- if (thd->binlog_query(THD::STMT_QUERY_TYPE,
-- query, (ulong)(end-query),
-+ query.ptr(), query.length(),
- FALSE, FALSE, errcode))
-- {
-- my_free(query, MYF(0));
- goto err;
-- }
-- my_free(query, MYF(0));
- }
- else
- {
-@@ -4220,7 +4220,7 @@
- because of MYF(MY_WME) in my_malloc() above).
- */
- sql_print_error("When opening HEAP table, could not allocate memory "
-- "to write 'DELETE FROM `%s`.`%s`' to the binary log",
-+ "to write 'DELETE FROM %`s.%`s' to the binary log",
- table_list->db, table_list->table_name);
- delete entry->triggers;
- closefrm(entry, 0);
-
-=== modified file 'sql/sql_db.cc'
---- sql/sql_db.cc 2011-11-24 16:48:58 +0000
-+++ sql/sql_db.cc 2012-08-24 10:32:46 +0000
-@@ -613,7 +613,6 @@
- bool silent)
- {
- char path[FN_REFLEN+16];
-- char tmp_query[FN_REFLEN+16];
- long result= 1;
- int error= 0;
- MY_STAT stat_info;
-@@ -720,17 +719,9 @@
- char *query;
- uint query_length;
-
-- if (!thd->query()) // Only in replication
-- {
-- query= tmp_query;
-- query_length= (uint) (strxmov(tmp_query,"create database `",
-- db, "`", NullS) - tmp_query);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-
- ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB,
- query, query_length,
-@@ -990,18 +981,11 @@
- {
- const char *query;
- ulong query_length;
-- if (!thd->query())
-- {
-- /* The client used the old obsolete mysql_drop_db() call */
-- query= path;
-- query_length= (uint) (strxmov(path, "drop database `", db, "`",
-- NullS) - path);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-+
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
-@@ -1042,9 +1026,10 @@
- for (tbl= dropped_tables; tbl; tbl= tbl->next_local)
- {
- uint tbl_name_len;
-+ char quoted_name[FN_REFLEN+3];
-
-- /* 3 for the quotes and the comma*/
-- tbl_name_len= strlen(tbl->table_name) + 3;
-+ my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name);
-+ tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
- if (query_pos + tbl_name_len + 1 >= query_end)
- {
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
-@@ -1056,9 +1041,7 @@
- query_pos= query_data_start;
- }
-
-- *query_pos++ = '`';
-- query_pos= strmov(query_pos,tbl->table_name);
-- *query_pos++ = '`';
-+ query_pos= strmov(query_pos, quoted_name);
- *query_pos++ = ',';
- }
-
-
-=== modified file 'sql/sql_insert.cc'
---- sql/sql_insert.cc 2012-02-03 08:28:23 +0000
-+++ sql/sql_insert.cc 2012-08-24 10:32:46 +0000
-@@ -3480,16 +3480,16 @@
- if (thd->lex->create_select_in_comment)
- query.append(STRING_WITH_LEN("/*! "));
- if (thd->lex->ignore)
-- query.append(STRING_WITH_LEN("INSERT IGNORE INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT IGNORE INTO "));
- else if (thd->lex->duplicates == DUP_REPLACE)
-- query.append(STRING_WITH_LEN("REPLACE INTO `"));
-+ query.append(STRING_WITH_LEN("REPLACE INTO "));
- else
-- query.append(STRING_WITH_LEN("INSERT INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT INTO "));
-
-- query.append(create_table->db, db_len);
-- query.append(STRING_WITH_LEN("`.`"));
-- query.append(create_info->alias, table_len);
-- query.append(STRING_WITH_LEN("` "));
-+ append_identifier(thd, &query, create_table->db, db_len);
-+ query.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &query, create_info->alias, table_len);
-+ query.append(STRING_WITH_LEN(" "));
-
- /*
- The insert items.
-
-=== modified file 'sql/sql_load.cc'
---- sql/sql_load.cc 2012-04-05 10:01:52 +0000
-+++ sql/sql_load.cc 2012-08-24 10:32:46 +0000
-@@ -24,6 +24,7 @@
- #include "sql_repl.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "sql_show.h"
-
- class READ_INFO {
- File file;
-@@ -606,24 +607,31 @@
- bool transactional_table,
- int errcode)
- {
-- char *load_data_query,
-- *end,
-- *fname_start,
-- *fname_end,
-- *p= NULL;
-- size_t pl= 0;
-+ char *load_data_query;
-+ my_off_t fname_start,
-+ fname_end;
- List<Item> fv;
- Item *item, *val;
- int n;
-- const char *tbl= table_name_arg;
- const char *tdb= (thd->db != NULL ? thd->db : db_arg);
-+ const char *qualify_db= NULL;
- char name_buffer[SAFE_NAME_LEN*2];
- char command_buffer[1024];
- String string_buf(name_buffer, sizeof(name_buffer),
- system_charset_info);
-- String pfields(command_buffer, sizeof(command_buffer),
-+ String query_str(command_buffer, sizeof(command_buffer),
- system_charset_info);
-
-+ Load_log_event lle(thd, ex, tdb, table_name_arg, fv, duplicates,
-+ ignore, transactional_table);
-+
-+ /*
-+ force in a LOCAL if there was one in the original.
-+ */
-+ if (thd->lex->local_file)
-+ lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+
-+ query_str.length(0);
- if (!thd->db || strcmp(db_arg, thd->db))
- {
- /*
-@@ -631,49 +639,31 @@
- prefix table name with database name so that it
- becomes a FQ name.
- */
-- string_buf.length(0);
-- string_buf.append(db_arg);
-- string_buf.append("`");
-- string_buf.append(".");
-- string_buf.append("`");
-- string_buf.append(table_name_arg);
-- tbl= string_buf.c_ptr_safe();
-+ qualify_db= db_arg;
- }
--
-- Load_log_event lle(thd, ex, tdb, tbl, fv, duplicates,
-- ignore, transactional_table);
--
-- /*
-- force in a LOCAL if there was one in the original.
-- */
-- if (thd->lex->local_file)
-- lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+ lle.print_query(thd, FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-+ &query_str, &fname_start, &fname_end, qualify_db);
-
- /*
- prepare fields-list and SET if needed; print_query won't do that for us.
- */
-- pfields.length(0);
- if (!thd->lex->field_list.is_empty())
- {
- List_iterator<Item> li(thd->lex->field_list);
-
-- pfields.append(" (");
-+ query_str.append(" (");
- n= 0;
-
- while ((item= li++))
- {
- if (n++)
-- pfields.append(", ");
-+ query_str.append(", ");
- if (item->name)
-- {
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- }
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
- else
-- item->print(&pfields, QT_ORDINARY);
-+ ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
- }
-- pfields.append(")");
-+ query_str.append(")");
- }
-
- if (!thd->lex->update_list.is_empty())
-@@ -681,39 +671,26 @@
- List_iterator<Item> lu(thd->lex->update_list);
- List_iterator<Item> lv(thd->lex->value_list);
-
-- pfields.append(" SET ");
-+ query_str.append(" SET ");
- n= 0;
-
- while ((item= lu++))
- {
- val= lv++;
- if (n++)
-- pfields.append(", ");
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- pfields.append("=");
-- val->print(&pfields, QT_ORDINARY);
-+ query_str.append(", ");
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
-+ query_str.append("=");
-+ val->print(&query_str, QT_ORDINARY);
- }
- }
-
-- p= pfields.c_ptr_safe();
-- pl= pfields.length();
--
-- if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(), query_str.length())))
- return TRUE;
-
-- lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-- load_data_query, &end,
-- (char **)&fname_start, (char **)&fname_end);
--
-- strcpy(end, p);
-- end += pl;
--
- Execute_load_query_log_event
-- e(thd, load_data_query, end-load_data_query,
-- (uint) ((char*) fname_start - load_data_query - 1),
-- (uint) ((char*) fname_end - load_data_query),
-+ e(thd, load_data_query, query_str.length(),
-+ (uint) (fname_start - 1), (uint) fname_end,
- (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
- (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
- transactional_table, FALSE, errcode);
-
-=== modified file 'sql/sql_repl.cc'
---- sql/sql_repl.cc 2011-11-21 17:13:14 +0000
-+++ sql/sql_repl.cc 2012-08-24 08:06:16 +0000
-@@ -1554,7 +1554,7 @@
- description_event)); )
- {
- if (event_count >= limit_start &&
-- ev->net_send(protocol, linfo.log_file_name, pos))
-+ ev->net_send(thd, protocol, linfo.log_file_name, pos))
- {
- errmsg = "Net error";
- delete ev;
-
-=== modified file 'sql/sql_show.cc'
---- sql/sql_show.cc 2012-05-18 12:23:05 +0000
-+++ sql/sql_show.cc 2012-08-24 10:32:46 +0000
-@@ -1051,9 +1051,13 @@
- packet target string
- name the identifier to be appended
- name_length length of the appending identifier
-+
-+ RETURN VALUES
-+ true Error
-+ false Ok
- */
-
--void
-+bool
- append_identifier(THD *thd, String *packet, const char *name, uint length)
- {
- const char *name_end;
-@@ -1061,10 +1065,7 @@
- int q= get_quote_char_for_identifier(thd, name, length);
-
- if (q == EOF)
-- {
-- packet->append(name, length, packet->charset());
-- return;
-- }
-+ return packet->append(name, length, packet->charset());
-
- /*
- The identifier must be quoted as it includes a quote character or
-@@ -1073,7 +1074,8 @@
-
- VOID(packet->reserve(length*2 + 2));
- quote_char= (char) q;
-- packet->append(&quote_char, 1, system_charset_info);
-+ if (packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-
- for (name_end= name+length ; name < name_end ; name+= length)
- {
-@@ -1088,11 +1090,13 @@
- */
- if (!length)
- length= 1;
-- if (length == 1 && chr == (uchar) quote_char)
-- packet->append(&quote_char, 1, system_charset_info);
-- packet->append(name, length, system_charset_info);
-+ if (length == 1 && chr == (uchar) quote_char &&
-+ packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-+ if (packet->append(name, length, system_charset_info))
-+ return true;
- }
-- packet->append(&quote_char, 1, system_charset_info);
-+ return packet->append(&quote_char, 1, system_charset_info);
- }
-
-
-
-=== modified file 'sql/sql_string.cc'
---- sql/sql_string.cc 2012-04-05 10:01:52 +0000
-+++ sql/sql_string.cc 2012-08-24 10:32:46 +0000
-@@ -1159,39 +1159,47 @@
-
-
-
--
--void String::print(String *str)
-+/*
-+ Append characters to a single-quoted string '...', escaping special
-+ characters as necessary.
-+ Does not add the enclosing quotes, this is left up to caller.
-+*/
-+void String::append_for_single_quote(const char *st, uint len)
- {
-- char *st= (char*)Ptr, *end= st+str_length;
-+ const char *end= st+len;
- for (; st < end; st++)
- {
- uchar c= *st;
- switch (c)
- {
- case '\\':
-- str->append(STRING_WITH_LEN("\\\\"));
-+ append(STRING_WITH_LEN("\\\\"));
- break;
- case '\0':
-- str->append(STRING_WITH_LEN("\\0"));
-+ append(STRING_WITH_LEN("\\0"));
- break;
- case '\'':
-- str->append(STRING_WITH_LEN("\\'"));
-+ append(STRING_WITH_LEN("\\'"));
- break;
- case '\n':
-- str->append(STRING_WITH_LEN("\\n"));
-+ append(STRING_WITH_LEN("\\n"));
- break;
- case '\r':
-- str->append(STRING_WITH_LEN("\\r"));
-+ append(STRING_WITH_LEN("\\r"));
- break;
- case '\032': // Ctrl-Z
-- str->append(STRING_WITH_LEN("\\Z"));
-+ append(STRING_WITH_LEN("\\Z"));
- break;
- default:
-- str->append(c);
-+ append(c);
- }
- }
- }
-
-+void String::print(String *str)
-+{
-+ str->append_for_single_quote(Ptr, str_length);
-+}
-
- /*
- Exchange state of this object and argument.
-
-=== modified file 'sql/sql_string.h'
---- sql/sql_string.h 2011-11-24 16:48:58 +0000
-+++ sql/sql_string.h 2012-08-24 10:32:46 +0000
-@@ -426,6 +426,7 @@
- return FALSE;
- }
- void print(String *print);
-+ void append_for_single_quote(const char *st, uint len);
-
- /* Swap two string objects. Efficient way to exchange data without memcpy. */
- void swap(String &s);
-
-=== modified file 'sql/sql_table.cc'
---- sql/sql_table.cc 2012-04-05 10:01:52 +0000
-+++ sql/sql_table.cc 2012-08-24 10:32:46 +0000
-@@ -1939,6 +1939,7 @@
- for (table= tables; table; table= table->next_local)
- {
- char *db=table->db;
-+ size_t db_length= table->db_length;
- handlerton *table_type;
- enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN;
-
-@@ -1961,14 +1962,14 @@
- built_tmp_query.append("DROP TEMPORARY TABLE IF EXISTS ");
- }
-
-- built_tmp_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_tmp_query.append(db);
-- built_tmp_query.append("`.`");
-+ append_identifier(thd, &built_tmp_query, db, db_length);
-+ built_tmp_query.append(".");
- }
-- built_tmp_query.append(table->table_name);
-- built_tmp_query.append("`,");
-+ append_identifier(thd, &built_tmp_query, table->table_name,
-+ table->table_name_length);
-+ built_tmp_query.append(",");
- }
-
- continue;
-@@ -1994,15 +1995,15 @@
- Don't write the database name if it is the current one (or if
- thd->db is NULL).
- */
-- built_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_query.append(db);
-- built_query.append("`.`");
-+ append_identifier(thd, &built_query, db, db_length);
-+ built_query.append(".");
- }
-
-- built_query.append(table->table_name);
-- built_query.append("`,");
-+ append_identifier(thd, &built_query, table->table_name,
-+ table->table_name_length);
-+ built_query.append(",");
- }
-
- if (!drop_temporary)
-
-=== modified file 'strings/my_vsnprintf.c'
---- strings/my_vsnprintf.c 2011-11-24 16:48:58 +0000
-+++ strings/my_vsnprintf.c 2012-08-24 10:32:46 +0000
-@@ -636,3 +636,66 @@
- return result;
- }
-
-+
-+/**
-+ Writes output to the stream according to a format string.
-+
-+ @param stream file to write to
-+ @param format string format
-+ @param args list of parameters
-+
-+ @retval
-+ number of the characters written.
-+*/
-+
-+int my_vfprintf(FILE *stream, const char* format, va_list args)
-+{
-+ char cvtbuf[1024];
-+ int alloc= 0;
-+ char *p= cvtbuf;
-+ size_t cur_len= sizeof(cvtbuf);
-+ int ret;
-+
-+ /*
-+ We do not know how much buffer we need.
-+ So start with a reasonably-sized stack-allocated buffer, and increase
-+ it exponentially until it is big enough.
-+ */
-+ for (;;)
-+ {
-+ size_t new_len;
-+ size_t actual= my_vsnprintf(p, cur_len, format, args);
-+ if (actual < cur_len - 1)
-+ break;
-+ /*
-+ Not enough space (or just enough with nothing to spare - but we cannot
-+ distinguish this case from the return value). Allocate a bigger buffer
-+ and try again.
-+ */
-+ if (alloc)
-+ (*my_str_free)(p);
-+ else
-+ alloc= 1;
-+ new_len= cur_len*2;
-+ if (new_len < cur_len)
-+ return 0; /* Overflow */
-+ cur_len= new_len;
-+ p= (*my_str_malloc)(cur_len);
-+ if (!p)
-+ return 0;
-+ }
-+ ret= fprintf(stream, "%s", p);
-+ if (alloc)
-+ (*my_str_free)(p);
-+ return ret;
-+}
-+
-+int my_fprintf(FILE *stream, const char* format, ...)
-+{
-+ int result;
-+ va_list args;
-+ va_start(args, format);
-+ result= my_vfprintf(stream, format, args);
-+ va_end(args);
-+ return result;
-+}
-
diff --git a/21000_all_sql-5.3.7.patch b/21000_all_sql-5.3.7.patch
deleted file mode 100644
index feff133..0000000
--- a/21000_all_sql-5.3.7.patch
+++ /dev/null
@@ -1,3258 +0,0 @@
-=== modified file 'client/mysqlbinlog.cc'
---- client/mysqlbinlog.cc 2011-12-11 09:34:44 +0000
-+++ client/mysqlbinlog.cc 2012-08-24 12:02:32 +0000
-@@ -731,7 +731,7 @@
- return;
-
- // In case of rewrite rule print USE statement for db_to
-- fprintf(result_file, "use %s%s\n", db_to, pinfo->delimiter);
-+ my_fprintf(result_file, "use %`s%s\n", db_to, pinfo->delimiter);
-
- // Copy the *original* db to pinfo to suppress emiting
- // of USE stmts by log_event print-functions.
-
-=== modified file 'include/my_sys.h'
---- include/my_sys.h 2011-12-11 09:34:44 +0000
-+++ include/my_sys.h 2012-08-24 12:02:32 +0000
-@@ -686,6 +686,7 @@
- extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
- extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
- extern int my_fclose(FILE *fd,myf MyFlags);
-+extern int my_fprintf(FILE *stream, const char* format, ...);
- extern File my_fileno(FILE *fd);
- extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
- extern int my_chmod(const char *name, mode_t mode, myf my_flags);
-@@ -822,6 +823,8 @@
- extern void my_b_seek(IO_CACHE *info,my_off_t pos);
- extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
- extern my_off_t my_b_filelength(IO_CACHE *info);
-+extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
-+ size_t len);
- extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
- extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
- extern int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
-
-=== modified file 'mysql-test/r/func_compress.result'
---- mysql-test/r/func_compress.result 2011-11-21 16:00:55 +0000
-+++ mysql-test/r/func_compress.result 2012-08-24 12:02:32 +0000
-@@ -11,7 +11,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))`
-+Note 1003 select uncompress(compress((@`test_compress_string`))) AS `uncompress(compress(@test_compress_string))`
- select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
- uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
- 1
-@@ -19,7 +19,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
-+Note 1003 select (uncompressed_length(compress((@`test_compress_string`))) = length((@`test_compress_string`))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
- select uncompressed_length(compress(@test_compress_string));
- uncompressed_length(compress(@test_compress_string))
- 117
-
-=== modified file 'mysql-test/r/func_time_hires.result'
---- mysql-test/r/func_time_hires.result 2011-06-07 16:13:02 +0000
-+++ mysql-test/r/func_time_hires.result 2012-08-24 12:02:32 +0000
-@@ -156,12 +156,12 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select cast(cast((@a) as datetime(4)) as time) AS `cast(cast(@a as datetime(4)) as time(0))`
-+Note 1003 select cast(cast((@`a`) as datetime(4)) as time) AS `cast(cast(@a as datetime(4)) as time(0))`
- select cast(cast(@a as time(2)) as time(6));
- cast(cast(@a as time(2)) as time(6))
- 12:13:14.120000
- select CAST(@a AS DATETIME(7));
--ERROR 42000: Too big precision 7 specified for '(@a)'. Maximum is 6.
-+ERROR 42000: Too big precision 7 specified for '(@`a`)'. Maximum is 6.
- SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
- CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00')
- 2011-01-02 15:00:00
-
-=== modified file 'mysql-test/r/mysqlbinlog-innodb.result'
---- mysql-test/r/mysqlbinlog-innodb.result 2011-01-13 12:28:36 +0000
-+++ mysql-test/r/mysqlbinlog-innodb.result 2012-08-24 10:32:46 +0000
-@@ -34,7 +34,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-@@ -65,7 +65,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use foo/*!*/;
-+use `foo`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog.result'
---- mysql-test/r/mysqlbinlog.result 2011-05-10 15:17:43 +0000
-+++ mysql-test/r/mysqlbinlog.result 2012-08-24 12:02:32 +0000
-@@ -20,7 +20,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -66,7 +66,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -99,7 +99,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -121,7 +121,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -167,7 +167,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -200,7 +200,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -229,7 +229,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844555/*!*/;
- insert t1 values (1)
- /*!*/;
-@@ -248,7 +248,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844555/*!*/;
- insert t1 values (1)
- /*!*/;
-@@ -302,7 +302,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -352,7 +352,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -487,7 +487,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1253783037/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -587,7 +587,7 @@
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog2.result'
---- mysql-test/r/mysqlbinlog2.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/mysqlbinlog2.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -62,7 +62,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -101,7 +101,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -127,7 +127,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -162,7 +162,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -185,7 +185,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -215,7 +215,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -246,7 +246,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -281,7 +281,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -304,7 +304,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -335,7 +335,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -358,7 +358,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -377,7 +377,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -399,7 +399,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -445,7 +445,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -468,7 +468,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -490,7 +490,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -520,7 +520,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -563,7 +563,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -601,7 +601,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -627,7 +627,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -661,7 +661,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -684,7 +684,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -714,7 +714,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -744,7 +744,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -779,7 +779,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -802,7 +802,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -833,7 +833,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -855,7 +855,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- SET INSERT_ID=4/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609946/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -874,7 +874,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -896,7 +896,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -942,7 +942,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -965,7 +965,7 @@
- DELIMITER ;
- DELIMITER /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -987,7 +987,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1017,7 +1017,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row.result'
---- mysql-test/r/mysqlbinlog_row.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row.result 2012-08-24 08:06:16 +0000
-@@ -336,7 +336,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_innodb.result'
---- mysql-test/r/mysqlbinlog_row_innodb.result 2010-03-22 12:10:18 +0000
-+++ mysql-test/r/mysqlbinlog_row_innodb.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3876,7 +3876,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4243,7 +4243,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4804,7 +4804,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_myisam.result'
---- mysql-test/r/mysqlbinlog_row_myisam.result 2008-09-06 04:49:43 +0000
-+++ mysql-test/r/mysqlbinlog_row_myisam.result 2012-08-24 08:06:16 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3898,7 +3898,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4271,7 +4271,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4842,7 +4842,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_trans.result'
---- mysql-test/r/mysqlbinlog_row_trans.result 2009-08-27 09:32:27 +0000
-+++ mysql-test/r/mysqlbinlog_row_trans.result 2012-08-24 08:06:16 +0000
-@@ -132,7 +132,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/user_var-binlog.result'
---- mysql-test/r/user_var-binlog.result 2008-04-02 09:49:22 +0000
-+++ mysql-test/r/user_var-binlog.result 2012-08-24 08:06:16 +0000
-@@ -19,7 +19,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/variables.result'
---- mysql-test/r/variables.result 2011-12-11 09:34:44 +0000
-+++ mysql-test/r/variables.result 2012-08-24 12:02:32 +0000
-@@ -78,7 +78,7 @@
- id select_type table type possible_keys key key_len ref rows filtered Extra
- 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
- Warnings:
--Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
-+Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@`t1`) AS `@t1`,(@`t2`) AS `@t2`,(@`t3`) AS `@t3`
- select @t5;
- @t5
- 1.23456
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_base64_flag.result'
---- mysql-test/suite/binlog/r/binlog_base64_flag.result 2011-02-23 09:31:37 +0000
-+++ mysql-test/suite/binlog/r/binlog_base64_flag.result 2012-08-24 08:06:16 +0000
-@@ -35,7 +35,7 @@
- # at 4
- <#>ROLLBACK/*!*/;
- # at 102
--<#>use test/*!*/;
-+<#>use `test`/*!*/;
- SET TIMESTAMP=1196959712/*!*/;
- <#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
- SET @@session.sql_mode=0/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result'
---- mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2011-01-13 12:28:36 +0000
-+++ mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2012-08-24 10:32:46 +0000
-@@ -35,7 +35,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -72,7 +72,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -115,7 +115,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-@@ -229,7 +229,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -266,7 +266,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -309,7 +309,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
---- mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2008-10-23 19:27:09 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2012-08-24 08:06:16 +0000
-@@ -13,7 +13,7 @@
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
- SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
---- mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2010-09-02 13:05:06 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2012-08-24 08:06:16 +0000
-@@ -631,7 +631,7 @@
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- /* the output must denote there is the query */;
- drop trigger trg_del_t2;
-@@ -869,7 +869,7 @@
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`=((@b) + `bug27417`(2)) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=((@`b`) + `bug27417`(2)) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- drop trigger trg_del_t2;
- drop table t1,t2,t3,t4,t5;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_hrtime.result'
---- mysql-test/suite/rpl/r/rpl_hrtime.result 2011-05-28 02:11:32 +0000
-+++ mysql-test/suite/rpl/r/rpl_hrtime.result 2012-08-24 12:02:32 +0000
-@@ -30,7 +30,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1293832861/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== added file 'mysql-test/suite/rpl/r/rpl_mdev382.result'
---- mysql-test/suite/rpl/r/rpl_mdev382.result 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/r/rpl_mdev382.result 2012-08-24 10:32:46 +0000
-@@ -0,0 +1,302 @@
-+include/master-slave.inc
-+[connection master]
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+Warnings:
-+Warning 1196 Some non-transactional changed tables couldn't be rolled back
-+insert into t1 values (3);
-+commit;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
-+master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
-+master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
-+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
-+master-bin.000001 # Query # # use `test`; insert into t2 values (1)
-+master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
-+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values(10)
-+master-bin.000001 # Query # # SAVEPOINT "a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(11)
-+master-bin.000001 # Query # # SAVEPOINT "a""a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(12)
-+master-bin.000001 # Query # # SAVEPOINT b
-+master-bin.000001 # Query # # use `test`; insert into t1 values(13)
-+master-bin.000001 # Query # # SAVEPOINT "b""b"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(14)
-+master-bin.000001 # Query # # SAVEPOINT `c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(15)
-+master-bin.000001 # Query # # SAVEPOINT `c``c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(16)
-+master-bin.000001 # Query # # SAVEPOINT d
-+master-bin.000001 # Query # # use `test`; insert into t1 values(17)
-+master-bin.000001 # Query # # SAVEPOINT `d``d`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(18)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+*** Test correct USE statement in SHOW BINLOG EVENTS ***
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+DROP TABLE t1;
-+use test;
-+***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+truncate `t``1`;
-+use test;
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!') ;file_id=#
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`=(@`b```), `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+truncate `t``1`
-+/*!*/;
-+use `test`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`=concat('|','b"a\'z','!')
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+drop table t1,t2;
-+*** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
-+FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`=concat((@`b`),'| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|',(@`b`)) ;file_id=#
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+DROP TABLE t1;
-+*** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+master-bin.000001 # User var # # @`a``1`=-9223372036854775808
-+master-bin.000001 # User var # # @`a``2`=42
-+master-bin.000001 # User var # # @`a``3`=9223372036854775807
-+master-bin.000001 # User var # # @`a``4`=-1
-+master-bin.000001 # User var # # @`b```=-1.2345601234568e+125
-+master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
-+master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+/*!*/;
-+SET @`a``1`:=-9223372036854775808/*!*/;
-+SET @`a``2`:=42/*!*/;
-+SET @`a``3`:=9223372036854775807/*!*/;
-+SET @`a``4`:=-1/*!*/;
-+SET @`b```:=-1.2345601234568e+125/*!*/;
-+SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
-+SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+a1 a2 a3 a4 b c d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.23456012345679e+125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+-9223372036854775807 4200 9223372036854775806 0 -6.17280061728394e+124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+DROP TABLE t1;
-+*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+include/stop_slave.inc
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+a`
-+1
-+2
-+5
-+set timestamp=1000000000;
-+# The table should be empty on the master.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+# The DELETE statement should be correctly quoted
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
-+include/start_slave.inc
-+# The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+*** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+INSERT INTO t1 VALUES(1);
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES(1)
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `ts``et`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+INSERT INTO t1 VALUES(1)
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+DROP TABLE t1;
-+include/rpl_end.inc
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
---- mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2012-08-24 08:06:16 +0000
-@@ -153,7 +153,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -175,7 +175,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -284,7 +284,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -316,7 +316,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
---- mysql-test/suite/rpl/r/rpl_sp.result 2010-12-19 17:07:28 +0000
-+++ mysql-test/suite/rpl/r/rpl_sp.result 2012-08-24 08:06:16 +0000
-@@ -627,7 +627,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest1
- /*!*/;
--use mysqltest1/*!*/;
-+use `mysqltest1`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t1 (a varchar(100))
- /*!*/;
-@@ -840,7 +840,7 @@
- SET TIMESTAMP=t/*!*/;
- drop user "zedjzlcsjhd"@127.0.0.1
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- drop function if exists f1
- /*!*/;
-@@ -925,7 +925,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest2
- /*!*/;
--use mysqltest2/*!*/;
-+use `mysqltest2`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t ( t integer )
- /*!*/;
-@@ -943,7 +943,7 @@
- return 0;
- end
- /*!*/;
--use mysqltest/*!*/;
-+use `mysqltest`/*!*/;
- SET TIMESTAMP=t/*!*/;
- SELECT `mysqltest2`.`f1`()
- /*!*/;
-@@ -953,14 +953,14 @@
- SET TIMESTAMP=t/*!*/;
- drop database mysqltest2
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
- begin
- select 1;
- end
- /*!*/;
--use mysql/*!*/;
-+use `mysql`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
- `label`:
-
-=== added file 'mysql-test/suite/rpl/t/rpl_mdev382.test'
---- mysql-test/suite/rpl/t/rpl_mdev382.test 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/t/rpl_mdev382.test 2012-08-24 10:32:46 +0000
-@@ -0,0 +1,257 @@
-+--source include/have_innodb.inc
-+--source include/not_windows.inc
-+--source include/have_binlog_format_statement.inc
-+--source include/master-slave.inc
-+
-+# MDEV-382: multiple SQL injections in replication code.
-+
-+# Test previous SQL injection attack against binlog for SAVEPOINT statement.
-+# The test would cause syntax error on slave due to improper quoting of
-+# the savepoint name.
-+connection master;
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (3);
-+commit;
-+
-+--source include/show_binlog_events.inc
-+
-+# This failed due to syntax error in query when the bug was not fixed.
-+sync_slave_with_master;
-+connection slave;
-+
-+# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+
-+--source include/show_binlog_events.inc
-+
-+--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+--source include/show_binlog_events.inc
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+--source include/show_binlog_events.inc
-+set sql_quote_show_create = 1;
-+--source include/show_binlog_events.inc
-+DROP TABLE t1;
-+
-+use test;
-+
-+--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
-+--write_file $load_file
-+'fo\\o','bar'
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+ `c``3` VARCHAR(7));
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+
-+SELECT * FROM `t``1`;
-+# Also test when code prefixes table name with database.
-+truncate `t``1`;
-+use test;
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+connection master;
-+
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+--remove_file $load_file
-+
-+connection master;
-+drop table t1,t2;
-+
-+
-+--echo *** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
-+--write_file $load_file
-+1,X
-+2,A
-+EOF
-+--exec chmod go+r "$load_file"
-+
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+# The bug was that the SET expression was truncated to 256 bytes, so test with
-+# an expression longer than that.
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$load_file' INTO TABLE t1
-+ FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+
-+SELECT * FROM t1 ORDER BY a;
-+--source include/show_binlog_events.inc
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM t1 ORDER BY a;
-+
-+connection master;
-+--remove_file $load_file
-+DROP TABLE t1;
-+
-+
-+--echo *** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+
-+connection master;
-+DROP TABLE t1;
-+
-+
-+--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+
-+# Let's keep the slave stopped during master restart, to avoid any potential
-+# races between slave reconnect and master restart.
-+connection slave;
-+--source include/stop_slave.inc
-+
-+connection master;
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+
-+# Restart the master mysqld.
-+# This will cause an implicit truncation of the memory-based table, which will
-+# cause logging of an explicit DELETE FROM to binlog.
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+wait-rpl_mdev382.test
-+EOF
-+
-+--shutdown_server 30
-+
-+--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+restart-rpl_mdev382.test
-+EOF
-+
-+connection default;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+# rpl_end.inc needs to use the connection server_1
-+connection server_1;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+connection master;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+set timestamp=1000000000;
-+
-+--echo # The table should be empty on the master.
-+let $binlog_file= master-bin.000002;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+--echo # The DELETE statement should be correctly quoted
-+--source include/show_binlog_events.inc
-+
-+connection slave;
-+--source include/start_slave.inc
-+
-+connection master;
-+sync_slave_with_master;
-+connection slave;
-+--echo # The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+connection master;
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+sync_slave_with_master;
-+
-+
-+connection master;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+
-+--echo *** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+INSERT INTO t1 VALUES(1);
-+--source include/show_binlog_events.inc
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 --rewrite-db='test->ts`et' $MYSQLD_DATADIR/master-bin.000002
-+DROP TABLE t1;
-+
-+--source include/rpl_end.inc
-
-=== modified file 'mysys/mf_iocache2.c'
---- mysys/mf_iocache2.c 2011-11-21 17:13:14 +0000
-+++ mysys/mf_iocache2.c 2012-08-24 10:32:46 +0000
-@@ -284,6 +284,40 @@
- }
-
-
-+size_t
-+my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len)
-+{
-+ const uchar *start;
-+ const uchar *p= (const uchar *)str;
-+ const uchar *end= p + len;
-+ size_t count;
-+ size_t total= 0;
-+
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ for (;;)
-+ {
-+ start= p;
-+ while (p < end && *p != '`')
-+ ++p;
-+ count= p - start;
-+ if (count && my_b_write(info, start, count))
-+ return (size_t)-1;
-+ total+= count;
-+ if (p >= end)
-+ break;
-+ if (my_b_write(info, (uchar *)"``", 2))
-+ return (size_t)-1;
-+ total+= 2;
-+ ++p;
-+ }
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ return total;
-+}
-+
- /*
- Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
- Used for logging in MySQL
-@@ -308,6 +342,7 @@
- uint minimum_width_sign;
- uint precision; /* as yet unimplemented for anything but %b */
- my_bool is_zero_padded;
-+ my_bool backtick_quoting;
-
- /*
- Store the location of the beginning of a format directive, for the
-@@ -342,6 +377,7 @@
- fmt++;
-
- is_zero_padded= FALSE;
-+ backtick_quoting= FALSE;
- minimum_width_sign= 1;
- minimum_width= 0;
- precision= 0;
-@@ -354,6 +390,8 @@
- minimum_width_sign= -1; fmt++; goto process_flags;
- case '0':
- is_zero_padded= TRUE; fmt++; goto process_flags;
-+ case '`':
-+ backtick_quoting= TRUE; fmt++; goto process_flags;
- case '#':
- /** @todo Implement "#" conversion flag. */ fmt++; goto process_flags;
- case ' ':
-@@ -397,9 +435,19 @@
- reg2 char *par = va_arg(args, char *);
- size_t length2 = strlen(par);
- /* TODO: implement precision */
-- out_length+= length2;
-- if (my_b_write(info, (uchar*) par, length2))
-- goto err;
-+ if (backtick_quoting)
-+ {
-+ size_t total= my_b_write_backtick_quote(info, par, length2);
-+ if (total == (size_t)-1)
-+ goto err;
-+ out_length+= total;
-+ }
-+ else
-+ {
-+ out_length+= length2;
-+ if (my_b_write(info, (uchar*) par, length2))
-+ goto err;
-+ }
- }
- else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
- {
-
-=== modified file 'sql/ha_ndbcluster_binlog.cc'
---- sql/ha_ndbcluster_binlog.cc 2011-12-11 09:34:44 +0000
-+++ sql/ha_ndbcluster_binlog.cc 2012-08-24 12:02:32 +0000
-@@ -1268,7 +1268,9 @@
- DBUG_RETURN(0);
- }
-
-- char tmp_buf2[FN_REFLEN];
-+ char tmp_buf2_mem[FN_REFLEN];
-+ String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
-+ tmp_buf2.length(0);
- const char *type_str;
- switch (type)
- {
-@@ -1277,17 +1279,24 @@
- if (thd->lex->sql_command == SQLCOM_DROP_DB)
- DBUG_RETURN(0);
- /* redo the drop table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "drop table `",
-- table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("drop table "));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "drop table";
- break;
- case SOT_RENAME_TABLE:
- /* redo the rename table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "rename table `",
-- db, ".", table_name, "` to `",
-- new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("rename table "));
-+ append_identifier(thd, &tmp_buf2, db, strlen(db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ tmp_buf2.append(STRING_WITH_LEN(" to "));
-+ append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "rename table";
- break;
- case SOT_CREATE_TABLE:
-
-=== modified file 'sql/item.cc'
---- sql/item.cc 2012-06-08 17:15:01 +0000
-+++ sql/item.cc 2012-08-24 12:02:32 +0000
-@@ -942,15 +942,31 @@
- if (!my_charset_same(cs, system_charset_info))
- {
- size_t res_length;
-- name= sql_strmake_with_convert(str, name_length= length, cs,
-+ name= sql_strmake_with_convert(str, length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
-+ name_length= res_length;
- }
- else
- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
- }
-
-
-+void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
-+{
-+ if (!my_charset_same(cs, system_charset_info))
-+ {
-+ size_t res_length;
-+ name= sql_strmake_with_convert(str, length, cs,
-+ UINT_MAX, system_charset_info,
-+ &res_length);
-+ name_length= res_length;
-+ }
-+ else
-+ name= sql_strmake(str, (name_length= length));
-+}
-+
-+
- void Item::set_name_for_rollback(THD *thd, const char *str, uint length,
- CHARSET_INFO *cs)
- {
-
-=== modified file 'sql/item.h'
---- sql/item.h 2012-05-20 12:57:29 +0000
-+++ sql/item.h 2012-08-24 12:02:32 +0000
-@@ -620,6 +620,7 @@
- #endif
- } /*lint -e1509 */
- void set_name(const char *str, uint length, CHARSET_INFO *cs);
-+ void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
- void set_name_for_rollback(THD *thd, const char *str, uint length,
- CHARSET_INFO *cs);
- void rename(char *new_name);
-
-=== modified file 'sql/item_func.cc'
---- sql/item_func.cc 2012-06-18 18:38:11 +0000
-+++ sql/item_func.cc 2012-08-24 12:02:32 +0000
-@@ -4913,7 +4913,7 @@
- void Item_func_get_user_var::print(String *str, enum_query_type query_type)
- {
- str->append(STRING_WITH_LEN("(@"));
-- str->append(name.str,name.length);
-+ append_identifier(current_thd, str, name.str, name.length);
- str->append(')');
- }
-
-@@ -5011,10 +5011,10 @@
- }
-
-
--void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
-+void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
- {
- str->append('@');
-- str->append(name.str,name.length);
-+ append_identifier(thd, str, name.str, name.length);
- }
-
-
-
-=== modified file 'sql/item_func.h'
---- sql/item_func.h 2011-12-19 20:55:32 +0000
-+++ sql/item_func.h 2012-08-24 12:02:32 +0000
-@@ -1582,7 +1582,7 @@
- my_decimal *val_decimal(my_decimal *decimal_buffer);
- /* fix_fields() binds variable name with its entry structure */
- bool fix_fields(THD *thd, Item **ref);
-- virtual void print(String *str, enum_query_type query_type);
-+ void print_for_load(THD *thd, String *str);
- void set_null_value(CHARSET_INFO* cs);
- void set_value(const char *str, uint length, CHARSET_INFO* cs);
- };
-
-=== modified file 'sql/log.cc'
---- sql/log.cc 2012-05-20 12:57:29 +0000
-+++ sql/log.cc 2012-08-24 12:02:32 +0000
-@@ -39,6 +39,7 @@
-
- #include <mysql/plugin.h>
- #include "debug_sync.h"
-+#include "sql_show.h"
-
- /* max size of the log message */
- #define MAX_LOG_BUFFER_SIZE 1024
-@@ -1794,9 +1795,8 @@
-
- String log_query;
- if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-@@ -1818,9 +1818,8 @@
- {
- String log_query;
- if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-
-=== modified file 'sql/log_event.cc'
---- sql/log_event.cc 2012-06-01 12:56:47 +0000
-+++ sql/log_event.cc 2012-08-24 12:02:32 +0000
-@@ -34,6 +34,7 @@
- #include "rpl_utility.h"
- #include "rpl_record.h"
- #include <my_dir.h>
-+#include "sql_show.h"
-
- #endif /* MYSQL_CLIENT */
-
-@@ -457,29 +458,28 @@
- pretty_print_str()
- */
-
--static char *pretty_print_str(char *packet, const char *str, int len)
-+static void
-+pretty_print_str(String *packet, const char *str, int len)
- {
- const char *end= str + len;
-- char *pos= packet;
-- *pos++= '\'';
-+ packet->append(STRING_WITH_LEN("'"));
- while (str < end)
- {
- char c;
- switch ((c=*str++)) {
-- case '\n': *pos++= '\\'; *pos++= 'n'; break;
-- case '\r': *pos++= '\\'; *pos++= 'r'; break;
-- case '\\': *pos++= '\\'; *pos++= '\\'; break;
-- case '\b': *pos++= '\\'; *pos++= 'b'; break;
-- case '\t': *pos++= '\\'; *pos++= 't'; break;
-- case '\'': *pos++= '\\'; *pos++= '\''; break;
-- case 0 : *pos++= '\\'; *pos++= '0'; break;
-+ case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
-+ case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
-+ case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
-+ case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
-+ case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
-+ case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
-+ case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
- default:
-- *pos++= c;
-+ packet->append(&c, 1);
- break;
- }
- }
-- *pos++= '\'';
-- return pos;
-+ packet->append(STRING_WITH_LEN("'"));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -904,7 +904,7 @@
- Log_event::pack_info()
- */
-
--void Log_event::pack_info(Protocol *protocol)
-+void Log_event::pack_info(THD *thd, Protocol *protocol)
- {
- protocol->store("", &my_charset_bin);
- }
-@@ -913,7 +913,8 @@
- /**
- Only called by SHOW BINLOG EVENTS
- */
--int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
-+int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos)
- {
- const char *p= strrchr(log_name, FN_LIBCHAR);
- const char *event_type;
-@@ -927,7 +928,7 @@
- protocol->store(event_type, strlen(event_type), &my_charset_bin);
- protocol->store((uint32) server_id);
- protocol->store((ulonglong) log_pos);
-- pack_info(protocol);
-+ pack_info(thd, protocol);
- return protocol->write();
- }
- #endif /* HAVE_REPLICATION */
-@@ -2428,27 +2429,22 @@
- show the catalog ??
- */
-
--void Query_log_event::pack_info(Protocol *protocol)
-+void Query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- // TODO: show the catalog ??
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len);
- if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
- && db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf.append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, &buf, db, db_len);
-+ buf.append("; ");
- }
- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ buf.append(query, q_len);
-+ protocol->store(&buf);
- }
- #endif
-
-@@ -3233,11 +3229,17 @@
- }
- else if (db)
- {
-+ /* Room for expand ` to `` + initial/final ` + \0 */
-+ char buf[FN_REFLEN*2+3];
-+
- different_db= memcmp(print_event_info->db, db, db_len + 1);
- if (different_db)
- memcpy(print_event_info->db, db, db_len + 1);
- if (db[0] && different_db)
-- my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
-+ {
-+ my_snprintf(buf, sizeof(buf), "%`s", db);
-+ my_b_printf(file, "use %s%s\n", buf, print_event_info->delimiter);
-+ }
- }
-
- end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
-@@ -3859,7 +3861,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Start_log_event_v3::pack_info(Protocol *protocol)
-+void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
- pos= strmov(buf, "Server ver: ");
-@@ -4635,131 +4637,115 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--uint Load_log_event::get_query_buffer_length()
--{
-- return
-- 5 + db_len + 3 + // "use DB; "
-- 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
-- 11 + // "CONCURRENT "
-- 7 + // LOCAL
-- 9 + // " REPLACE or IGNORE "
-- 13 + table_name_len*2 + // "INTO TABLE `table`"
-- 21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
-- 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
-- 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
-- 21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
-- 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
-- 15 + 22 + // " IGNORE xxx LINES"
-- 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
--}
--
--
--void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
-- char **end, char **fn_start, char **fn_end)
--{
-- char *pos= buf;
--
-+void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
-+ String *buf, my_off_t *fn_start,
-+ my_off_t *fn_end, const char *qualify_db)
-+{
- if (need_db && db && db_len)
- {
-- pos= strmov(pos, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf->append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, buf, db, db_len);
-+ buf->append(STRING_WITH_LEN("; "));
- }
-
-- pos= strmov(pos, "LOAD DATA ");
-+ buf->append(STRING_WITH_LEN("LOAD DATA "));
-
- if (thd->lex->lock_option == TL_WRITE_CONCURRENT_INSERT)
-- pos= strmov(pos, "CONCURRENT ");
-+ buf->append(STRING_WITH_LEN("CONCURRENT "));
-
- if (fn_start)
-- *fn_start= pos;
-+ *fn_start= buf->length();
-
- if (check_fname_outside_temp_buf())
-- pos= strmov(pos, "LOCAL ");
-- pos= strmov(pos, "INFILE '");
-- memcpy(pos, fname, fname_len);
-- pos= strmov(pos+fname_len, "' ");
-+ buf->append(STRING_WITH_LEN("LOCAL "));
-+ buf->append(STRING_WITH_LEN("INFILE '"));
-+ buf->append_for_single_quote(fname, fname_len);
-+ buf->append(STRING_WITH_LEN("' "));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
-- pos= strmov(pos, "REPLACE ");
-+ buf->append(STRING_WITH_LEN("REPLACE "));
- else if (sql_ex.opt_flags & IGNORE_FLAG)
-- pos= strmov(pos, "IGNORE ");
-+ buf->append(STRING_WITH_LEN("IGNORE "));
-
-- pos= strmov(pos ,"INTO");
-+ buf->append(STRING_WITH_LEN("INTO"));
-
- if (fn_end)
-- *fn_end= pos;
-+ *fn_end= buf->length();
-
-- pos= strmov(pos ," TABLE `");
-- memcpy(pos, table_name, table_name_len);
-- pos+= table_name_len;
-+ buf->append(STRING_WITH_LEN(" TABLE "));
-+ if (qualify_db)
-+ {
-+ append_identifier(thd, buf, qualify_db, strlen(qualify_db));
-+ buf->append(STRING_WITH_LEN("."));
-+ }
-+ append_identifier(thd, buf, table_name, table_name_len);
-
- if (cs != NULL)
- {
-- pos= strmov(pos ,"` CHARACTER SET ");
-- pos= strmov(pos , cs);
-+ buf->append(STRING_WITH_LEN(" CHARACTER SET "));
-+ buf->append(cs, strlen(cs));
- }
-- else
-- pos= strmov(pos, "`");
-
- /* We have to create all optional fields as the default is not empty */
-- pos= strmov(pos, " FIELDS TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
-+ buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
- if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
-- pos= strmov(pos, " OPTIONALLY ");
-- pos= strmov(pos, " ENCLOSED BY ");
-- pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
--
-- pos= strmov(pos, " ESCAPED BY ");
-- pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
--
-- pos= strmov(pos, " LINES TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
-+ buf->append(STRING_WITH_LEN(" OPTIONALLY "));
-+ buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
-+ pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
-+
-+ buf->append(STRING_WITH_LEN(" ESCAPED BY "));
-+ pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
-+
-+ buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
- if (sql_ex.line_start_len)
- {
-- pos= strmov(pos, " STARTING BY ");
-- pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
-+ buf->append(STRING_WITH_LEN(" STARTING BY "));
-+ pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
- }
-
- if ((long) skip_lines > 0)
- {
-- pos= strmov(pos, " IGNORE ");
-- pos= longlong10_to_str((longlong) skip_lines, pos, 10);
-- pos= strmov(pos," LINES ");
-+ char skipbuf[22];
-+ buf->append(STRING_WITH_LEN(" IGNORE "));
-+ longlong10_to_str((longlong) skip_lines, skipbuf, 10);
-+ buf->append(skipbuf);
-+ buf->append(STRING_WITH_LEN(" LINES "));
- }
-
- if (num_fields)
- {
- uint i;
- const char *field= fields;
-- pos= strmov(pos, " (");
-+ buf->append(STRING_WITH_LEN(" ("));
- for (i = 0; i < num_fields; i++)
- {
- if (i)
- {
-- *pos++= ' ';
-- *pos++= ',';
-+ /*
-+ Yes, the space and comma is reversed here. But this is mostly dead
-+ code, at most used when reading really old binlogs from old servers,
-+ so better just leave it as is...
-+ */
-+ buf->append(STRING_WITH_LEN(" ,"));
- }
-- memcpy(pos, field, field_lens[i]);
-- pos+= field_lens[i];
-+ append_identifier(thd, buf, field, field_lens[i]);
- field+= field_lens[i] + 1;
- }
-- *pos++= ')';
-+ buf->append(STRING_WITH_LEN(")"));
- }
--
-- *end= pos;
- }
-
-
--void Load_log_event::pack_info(Protocol *protocol)
-+void Load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *end;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
-
-- if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
-- return;
-- print_query(TRUE, NULL, buf, &end, 0, 0);
-- protocol->store(buf, end-buf, &my_charset_bin);
-- my_free(buf, MYF(0));
-+ query_str.length(0);
-+ print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
-+ protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
- }
- #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-
-@@ -5026,7 +5012,7 @@
- else if (sql_ex.opt_flags & IGNORE_FLAG)
- my_b_printf(&cache,"IGNORE ");
-
-- my_b_printf(&cache, "INTO TABLE `%s`", table_name);
-+ my_b_printf(&cache, "INTO TABLE %`s", table_name);
- my_b_printf(&cache, " FIELDS TERMINATED BY ");
- pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
-
-@@ -5215,16 +5201,20 @@
- else
- {
- char llbuff[22];
-- char *end;
- enum enum_duplicates handle_dup;
- bool ignore= 0;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
- char *load_data_query;
-
-+ query_str.length(0);
- /*
- Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
- and written to slave's binlog if binlogging is on.
- */
-- if (!(load_data_query= (char *)thd->alloc(get_query_buffer_length() + 1)))
-+ print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(),
-+ query_str.length())))
- {
- /*
- This will set thd->fatal_error in case of OOM. So we surely will notice
-@@ -5233,9 +5223,7 @@
- goto error;
- }
-
-- print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
-- *end= 0;
-- thd->set_query(load_data_query, (uint) (end - load_data_query));
-+ thd->set_query(load_data_query, (uint) (query_str.length()));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
- {
-@@ -5400,7 +5388,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rotate_log_event::pack_info(Protocol *protocol)
-+void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], buf[22];
- String tmp(buf1, sizeof(buf1), log_cs);
-@@ -5618,7 +5606,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Intvar_log_event::pack_info(Protocol *protocol)
-+void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256], *pos;
- pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
-@@ -5768,7 +5756,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rand_log_event::pack_info(Protocol *protocol)
-+void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], *pos;
- pos= strmov(buf1,"rand_seed1=");
-@@ -5867,7 +5855,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Xid_log_event::pack_info(Protocol *protocol)
-+void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[128], *pos;
- pos= strmov(buf, "COMMIT /* xid=");
-@@ -5955,69 +5943,109 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void User_var_log_event::pack_info(Protocol* protocol)
-+static bool
-+user_var_append_name_part(THD *thd, String *buf,
-+ const char *name, size_t name_len)
- {
-- char *buf= 0;
-- uint val_offset= 4 + name_len;
-- uint event_len= val_offset;
-+ return buf->append("@") ||
-+ append_identifier(thd, buf, name, name_len) ||
-+ buf->append("=");
-+}
-
-+void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
-+{
- if (is_null)
- {
-- if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
-+ char buf_mem[FN_REFLEN+7];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("NULL"))
- return;
-- strmov(buf + val_offset, "NULL");
-- event_len= val_offset + 4;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
- else
- {
- switch (type) {
- case REAL_RESULT:
-+ {
- double real_val;
-+ char buf2[FLOATING_POINT_BUFFER];
-+ char buf_mem[FN_REFLEN + FLOATING_POINT_BUFFER];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- float8get(real_val, val);
-- if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
-- MYF(MY_WME))))
-- return;
-- event_len+= my_sprintf(buf + val_offset,
-- (buf + val_offset, "%.14g", real_val));
-+ buf.length(0);
-+ my_sprintf(buf2, (buf2, "%.14g", real_val));
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case INT_RESULT:
-- if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
-+ {
-+ char buf2[22];
-+ char buf_mem[FN_REFLEN + 22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2, longlong10_to_str(uint8korr(val), buf2, -10)-buf2))
- return;
-- event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case DECIMAL_RESULT:
- {
-- if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
-- MYF(MY_WME))))
-- return;
-- String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
-+ char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ char buf2[DECIMAL_MAX_STR_LENGTH+1];
-+ String str(buf2, sizeof(buf2), &my_charset_bin);
- my_decimal dec;
-+ buf.length(0);
- binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
- val[1]);
- my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
-- event_len= str.length() + val_offset;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
- }
- case STRING_RESULT:
-+ {
- /* 15 is for 'COLLATE' and other chars */
-- buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
-- MYF(MY_WME));
-+ char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- CHARSET_INFO *cs;
-- if (!buf)
-- return;
-+ buf.length(0);
- if (!(cs= get_charset(charset_number, MYF(0))))
- {
-- strmov(buf+val_offset, "???");
-- event_len+= 3;
-+ if (buf.append("???"))
-+ return;
- }
- else
- {
-- char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
-- p= str_to_hex(p, val, val_len);
-- p= strxmov(p, " COLLATE ", cs->name, NullS);
-- event_len= p-buf;
-+ size_t old_len;
-+ char *beg, *end;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("_") ||
-+ buf.append(cs->csname) ||
-+ buf.append(" "))
-+ return;
-+ old_len= buf.length();
-+ if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
-+ MY_CS_NAME_SIZE))
-+ return;
-+ beg= const_cast<char *>(buf.ptr()) + old_len;
-+ end= str_to_hex(beg, val, val_len);
-+ buf.length(old_len + (end - beg));
-+ if (buf.append(" COLLATE ") ||
-+ buf.append(cs->name))
-+ return;
- }
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
- default:
-@@ -6025,13 +6053,6 @@
- return;
- }
- }
-- buf[0]= '@';
-- buf[1]= '`';
-- memcpy(buf+2, name, name_len);
-- buf[2+name_len]= '`';
-- buf[3+name_len]= '=';
-- protocol->store(buf, event_len, &my_charset_bin);
-- my_free(buf, MYF(0));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -6148,9 +6169,8 @@
- my_b_printf(&cache, "\tUser_var\n");
- }
-
-- my_b_printf(&cache, "SET @`");
-- my_b_write(&cache, (uchar*) name, (uint) (name_len));
-- my_b_printf(&cache, "`");
-+ my_b_printf(&cache, "SET @");
-+ my_b_write_backtick_quote(&cache, name, name_len);
-
- if (is_null)
- {
-@@ -6223,7 +6243,7 @@
- */
- my_b_printf(&cache, ":=???%s\n", print_event_info->delimiter);
- else
-- my_b_printf(&cache, ":=_%s %s COLLATE `%s`%s\n",
-+ my_b_printf(&cache, ":=_%s %s COLLATE %`s%s\n",
- cs->csname, hex_str, cs->name,
- print_event_info->delimiter);
- my_afree(hex_str);
-@@ -6362,7 +6382,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
--void Slave_log_event::pack_info(Protocol *protocol)
-+void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256+HOSTNAME_LENGTH], *pos;
- pos= strmov(buf, "host=");
-@@ -6734,7 +6754,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Create_file_log_event::pack_info(Protocol *protocol)
-+void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos;
- pos= strmov(buf, "db=");
-@@ -6916,7 +6936,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Append_block_log_event::pack_info(Protocol *protocol)
-+void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- uint length;
-@@ -7069,7 +7089,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Delete_file_log_event::pack_info(Protocol *protocol)
-+void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -7168,7 +7188,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_log_event::pack_info(Protocol *protocol)
-+void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -7422,27 +7442,26 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_query_log_event::pack_info(Protocol *protocol)
-+void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ char file_id_buf[22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len + 10 + 21);
- if (db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-- }
-- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- pos= strmov(pos, " ;file_id=");
-- pos= int10_to_str((long) file_id, pos, 10);
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
-+ if (buf.append("use ") ||
-+ append_identifier(thd, &buf, db, db_len) ||
-+ buf.append("; "))
-+ return;
-+ }
-+ if (query && q_len && buf.append(query, q_len))
-+ return;
-+ int10_to_str((long) file_id, file_id_buf, 10);
-+ if (buf.append(" ;file_id=") ||
-+ buf.append(file_id_buf))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
-
-
-@@ -8386,7 +8405,7 @@
- #endif
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rows_log_event::pack_info(Protocol *protocol)
-+void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-@@ -8488,7 +8507,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
--void Annotate_rows_log_event::pack_info(Protocol* protocol)
-+void Annotate_rows_log_event::pack_info(THD *thd, Protocol* protocol)
- {
- if (m_query_txt && m_query_len)
- protocol->store(m_query_txt, m_query_len, &my_charset_bin);
-@@ -9230,7 +9249,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Table_map_log_event::pack_info(Protocol *protocol)
-+void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes= my_snprintf(buf, sizeof(buf),
-@@ -9251,7 +9270,7 @@
- {
- print_header(&print_event_info->head_cache, print_event_info, TRUE);
- my_b_printf(&print_event_info->head_cache,
-- "\tTable_map: `%s`.`%s` mapped to number %lu\n",
-+ "\tTable_map: %`s.%`s mapped to number %lu\n",
- m_dbnam, m_tblnam, m_table_id);
- print_base64(&print_event_info->body_cache, print_event_info, TRUE);
- }
-@@ -10531,7 +10550,7 @@
-
-
- #ifndef MYSQL_CLIENT
--void Incident_log_event::pack_info(Protocol *protocol)
-+void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes;
-
-=== modified file 'sql/log_event.h'
---- sql/log_event.h 2012-03-13 14:38:43 +0000
-+++ sql/log_event.h 2012-08-24 12:02:32 +0000
-@@ -1008,14 +1008,15 @@
- */
- static void init_show_field_list(List<Item>* field_list);
- #ifdef HAVE_REPLICATION
-- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
-+ int net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos);
-
- /*
- pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
- a string to display to the user, so it resembles print().
- */
-
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
-
- #endif /* HAVE_REPLICATION */
- virtual const char* get_db()
-@@ -1741,7 +1742,7 @@
- bool using_trans, bool suppress_use, int error);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -1871,7 +1872,7 @@
-
- #ifndef MYSQL_CLIENT
- Slave_log_event(THD* thd_arg, Relay_log_info* rli);
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2104,9 +2105,11 @@
- const Format_description_log_event* description_event);
-
- public:
-- uint get_query_buffer_length();
-- void print_query(bool need_db, const char *cs, char *buf, char **end,
-- char **fn_start, char **fn_end);
-+#ifndef MYSQL_CLIENT
-+ void print_query(THD *thd, bool need_db, const char *cs, String *buf,
-+ my_off_t *fn_start, my_off_t *fn_end,
-+ const char *qualify_db);
-+#endif
- ulong thread_id;
- ulong slave_proxy_id;
- uint32 table_name_len;
-@@ -2154,7 +2157,7 @@
- Name_resolution_context *context);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2253,7 +2256,7 @@
- #ifndef MYSQL_CLIENT
- Start_log_event_v3();
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- Start_log_event_v3() {}
-@@ -2414,7 +2417,7 @@
- :Log_event(thd_arg,0,0), val(val_arg), type(type_arg)
- { cache_type= cache_type_arg; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2491,7 +2494,7 @@
- :Log_event(thd_arg, 0, 0), seed1(seed1_arg), seed2(seed2_arg)
- { cache_type= cache_type_arg; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2536,7 +2539,7 @@
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, 0), xid(x)
- { cache_type= EVENT_NO_CACHE; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2586,7 +2589,7 @@
- :Log_event(thd_arg, 0, 0), name(name_arg), name_len(name_len_arg), val(val_arg),
- val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
- { is_null= !val; cache_type= cache_type_arg; }
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2717,7 +2720,7 @@
- uint ident_len_arg,
- ulonglong pos_arg, uint flags);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2777,7 +2780,7 @@
- uchar* block_arg, uint block_len_arg,
- bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2849,7 +2852,7 @@
- Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
- uint block_len_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- virtual int get_create_or_append() const;
- #endif /* HAVE_REPLICATION */
- #else
-@@ -2890,7 +2893,7 @@
- #ifndef MYSQL_CLIENT
- Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2931,7 +2934,7 @@
- #ifndef MYSQL_CLIENT
- Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3027,7 +3030,7 @@
- bool using_trans, bool suppress_use,
- int errcode);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3113,7 +3116,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol*);
-+ virtual void pack_info(THD *thd, Protocol*);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3527,7 +3530,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3639,7 +3642,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -4080,7 +4083,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
-- void pack_info(Protocol*);
-+ void pack_info(THD *thd, Protocol*);
- #endif
-
- Incident_log_event(const char *buf, uint event_len,
-
-=== modified file 'sql/log_event_old.cc'
---- sql/log_event_old.cc 2012-03-13 14:38:43 +0000
-+++ sql/log_event_old.cc 2012-08-24 12:02:32 +0000
-@@ -2012,7 +2012,7 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Old_rows_log_event::pack_info(Protocol *protocol)
-+void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-
-=== modified file 'sql/log_event_old.h'
---- sql/log_event_old.h 2012-03-13 14:38:43 +0000
-+++ sql/log_event_old.h 2012-08-24 12:02:32 +0000
-@@ -108,7 +108,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-
-=== modified file 'sql/mysql_priv.h'
---- sql/mysql_priv.h 2012-05-21 14:37:46 +0000
-+++ sql/mysql_priv.h 2012-08-24 12:02:32 +0000
-@@ -1549,7 +1549,7 @@
- /* sql_show.cc */
- bool mysqld_show_open_tables(THD *thd,const char *wild);
- bool mysqld_show_logs(THD *thd);
--void append_identifier(THD *thd, String *packet, const char *name,
-+bool append_identifier(THD *thd, String *packet, const char *name,
- uint length);
- #endif /* MYSQL_SERVER */
- #if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-
-=== modified file 'sql/sql_base.cc'
---- sql/sql_base.cc 2012-05-21 14:37:46 +0000
-+++ sql/sql_base.cc 2012-08-24 12:02:32 +0000
-@@ -4254,22 +4254,22 @@
- entry->file->implicit_emptied= 0;
- if (mysql_bin_log.is_open())
- {
-- char *query, *end;
-- uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
-- if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
-+ char query_buf[2*FN_REFLEN + 21];
-+ String query(query_buf, sizeof(query_buf), system_charset_info);
-+ query.length(0);
-+ if (query.ptr())
- {
- /* this DELETE FROM is needed even with row-based binlogging */
-- end = strxmov(strmov(query, "DELETE FROM `"),
-- share->db.str,"`.`",share->table_name.str,"`", NullS);
-+ query.append("DELETE FROM ");
-+ append_identifier(thd, &query, share->db.str, share->db.length);
-+ query.append(".");
-+ append_identifier(thd, &query, share->table_name.str,
-+ share->table_name.length);
- int errcode= query_error_code(thd, TRUE);
- if (thd->binlog_query(THD::STMT_QUERY_TYPE,
-- query, (ulong)(end-query),
-+ query.ptr(), query.length(),
- FALSE, FALSE, errcode))
-- {
-- my_free(query, MYF(0));
- goto err;
-- }
-- my_free(query, MYF(0));
- }
- else
- {
-@@ -4279,7 +4279,7 @@
- because of MYF(MY_WME) in my_malloc() above).
- */
- sql_print_error("When opening HEAP table, could not allocate memory "
-- "to write 'DELETE FROM `%s`.`%s`' to the binary log",
-+ "to write 'DELETE FROM %`s.%`s' to the binary log",
- table_list->db, table_list->table_name);
- delete entry->triggers;
- closefrm(entry, 0);
-
-=== modified file 'sql/sql_db.cc'
---- sql/sql_db.cc 2011-12-11 09:34:44 +0000
-+++ sql/sql_db.cc 2012-08-24 12:02:32 +0000
-@@ -614,7 +614,6 @@
- bool silent)
- {
- char path[FN_REFLEN+16];
-- char tmp_query[FN_REFLEN+16];
- long result= 1;
- int error= 0;
- MY_STAT stat_info;
-@@ -721,17 +720,9 @@
- char *query;
- uint query_length;
-
-- if (!thd->query()) // Only in replication
-- {
-- query= tmp_query;
-- query_length= (uint) (strxmov(tmp_query,"create database `",
-- db, "`", NullS) - tmp_query);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-
- ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB,
- query, query_length,
-@@ -991,18 +982,11 @@
- {
- const char *query;
- ulong query_length;
-- if (!thd->query())
-- {
-- /* The client used the old obsolete mysql_drop_db() call */
-- query= path;
-- query_length= (uint) (strxmov(path, "drop database `", db, "`",
-- NullS) - path);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-+
- if (mysql_bin_log.is_open())
- {
- thd->clear_error();
-@@ -1043,9 +1027,10 @@
- for (tbl= dropped_tables; tbl; tbl= tbl->next_local)
- {
- uint tbl_name_len;
-+ char quoted_name[FN_REFLEN+3];
-
-- /* 3 for the quotes and the comma*/
-- tbl_name_len= strlen(tbl->table_name) + 3;
-+ my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name);
-+ tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
- if (query_pos + tbl_name_len + 1 >= query_end)
- {
- /* These DDL methods and logging protected with LOCK_mysql_create_db */
-@@ -1057,9 +1042,7 @@
- query_pos= query_data_start;
- }
-
-- *query_pos++ = '`';
-- query_pos= strmov(query_pos,tbl->table_name);
-- *query_pos++ = '`';
-+ query_pos= strmov(query_pos, quoted_name);
- *query_pos++ = ',';
- }
-
-
-=== modified file 'sql/sql_insert.cc'
---- sql/sql_insert.cc 2012-02-03 11:32:29 +0000
-+++ sql/sql_insert.cc 2012-08-24 12:02:32 +0000
-@@ -3543,16 +3543,16 @@
- if (thd->lex->create_select_in_comment)
- query.append(STRING_WITH_LEN("/*! "));
- if (thd->lex->ignore)
-- query.append(STRING_WITH_LEN("INSERT IGNORE INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT IGNORE INTO "));
- else if (thd->lex->duplicates == DUP_REPLACE)
-- query.append(STRING_WITH_LEN("REPLACE INTO `"));
-+ query.append(STRING_WITH_LEN("REPLACE INTO "));
- else
-- query.append(STRING_WITH_LEN("INSERT INTO `"));
-+ query.append(STRING_WITH_LEN("INSERT INTO "));
-
-- query.append(create_table->db, db_len);
-- query.append(STRING_WITH_LEN("`.`"));
-- query.append(create_info->alias, table_len);
-- query.append(STRING_WITH_LEN("` "));
-+ append_identifier(thd, &query, create_table->db, db_len);
-+ query.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &query, create_info->alias, table_len);
-+ query.append(STRING_WITH_LEN(" "));
-
- /*
- The insert items.
-
-=== modified file 'sql/sql_load.cc'
---- sql/sql_load.cc 2012-04-05 21:07:18 +0000
-+++ sql/sql_load.cc 2012-08-24 12:02:32 +0000
-@@ -24,6 +24,7 @@
- #include "sql_repl.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "sql_show.h"
-
- class READ_INFO {
- File file;
-@@ -615,24 +616,31 @@
- bool transactional_table,
- int errcode)
- {
-- char *load_data_query,
-- *end,
-- *fname_start,
-- *fname_end,
-- *p= NULL;
-- size_t pl= 0;
-+ char *load_data_query;
-+ my_off_t fname_start,
-+ fname_end;
- List<Item> fv;
- Item *item, *val;
- int n;
-- const char *tbl= table_name_arg;
- const char *tdb= (thd->db != NULL ? thd->db : db_arg);
-+ const char *qualify_db= NULL;
- char name_buffer[SAFE_NAME_LEN*2];
- char command_buffer[1024];
- String string_buf(name_buffer, sizeof(name_buffer),
- system_charset_info);
-- String pfields(command_buffer, sizeof(command_buffer),
-+ String query_str(command_buffer, sizeof(command_buffer),
- system_charset_info);
-
-+ Load_log_event lle(thd, ex, tdb, table_name_arg, fv, duplicates,
-+ ignore, transactional_table);
-+
-+ /*
-+ force in a LOCAL if there was one in the original.
-+ */
-+ if (thd->lex->local_file)
-+ lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+
-+ query_str.length(0);
- if (!thd->db || strcmp(db_arg, thd->db))
- {
- /*
-@@ -640,49 +648,31 @@
- prefix table name with database name so that it
- becomes a FQ name.
- */
-- string_buf.length(0);
-- string_buf.append(db_arg);
-- string_buf.append("`");
-- string_buf.append(".");
-- string_buf.append("`");
-- string_buf.append(table_name_arg);
-- tbl= string_buf.c_ptr_safe();
-+ qualify_db= db_arg;
- }
--
-- Load_log_event lle(thd, ex, tdb, tbl, fv, duplicates,
-- ignore, transactional_table);
--
-- /*
-- force in a LOCAL if there was one in the original.
-- */
-- if (thd->lex->local_file)
-- lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+ lle.print_query(thd, FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-+ &query_str, &fname_start, &fname_end, qualify_db);
-
- /*
- prepare fields-list and SET if needed; print_query won't do that for us.
- */
-- pfields.length(0);
- if (!thd->lex->field_list.is_empty())
- {
- List_iterator<Item> li(thd->lex->field_list);
-
-- pfields.append(" (");
-+ query_str.append(" (");
- n= 0;
-
- while ((item= li++))
- {
- if (n++)
-- pfields.append(", ");
-+ query_str.append(", ");
- if (item->name)
-- {
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- }
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
- else
-- item->print(&pfields, QT_ORDINARY);
-+ ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
- }
-- pfields.append(")");
-+ query_str.append(")");
- }
-
- if (!thd->lex->update_list.is_empty())
-@@ -690,39 +680,26 @@
- List_iterator<Item> lu(thd->lex->update_list);
- List_iterator<Item> lv(thd->lex->value_list);
-
-- pfields.append(" SET ");
-+ query_str.append(" SET ");
- n= 0;
-
- while ((item= lu++))
- {
- val= lv++;
- if (n++)
-- pfields.append(", ");
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- pfields.append("=");
-- val->print(&pfields, QT_ORDINARY);
-+ query_str.append(", ");
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
-+ query_str.append("=");
-+ val->print(&query_str, QT_ORDINARY);
- }
- }
-
-- p= pfields.c_ptr_safe();
-- pl= pfields.length();
--
-- if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(), query_str.length())))
- return TRUE;
-
-- lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-- load_data_query, &end,
-- (char **)&fname_start, (char **)&fname_end);
--
-- strcpy(end, p);
-- end += pl;
--
- Execute_load_query_log_event
-- e(thd, load_data_query, end-load_data_query,
-- (uint) ((char*) fname_start - load_data_query - 1),
-- (uint) ((char*) fname_end - load_data_query),
-+ e(thd, load_data_query, query_str.length(),
-+ (uint) (fname_start - 1), (uint) fname_end,
- (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
- (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
- transactional_table, FALSE, errcode);
-
-=== modified file 'sql/sql_repl.cc'
---- sql/sql_repl.cc 2011-12-11 09:34:44 +0000
-+++ sql/sql_repl.cc 2012-08-24 12:02:32 +0000
-@@ -1721,7 +1721,7 @@
- description_event->checksum_alg= ev->checksum_alg;
-
- if (event_count >= limit_start &&
-- ev->net_send(protocol, linfo.log_file_name, pos))
-+ ev->net_send(thd, protocol, linfo.log_file_name, pos))
- {
- errmsg = "Net error";
- delete ev;
-
-=== modified file 'sql/sql_show.cc'
---- sql/sql_show.cc 2012-05-20 12:57:29 +0000
-+++ sql/sql_show.cc 2012-08-24 12:02:32 +0000
-@@ -1053,9 +1053,13 @@
- packet target string
- name the identifier to be appended
- name_length length of the appending identifier
-+
-+ RETURN VALUES
-+ true Error
-+ false Ok
- */
-
--void
-+bool
- append_identifier(THD *thd, String *packet, const char *name, uint length)
- {
- const char *name_end;
-@@ -1063,10 +1067,7 @@
- int q= get_quote_char_for_identifier(thd, name, length);
-
- if (q == EOF)
-- {
-- packet->append(name, length, packet->charset());
-- return;
-- }
-+ return packet->append(name, length, packet->charset());
-
- /*
- The identifier must be quoted as it includes a quote character or
-@@ -1075,7 +1076,8 @@
-
- VOID(packet->reserve(length*2 + 2));
- quote_char= (char) q;
-- packet->append(&quote_char, 1, system_charset_info);
-+ if (packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-
- for (name_end= name+length ; name < name_end ; name+= length)
- {
-@@ -1090,11 +1092,13 @@
- */
- if (!length)
- length= 1;
-- if (length == 1 && chr == (uchar) quote_char)
-- packet->append(&quote_char, 1, system_charset_info);
-- packet->append(name, length, system_charset_info);
-+ if (length == 1 && chr == (uchar) quote_char &&
-+ packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-+ if (packet->append(name, length, system_charset_info))
-+ return true;
- }
-- packet->append(&quote_char, 1, system_charset_info);
-+ return packet->append(&quote_char, 1, system_charset_info);
- }
-
-
-
-=== modified file 'sql/sql_string.cc'
---- sql/sql_string.cc 2012-04-05 21:07:18 +0000
-+++ sql/sql_string.cc 2012-08-24 12:02:32 +0000
-@@ -1159,39 +1159,47 @@
-
-
-
--
--void String::print(String *str)
-+/*
-+ Append characters to a single-quoted string '...', escaping special
-+ characters as necessary.
-+ Does not add the enclosing quotes, this is left up to caller.
-+*/
-+void String::append_for_single_quote(const char *st, uint len)
- {
-- char *st= (char*)Ptr, *end= st+str_length;
-+ const char *end= st+len;
- for (; st < end; st++)
- {
- uchar c= *st;
- switch (c)
- {
- case '\\':
-- str->append(STRING_WITH_LEN("\\\\"));
-+ append(STRING_WITH_LEN("\\\\"));
- break;
- case '\0':
-- str->append(STRING_WITH_LEN("\\0"));
-+ append(STRING_WITH_LEN("\\0"));
- break;
- case '\'':
-- str->append(STRING_WITH_LEN("\\'"));
-+ append(STRING_WITH_LEN("\\'"));
- break;
- case '\n':
-- str->append(STRING_WITH_LEN("\\n"));
-+ append(STRING_WITH_LEN("\\n"));
- break;
- case '\r':
-- str->append(STRING_WITH_LEN("\\r"));
-+ append(STRING_WITH_LEN("\\r"));
- break;
- case '\032': // Ctrl-Z
-- str->append(STRING_WITH_LEN("\\Z"));
-+ append(STRING_WITH_LEN("\\Z"));
- break;
- default:
-- str->append(c);
-+ append(c);
- }
- }
- }
-
-+void String::print(String *str)
-+{
-+ str->append_for_single_quote(Ptr, str_length);
-+}
-
- /*
- Exchange state of this object and argument.
-
-=== modified file 'sql/sql_string.h'
---- sql/sql_string.h 2011-12-11 09:34:44 +0000
-+++ sql/sql_string.h 2012-08-24 12:02:32 +0000
-@@ -438,6 +438,7 @@
- return FALSE;
- }
- void print(String *print);
-+ void append_for_single_quote(const char *st, uint len);
-
- /* Swap two string objects. Efficient way to exchange data without memcpy. */
- void swap(String &s);
-
-=== modified file 'sql/sql_table.cc'
---- sql/sql_table.cc 2012-04-05 21:07:18 +0000
-+++ sql/sql_table.cc 2012-08-24 12:02:32 +0000
-@@ -1939,6 +1939,7 @@
- for (table= tables; table; table= table->next_local)
- {
- char *db=table->db;
-+ size_t db_length= table->db_length;
- handlerton *table_type;
- enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN;
-
-@@ -1961,14 +1962,14 @@
- built_tmp_query.append("DROP TEMPORARY TABLE IF EXISTS ");
- }
-
-- built_tmp_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_tmp_query.append(db);
-- built_tmp_query.append("`.`");
-+ append_identifier(thd, &built_tmp_query, db, db_length);
-+ built_tmp_query.append(".");
- }
-- built_tmp_query.append(table->table_name);
-- built_tmp_query.append("`,");
-+ append_identifier(thd, &built_tmp_query, table->table_name,
-+ table->table_name_length);
-+ built_tmp_query.append(",");
- }
-
- continue;
-@@ -1994,15 +1995,15 @@
- Don't write the database name if it is the current one (or if
- thd->db is NULL).
- */
-- built_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_query.append(db);
-- built_query.append("`.`");
-+ append_identifier(thd, &built_query, db, db_length);
-+ built_query.append(".");
- }
-
-- built_query.append(table->table_name);
-- built_query.append("`,");
-+ append_identifier(thd, &built_query, table->table_name,
-+ table->table_name_length);
-+ built_query.append(",");
- }
-
- if (!drop_temporary)
-
-=== modified file 'strings/my_vsnprintf.c'
---- strings/my_vsnprintf.c 2011-12-11 09:34:44 +0000
-+++ strings/my_vsnprintf.c 2012-08-24 12:02:32 +0000
-@@ -635,3 +635,67 @@
- va_end(args);
- return result;
- }
-+
-+
-+/**
-+ Writes output to the stream according to a format string.
-+
-+ @param stream file to write to
-+ @param format string format
-+ @param args list of parameters
-+
-+ @retval
-+ number of the characters written.
-+*/
-+
-+int my_vfprintf(FILE *stream, const char* format, va_list args)
-+{
-+ char cvtbuf[1024];
-+ int alloc= 0;
-+ char *p= cvtbuf;
-+ size_t cur_len= sizeof(cvtbuf);
-+ int ret;
-+
-+ /*
-+ We do not know how much buffer we need.
-+ So start with a reasonably-sized stack-allocated buffer, and increase
-+ it exponentially until it is big enough.
-+ */
-+ for (;;)
-+ {
-+ size_t new_len;
-+ size_t actual= my_vsnprintf(p, cur_len, format, args);
-+ if (actual < cur_len - 1)
-+ break;
-+ /*
-+ Not enough space (or just enough with nothing to spare - but we cannot
-+ distinguish this case from the return value). Allocate a bigger buffer
-+ and try again.
-+ */
-+ if (alloc)
-+ (*my_str_free)(p);
-+ else
-+ alloc= 1;
-+ new_len= cur_len*2;
-+ if (new_len < cur_len)
-+ return 0; /* Overflow */
-+ cur_len= new_len;
-+ p= (*my_str_malloc)(cur_len);
-+ if (!p)
-+ return 0;
-+ }
-+ ret= fprintf(stream, "%s", p);
-+ if (alloc)
-+ (*my_str_free)(p);
-+ return ret;
-+}
-+
-+int my_fprintf(FILE *stream, const char* format, ...)
-+{
-+ int result;
-+ va_list args;
-+ va_start(args, format);
-+ result= my_vfprintf(stream, format, args);
-+ va_end(args);
-+ return result;
-+}
-
diff --git a/21000_all_sql-5.5.25.patch b/21000_all_sql-5.5.25.patch
deleted file mode 100644
index d904491..0000000
--- a/21000_all_sql-5.5.25.patch
+++ /dev/null
@@ -1,3338 +0,0 @@
-=== modified file 'client/mysqlbinlog.cc'
---- client/mysqlbinlog.cc 2012-08-09 15:22:00 +0000
-+++ client/mysqlbinlog.cc 2012-08-24 13:29:01 +0000
-@@ -743,7 +743,7 @@
- return;
-
- // In case of rewrite rule print USE statement for db_to
-- fprintf(result_file, "use %s%s\n", db_to, pinfo->delimiter);
-+ my_fprintf(result_file, "use %`s%s\n", db_to, pinfo->delimiter);
-
- // Copy the *original* db to pinfo to suppress emiting
- // of USE stmts by log_event print-functions.
-
-=== modified file 'include/my_sys.h'
---- include/my_sys.h 2012-03-28 17:26:00 +0000
-+++ include/my_sys.h 2012-08-24 13:29:01 +0000
-@@ -627,6 +627,7 @@
- extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
- extern int my_fclose(FILE *fd,myf MyFlags);
- extern int my_vfprintf(FILE *stream, const char* format, va_list args);
-+extern int my_fprintf(FILE *stream, const char* format, ...);
- extern File my_fileno(FILE *fd);
- extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
- extern int my_chmod(const char *name, mode_t mode, myf my_flags);
-@@ -751,6 +752,8 @@
- extern void my_b_seek(IO_CACHE *info,my_off_t pos);
- extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
- extern my_off_t my_b_filelength(IO_CACHE *info);
-+extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str,
-+ size_t len);
- extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
- extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
- extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
-
-=== modified file 'mysql-test/r/mysqlbinlog-innodb.result'
---- mysql-test/r/mysqlbinlog-innodb.result 2011-10-19 19:45:18 +0000
-+++ mysql-test/r/mysqlbinlog-innodb.result 2012-08-24 13:29:01 +0000
-@@ -34,7 +34,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-@@ -65,7 +65,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use foo/*!*/;
-+use `foo`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- INSERT INTO t1 VALUES (1)
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog.result'
---- mysql-test/r/mysqlbinlog.result 2011-10-19 19:45:18 +0000
-+++ mysql-test/r/mysqlbinlog.result 2012-08-24 13:29:01 +0000
-@@ -18,7 +18,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -111,7 +111,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
- /*!*/;
-@@ -202,7 +202,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- insert into t1 values ("Alas")
- /*!*/;
-@@ -219,7 +219,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -312,7 +312,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`)
- /*!*/;
-@@ -403,7 +403,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- insert into t1 values ("Alas")
- /*!*/;
-@@ -427,7 +427,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844555/*!*/;
- insert t1 values (1)
- /*!*/;
-@@ -445,7 +445,7 @@
- SET @@session.collation_database=DEFAULT/*!*/;
- BEGIN
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1108844555/*!*/;
- insert t1 values (1)
- /*!*/;
-@@ -498,7 +498,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -548,7 +548,7 @@
- /*!40019 SET @@session.max_insert_delayed_threads=0*/;
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -725,7 +725,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1253783037/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -825,7 +825,7 @@
- SET TIMESTAMP=1266652094/*!*/;
- SavePoint mixed_cases
- /*!*/;
--use db1/*!*/;
-+use `db1`/*!*/;
- SET TIMESTAMP=1266652094/*!*/;
- INSERT INTO db1.t2 VALUES("in savepoint mixed_cases")
- /*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog2.result'
---- mysql-test/r/mysqlbinlog2.result 2010-01-07 15:39:11 +0000
-+++ mysql-test/r/mysqlbinlog2.result 2012-08-24 13:29:01 +0000
-@@ -19,7 +19,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -103,7 +103,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- insert into t1 values(null, "a")
- /*!*/;
-@@ -172,7 +172,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -209,7 +209,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -263,7 +263,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -289,7 +289,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -326,7 +326,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -369,7 +369,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -445,7 +445,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -474,7 +474,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- insert into t1 values(null, "a")
- /*!*/;
-@@ -535,7 +535,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -564,7 +564,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -605,7 +605,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -622,7 +622,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -720,7 +720,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -761,7 +761,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -778,7 +778,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -820,7 +820,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -904,7 +904,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- insert into t1 values(null, "a")
- /*!*/;
-@@ -972,7 +972,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -1009,7 +1009,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1062,7 +1062,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -1088,7 +1088,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -1125,7 +1125,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1167,7 +1167,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1243,7 +1243,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -1272,7 +1272,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=1/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- insert into t1 values(null, "a")
- /*!*/;
-@@ -1333,7 +1333,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -1361,7 +1361,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -1402,7 +1402,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -1419,7 +1419,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1516,7 +1516,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=3/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609944/*!*/;
- insert into t1 values(null, "c")
- /*!*/;
-@@ -1557,7 +1557,7 @@
- BEGIN
- /*!*/;
- SET INSERT_ID=6/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609943/*!*/;
- insert into t1 values(null, "f")
- /*!*/;
-@@ -1574,7 +1574,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -1616,7 +1616,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1579609942/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row.result'
---- mysql-test/r/mysqlbinlog_row.result 2010-08-23 22:31:12 +0000
-+++ mysql-test/r/mysqlbinlog_row.result 2012-08-24 13:29:01 +0000
-@@ -336,7 +336,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_innodb.result'
---- mysql-test/r/mysqlbinlog_row_innodb.result 2010-03-24 15:03:44 +0000
-+++ mysql-test/r/mysqlbinlog_row_innodb.result 2012-08-24 13:29:01 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3876,7 +3876,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4243,7 +4243,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4804,7 +4804,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_myisam.result'
---- mysql-test/r/mysqlbinlog_row_myisam.result 2010-03-12 12:42:30 +0000
-+++ mysql-test/r/mysqlbinlog_row_myisam.result 2012-08-24 13:29:01 +0000
-@@ -2253,7 +2253,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -3898,7 +3898,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4271,7 +4271,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -4842,7 +4842,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/mysqlbinlog_row_trans.result'
---- mysql-test/r/mysqlbinlog_row_trans.result 2010-01-07 15:39:11 +0000
-+++ mysql-test/r/mysqlbinlog_row_trans.result 2012-08-24 13:29:01 +0000
-@@ -132,7 +132,7 @@
- ROLLBACK/*!*/;
- # at #
- #010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/r/user_var-binlog.result'
---- mysql-test/r/user_var-binlog.result 2010-01-07 15:39:11 +0000
-+++ mysql-test/r/user_var-binlog.result 2012-08-24 13:29:01 +0000
-@@ -34,7 +34,7 @@
- BEGIN
- /*!*/;
- SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- INSERT INTO t1 VALUES(@`a b`)
- /*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_base64_flag.result'
---- mysql-test/suite/binlog/r/binlog_base64_flag.result 2011-12-12 22:58:40 +0000
-+++ mysql-test/suite/binlog/r/binlog_base64_flag.result 2012-08-24 13:29:01 +0000
-@@ -35,7 +35,7 @@
- # at 4
- <#>ROLLBACK/*!*/;
- # at 102
--<#>use test/*!*/;
-+<#>use `test`/*!*/;
- SET TIMESTAMP=1196959712/*!*/;
- <#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
- SET @@session.sql_mode=0/*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result'
---- mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2011-10-19 19:45:18 +0000
-+++ mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result 2012-08-24 13:29:01 +0000
-@@ -35,7 +35,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -72,7 +72,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -115,7 +115,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-@@ -229,7 +229,7 @@
- #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
- ROLLBACK/*!*/;
- # at #
--use new_test1/*!*/;
-+use `new_test1`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=#/*!*/;
-@@ -266,7 +266,7 @@
- /*!*/;
- # at #
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
--use test2/*!*/;
-+use `test2`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t2 (a INT)
- /*!*/;
-@@ -309,7 +309,7 @@
- COMMIT
- /*!*/;
- # at #
--use new_test3/*!*/;
-+use `new_test3`/*!*/;
- #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
- SET TIMESTAMP=1000000000/*!*/;
- CREATE TABLE t3 (a INT)
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
---- mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2010-01-07 15:39:11 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result 2012-08-24 13:29:01 +0000
-@@ -26,7 +26,7 @@
- BEGIN
- /*!*/;
- SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=10000/*!*/;
- insert into t2 values (@v)
- /*!*/;
-
-=== modified file 'mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result'
---- mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2011-05-12 04:56:41 +0000
-+++ mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result 2012-08-24 13:29:01 +0000
-@@ -698,7 +698,7 @@
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- /* the output must denote there is the query */;
- drop trigger trg_del_t2;
-@@ -950,7 +950,7 @@
- master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
- master-bin.000001 # Intvar # # INSERT_ID=10
- master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
--master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @b) SET `b`= @b + bug27417(2) ;file_id=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= @b + bug27417(2) ;file_id=#
- master-bin.000001 # Query # # ROLLBACK
- drop trigger trg_del_t2;
- drop table t1,t2,t3,t4,t5;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_hrtime.result'
---- mysql-test/suite/rpl/r/rpl_hrtime.result 2011-10-19 19:45:18 +0000
-+++ mysql-test/suite/rpl/r/rpl_hrtime.result 2012-08-24 13:29:01 +0000
-@@ -30,7 +30,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1293832861/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== added file 'mysql-test/suite/rpl/r/rpl_mdev382.result'
---- mysql-test/suite/rpl/r/rpl_mdev382.result 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/r/rpl_mdev382.result 2012-08-24 13:29:01 +0000
-@@ -0,0 +1,369 @@
-+include/master-slave.inc
-+[connection master]
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+Warnings:
-+Warning 1196 Some non-transactional changed tables couldn't be rolled back
-+insert into t1 values (3);
-+commit;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `test`; create table t1 (a int primary key) engine=innodb
-+master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) engine=myisam
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t2 values (1)
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
-+master-bin.000001 # Query # # SAVEPOINT "a`; create database couldbebadthingshere; savepoint `dummy"
-+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
-+master-bin.000001 # Query # # ROLLBACK TO `a``; create database couldbebadthingshere; savepoint ``dummy`
-+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `test`; insert into t1 values(10)
-+master-bin.000001 # Query # # SAVEPOINT "a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(11)
-+master-bin.000001 # Query # # SAVEPOINT "a""a"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(12)
-+master-bin.000001 # Query # # SAVEPOINT b
-+master-bin.000001 # Query # # use `test`; insert into t1 values(13)
-+master-bin.000001 # Query # # SAVEPOINT "b""b"
-+master-bin.000001 # Query # # use `test`; insert into t1 values(14)
-+master-bin.000001 # Query # # SAVEPOINT `c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(15)
-+master-bin.000001 # Query # # SAVEPOINT `c``c`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(16)
-+master-bin.000001 # Query # # SAVEPOINT d
-+master-bin.000001 # Query # # use `test`; insert into t1 values(17)
-+master-bin.000001 # Query # # SAVEPOINT `d``d`
-+master-bin.000001 # Query # # use `test`; insert into t1 values(18)
-+master-bin.000001 # Xid # # COMMIT /* XID */
-+*** Test correct USE statement in SHOW BINLOG EVENTS ***
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use "db1`; SELECT 'oops!'"; INSERT INTO t1 VALUES (2)
-+master-bin.000001 # Query # # COMMIT
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+master-bin.000001 # Query # # COMMIT
-+set sql_quote_show_create = 1;
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # CREATE DATABASE "db1`; SELECT 'oops!'"
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (1)
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (2)
-+master-bin.000001 # Query # # COMMIT
-+DROP TABLE t1;
-+use test;
-+***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+truncate `t``1`;
-+use test;
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `db1``; SELECT 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; truncate `t``1`
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
-+master-bin.000001 # Query # # COMMIT
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+`c``3` VARCHAR(7))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+BEGIN
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!")
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+COMMIT
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+truncate `t``1`
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+BEGIN
-+/*!*/;
-+use `test`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+LOAD DATA LOCAL INFILE '<name>' INTO TABLE `db1``; SELECT 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!")
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+COMMIT
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`1 b`2 c`3
-+fo\o bar |b"a'z!
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+drop table t1,t2;
-+*** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE t1
-+FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=#
-+master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b) ;file_id=#
-+master-bin.000001 # Query # # COMMIT
-+SELECT * FROM t1 ORDER BY a;
-+a b
-+1 X| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|X
-+2 A| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|A
-+DROP TABLE t1;
-+*** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+@`a``1`:=a1 @`a``2`:=a2 @`a``3`:=a3 @`a``4`:=a4 @`b```:=b @```c`:=c @```d```:=d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+show binlog events from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+master-bin.000001 # Query # # COMMIT
-+master-bin.000001 # Query # # BEGIN
-+master-bin.000001 # User var # # @`a``1`=-9223372036854775808
-+master-bin.000001 # User var # # @`a``2`=42
-+master-bin.000001 # User var # # @`a``3`=9223372036854775807
-+master-bin.000001 # User var # # @`a``4`=18446744073709551615
-+master-bin.000001 # User var # # @`b```=-1.234560123456789e125
-+master-bin.000001 # User var # # @```c`=-1234501234567890123456789012345678901234567890123456789.0123456789
-+master-bin.000001 # User var # # @```d```=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE latin1_swedish_ci
-+master-bin.000001 # Query # # use `db1``; SELECT 'oops!'`; INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+master-bin.000001 # Query # # COMMIT
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+use `db1``; SELECT 'oops!'`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+BEGIN
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+COMMIT
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+BEGIN
-+/*!*/;
-+SET @`a``1`:=-9223372036854775808/*!*/;
-+SET @`a``2`:=42/*!*/;
-+SET @`a``3`:=9223372036854775807/*!*/;
-+SET @`a``4`:=18446744073709551615/*!*/;
-+SET @`b```:=-1.2345601234568e+125/*!*/;
-+SET @```c`:=-1234501234567890123456789012345678901234567890123456789.0123456789/*!*/;
-+SET @```d```:=_latin1 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 COLLATE `latin1_swedish_ci`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98))
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+COMMIT
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+a1 a2 a3 a4 b c d
-+-9223372036854775808 42 9223372036854775807 18446744073709551615 -1.234560123456789e125 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+-9223372036854775807 4200 9223372036854775806 18446744073709551614 -6.172800617283945e124 -1234501234567890123456789012345678901234567890123456789.0123456789 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-+DROP TABLE t1;
-+*** Test correct quoting in foreign key error message ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
-+CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
-+FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
-+TRUNCATE `t``1`;
-+ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; SELECT 'oops!'`.`t``2`, CONSTRAINT `INNODB_FOREIGN_KEY_NAME` FOREIGN KEY (`c```) REFERENCES `db1``; SELECT 'oops!'`.`t``1` (`a```))
-+DROP TABLE `t``2`;
-+DROP TABLE `t``1`;
-+*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+include/stop_slave.inc
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+a`
-+1
-+2
-+5
-+set timestamp=1000000000;
-+# The table should be empty on the master.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+# The DELETE statement should be correctly quoted
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # BEGIN
-+master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; SELECT 'oops!'`.`t``1`
-+master-bin.000002 # Query # # COMMIT
-+include/start_slave.inc
-+# The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+a`
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+*** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+INSERT INTO t1 VALUES(1);
-+show binlog events in 'master-bin.000002' from <binlog_start>;
-+Log_name Pos Event_type Server_id End_log_pos Info
-+master-bin.000002 # Query # # BEGIN
-+master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES(1)
-+master-bin.000002 # Query # # COMMIT
-+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-+DELIMITER /*!*/;
-+ROLLBACK/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+SET @@session.pseudo_thread_id=999999999/*!*/;
-+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-+SET @@session.sql_mode=0/*!*/;
-+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-+/*!\C latin1 *//*!*/;
-+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-+SET @@session.lc_time_names=0/*!*/;
-+SET @@session.collation_database=DEFAULT/*!*/;
-+BEGIN
-+/*!*/;
-+use `ts``et`/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+INSERT INTO t1 VALUES(1)
-+/*!*/;
-+SET TIMESTAMP=1000000000/*!*/;
-+COMMIT
-+/*!*/;
-+DELIMITER ;
-+# End of log file
-+ROLLBACK /* added by mysqlbinlog */;
-+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-+DROP TABLE t1;
-+include/rpl_end.inc
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
---- mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2010-12-19 17:15:12 +0000
-+++ mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result 2012-08-24 13:29:01 +0000
-@@ -154,7 +154,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -176,7 +176,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -287,7 +287,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-@@ -318,7 +318,7 @@
- /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
- DELIMITER /*!*/;
- ROLLBACK/*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.pseudo_thread_id=999999999/*!*/;
- SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
-
-=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
---- mysql-test/suite/rpl/r/rpl_sp.result 2010-12-19 17:15:12 +0000
-+++ mysql-test/suite/rpl/r/rpl_sp.result 2012-08-24 13:29:01 +0000
-@@ -670,7 +670,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest1
- /*!*/;
--use mysqltest1/*!*/;
-+use `mysqltest1`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t1 (a varchar(100))
- /*!*/;
-@@ -1015,7 +1015,7 @@
- SET TIMESTAMP=t/*!*/;
- drop user "zedjzlcsjhd"@127.0.0.1
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- drop function if exists f1
- /*!*/;
-@@ -1112,7 +1112,7 @@
- SET TIMESTAMP=t/*!*/;
- create database mysqltest2
- /*!*/;
--use mysqltest2/*!*/;
-+use `mysqltest2`/*!*/;
- SET TIMESTAMP=t/*!*/;
- create table t ( t integer )
- /*!*/;
-@@ -1139,7 +1139,7 @@
- SET TIMESTAMP=t/*!*/;
- BEGIN
- /*!*/;
--use mysqltest/*!*/;
-+use `mysqltest`/*!*/;
- SET TIMESTAMP=t/*!*/;
- SELECT `mysqltest2`.`f1`()
- /*!*/;
-@@ -1152,14 +1152,14 @@
- SET TIMESTAMP=t/*!*/;
- drop database mysqltest2
- /*!*/;
--use test/*!*/;
-+use `test`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`()
- begin
- select 1;
- end
- /*!*/;
--use mysql/*!*/;
-+use `mysql`/*!*/;
- SET TIMESTAMP=t/*!*/;
- CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`( a int)
- `label`:
-
-=== added file 'mysql-test/suite/rpl/t/rpl_mdev382.test'
---- mysql-test/suite/rpl/t/rpl_mdev382.test 1970-01-01 00:00:00 +0000
-+++ mysql-test/suite/rpl/t/rpl_mdev382.test 2012-08-24 13:29:01 +0000
-@@ -0,0 +1,265 @@
-+--source include/have_innodb.inc
-+--source include/have_binlog_format_statement.inc
-+--source include/master-slave.inc
-+
-+# MDEV-382: multiple SQL injections in replication code.
-+
-+# Test previous SQL injection attack against binlog for SAVEPOINT statement.
-+# The test would cause syntax error on slave due to improper quoting of
-+# the savepoint name.
-+connection master;
-+create table t1 (a int primary key) engine=innodb;
-+create table t2 (a int primary key) engine=myisam;
-+
-+begin;
-+insert into t1 values (1);
-+SET sql_mode = 'ANSI_QUOTES';
-+savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (2);
-+insert into t2 values (1);
-+SET sql_mode = '';
-+rollback to savepoint `a``; create database couldbebadthingshere; savepoint ``dummy`;
-+insert into t1 values (3);
-+commit;
-+
-+--source include/show_binlog_events.inc
-+
-+# This failed due to syntax error in query when the bug was not fixed.
-+sync_slave_with_master;
-+connection slave;
-+
-+# Test some more combinations of ANSI_QUOTES and sql_quote_show_create
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+BEGIN;
-+insert into t1 values(10);
-+set sql_mode = 'ANSI_QUOTES';
-+set sql_quote_show_create = 1;
-+savepoint a;
-+insert into t1 values(11);
-+savepoint "a""a";
-+insert into t1 values(12);
-+set sql_quote_show_create = 0;
-+savepoint b;
-+insert into t1 values(13);
-+savepoint "b""b";
-+insert into t1 values(14);
-+set sql_mode = '';
-+set sql_quote_show_create = 1;
-+savepoint c;
-+insert into t1 values(15);
-+savepoint `c``c`;
-+insert into t1 values(16);
-+set sql_quote_show_create = 0;
-+savepoint d;
-+insert into t1 values(17);
-+savepoint `d``d`;
-+insert into t1 values(18);
-+COMMIT;
-+set sql_quote_show_create = 1;
-+
-+--source include/show_binlog_events.inc
-+
-+--echo *** Test correct USE statement in SHOW BINLOG EVENTS ***
-+connection master;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set sql_mode = 'ANSI_QUOTES';
-+CREATE DATABASE "db1`; SELECT 'oops!'";
-+use "db1`; SELECT 'oops!'";
-+CREATE TABLE t1 (a INT PRIMARY KEY) engine=MyISAM;
-+INSERT INTO t1 VALUES (1);
-+set sql_mode = '';
-+INSERT INTO t1 VALUES (2);
-+set sql_mode = 'ANSI_QUOTES';
-+--source include/show_binlog_events.inc
-+set sql_mode = '';
-+set sql_quote_show_create = 0;
-+--source include/show_binlog_events.inc
-+set sql_quote_show_create = 1;
-+--source include/show_binlog_events.inc
-+DROP TABLE t1;
-+
-+use test;
-+
-+--echo ***Test LOAD DATA INFILE with various identifiers that need correct quoting ***
-+
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/f'le.txt
-+--write_file $load_file
-+'fo\\o','bar'
-+EOF
-+
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+set timestamp=1000000000;
-+CREATE TABLE `t``1` (`a``1` VARCHAR(4) PRIMARY KEY, `b``2` VARCHAR(3),
-+ `c``3` VARCHAR(7));
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt' INTO TABLE `t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, @`b```) SET `b``2` = @`b```, `c``3` = concat('|', "b""a'z", "!");
-+
-+SELECT * FROM `t``1`;
-+# Also test when code prefixes table name with database.
-+truncate `t``1`;
-+use test;
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/f''le.txt'
-+ INTO TABLE `db1``; SELECT 'oops!'`.`t``1`
-+ FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' ENCLOSED BY ''''
-+ LINES TERMINATED BY '\\n'
-+ (`a``1`, `b``2`) SET `c``3` = concat('|', "b""a'z", "!");
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /LOCAL INFILE '.*SQL_LOAD.*' INTO/LOCAL INFILE '<name>' INTO/
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+connection master;
-+
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+--remove_file $load_file
-+
-+connection master;
-+drop table t1,t2;
-+
-+
-+--echo *** Test truncation of long SET expression in LOAD DATA ***
-+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(1000));
-+--let $load_file= $MYSQLTEST_VARDIR/tmp/file.txt
-+--write_file $load_file
-+1,X
-+2,A
-+EOF
-+
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+# The bug was that the SET expression was truncated to 256 bytes, so test with
-+# an expression longer than that.
-+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-+eval LOAD DATA INFILE '$load_file' INTO TABLE t1
-+ FIELDS TERMINATED BY ','
-+ (a, @b) SET b = CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b);
-+
-+SELECT * FROM t1 ORDER BY a;
-+--source include/show_binlog_events.inc
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM t1 ORDER BY a;
-+
-+connection master;
-+--remove_file $load_file
-+DROP TABLE t1;
-+
-+
-+--echo *** Test user variables whose names require correct quoting ***
-+use `db1``; SELECT 'oops!'`;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+CREATE TABLE t1 (a1 BIGINT PRIMARY KEY, a2 BIGINT, a3 BIGINT, a4 BIGINT UNSIGNED, b DOUBLE, c DECIMAL(65,10), d VARCHAR(100));
-+INSERT INTO t1 VALUES (-9223372036854775808,42,9223372036854775807,18446744073709551615,-1234560123456789e110, -1234501234567890123456789012345678901234567890123456789.0123456789, REPEAT("x", 100));
-+SELECT @`a``1`:=a1, @`a``2`:=a2, @`a``3`:=a3, @`a``4`:=a4, @`b```:=b, @```c`:=c, @```d```:=d FROM t1;
-+INSERT INTO t1 VALUES (@`a``1`+1, @`a``2`*100, @`a``3`-1, @`a``4`-1, @`b```/2, @```c`, substr(@```d```, 2, 98));
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+
-+--source include/show_binlog_events.inc
-+
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001
-+
-+sync_slave_with_master;
-+connection slave;
-+SELECT * FROM `db1``; SELECT 'oops!'`.t1 ORDER BY a1;
-+
-+connection master;
-+DROP TABLE t1;
-+
-+--echo *** Test correct quoting in foreign key error message ***
-+use `db1``; SELECT 'oops!'`;
-+CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
-+CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
-+ FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
-+--replace_regex /t@[0-9]+_ibfk_[0-9]+/INNODB_FOREIGN_KEY_NAME/
-+--error ER_TRUNCATE_ILLEGAL_FK
-+TRUNCATE `t``1`;
-+DROP TABLE `t``2`;
-+DROP TABLE `t``1`;
-+
-+
-+--echo *** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
-+
-+# Let's keep the slave stopped during master restart, to avoid any potential
-+# races between slave reconnect and master restart.
-+connection slave;
-+--source include/stop_slave.inc
-+
-+connection master;
-+CREATE TABLE `db1``; SELECT 'oops!'`.`t``1` (`a``` INT PRIMARY KEY) ENGINE=heap;
-+INSERT INTO `db1``; SELECT 'oops!'`.`t``1` VALUES (1), (2), (5);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1` ORDER BY 1;
-+
-+# Restart the master mysqld.
-+# This will cause an implicit truncation of the memory-based table, which will
-+# cause logging of an explicit DELETE FROM to binlog.
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+wait-rpl_mdev382.test
-+EOF
-+
-+--shutdown_server 30
-+
-+--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-+restart-rpl_mdev382.test
-+EOF
-+
-+connection default;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+# rpl_end.inc needs to use the connection server_1
-+connection server_1;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+connection master;
-+--enable_reconnect
-+--source include/wait_until_connected_again.inc
-+set timestamp=1000000000;
-+
-+--echo # The table should be empty on the master.
-+let $binlog_file= master-bin.000002;
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+--echo # The DELETE statement should be correctly quoted
-+--source include/show_binlog_events.inc
-+
-+connection slave;
-+--source include/start_slave.inc
-+
-+connection master;
-+sync_slave_with_master;
-+connection slave;
-+--echo # The table should be empty on the slave also.
-+SELECT * FROM `db1``; SELECT 'oops!'`.`t``1`;
-+
-+connection master;
-+DROP TABLE `db1``; SELECT 'oops!'`.`t``1`;
-+sync_slave_with_master;
-+
-+
-+connection master;
-+use test;
-+DROP DATABASE `db1``; SELECT 'oops!'`;
-+
-+--echo *** Test correct quoting of mysqlbinlog --rewrite-db option ***
-+CREATE TABLE t1 (a INT PRIMARY KEY);
-+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-+INSERT INTO t1 VALUES(1);
-+--source include/show_binlog_events.inc
-+let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1);
-+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 --rewrite-db='test->ts`et' $MYSQLD_DATADIR/master-bin.000002
-+DROP TABLE t1;
-+
-+--source include/rpl_end.inc
-
-=== modified file 'mysys/mf_iocache2.c'
---- mysys/mf_iocache2.c 2012-08-09 15:22:00 +0000
-+++ mysys/mf_iocache2.c 2012-08-24 13:29:01 +0000
-@@ -287,6 +287,40 @@
- }
-
-
-+size_t
-+my_b_write_backtick_quote(IO_CACHE *info, const char *str, size_t len)
-+{
-+ const uchar *start;
-+ const uchar *p= (const uchar *)str;
-+ const uchar *end= p + len;
-+ size_t count;
-+ size_t total= 0;
-+
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ for (;;)
-+ {
-+ start= p;
-+ while (p < end && *p != '`')
-+ ++p;
-+ count= p - start;
-+ if (count && my_b_write(info, start, count))
-+ return (size_t)-1;
-+ total+= count;
-+ if (p >= end)
-+ break;
-+ if (my_b_write(info, (uchar *)"``", 2))
-+ return (size_t)-1;
-+ total+= 2;
-+ ++p;
-+ }
-+ if (my_b_write(info, (uchar *)"`", 1))
-+ return (size_t)-1;
-+ ++total;
-+ return total;
-+}
-+
- /*
- Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
- Used for logging in MySQL
-@@ -311,6 +345,7 @@
- uint minimum_width_sign;
- uint precision; /* as yet unimplemented for anything but %b */
- my_bool is_zero_padded;
-+ my_bool backtick_quoting;
-
- /*
- Store the location of the beginning of a format directive, for the
-@@ -345,6 +380,7 @@
- fmt++;
-
- is_zero_padded= FALSE;
-+ backtick_quoting= FALSE;
- minimum_width_sign= 1;
- minimum_width= 0;
- precision= 0;
-@@ -357,6 +393,8 @@
- minimum_width_sign= -1; fmt++; goto process_flags;
- case '0':
- is_zero_padded= TRUE; fmt++; goto process_flags;
-+ case '`':
-+ backtick_quoting= TRUE; fmt++; goto process_flags;
- case '#':
- /** @todo Implement "#" conversion flag. */ fmt++; goto process_flags;
- case ' ':
-@@ -400,9 +438,19 @@
- reg2 char *par = va_arg(args, char *);
- size_t length2 = strlen(par);
- /* TODO: implement precision */
-- out_length+= length2;
-- if (my_b_write(info, (uchar*) par, length2))
-- goto err;
-+ if (backtick_quoting)
-+ {
-+ size_t total= my_b_write_backtick_quote(info, (uchar *) par, length2);
-+ if (total == (size_t)-1)
-+ goto err;
-+ out_length+= total;
-+ }
-+ else
-+ {
-+ out_length+= length2;
-+ if (my_b_write(info, (uchar*) par, length2))
-+ goto err;
-+ }
- }
- else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
- {
-
-=== modified file 'sql/ha_ndbcluster_binlog.cc'
---- sql/ha_ndbcluster_binlog.cc 2012-01-13 14:50:02 +0000
-+++ sql/ha_ndbcluster_binlog.cc 2012-08-24 13:29:01 +0000
-@@ -1295,7 +1295,9 @@
- DBUG_RETURN(0);
- }
-
-- char tmp_buf2[FN_REFLEN];
-+ char tmp_buf2_mem[FN_REFLEN];
-+ String tmp_buf2(tmp_buf2_mem, sizeof(tmp_buf2_mem), system_charset_info);
-+ tmp_buf2.length(0);
- const char *type_str;
- switch (type)
- {
-@@ -1304,17 +1306,24 @@
- if (thd->lex->sql_command == SQLCOM_DROP_DB)
- DBUG_RETURN(0);
- /* redo the drop table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "drop table `",
-- table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("drop table "));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "drop table";
- break;
- case SOT_RENAME_TABLE:
- /* redo the rename table query as is may contain several tables */
-- query= tmp_buf2;
-- query_length= (uint) (strxmov(tmp_buf2, "rename table `",
-- db, ".", table_name, "` to `",
-- new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
-+ tmp_buf2.append(STRING_WITH_LEN("rename table "));
-+ append_identifier(thd, &tmp_buf2, db, strlen(db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, table_name, strlen(table_name));
-+ tmp_buf2.append(STRING_WITH_LEN(" to "));
-+ append_identifier(thd, &tmp_buf2, new_db, strlen(new_db));
-+ tmp_buf2.append(STRING_WITH_LEN("."));
-+ append_identifier(thd, &tmp_buf2, new_table_name, strlen(new_table_name));
-+ query= tmp_buf2.c_ptr_safe();
-+ query_length= tmp_buf2.length();
- type_str= "rename table";
- break;
- case SOT_CREATE_TABLE:
-
-=== modified file 'sql/item.cc'
---- sql/item.cc 2012-08-09 15:22:00 +0000
-+++ sql/item.cc 2012-08-24 13:29:01 +0000
-@@ -992,15 +992,31 @@
- if (!my_charset_same(cs, system_charset_info))
- {
- size_t res_length;
-- name= sql_strmake_with_convert(str, name_length= length, cs,
-+ name= sql_strmake_with_convert(str, length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
-+ name_length= res_length;
- }
- else
- name= sql_strmake(str, (name_length= min(length,MAX_ALIAS_NAME)));
- }
-
-
-+void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs)
-+{
-+ if (!my_charset_same(cs, system_charset_info))
-+ {
-+ size_t res_length;
-+ name= sql_strmake_with_convert(str, length, cs,
-+ UINT_MAX, system_charset_info,
-+ &res_length);
-+ name_length= res_length;
-+ }
-+ else
-+ name= sql_strmake(str, (name_length= length));
-+}
-+
-+
- void Item::set_name_for_rollback(THD *thd, const char *str, uint length,
- CHARSET_INFO *cs)
- {
-
-=== modified file 'sql/item.h'
---- sql/item.h 2012-06-06 19:26:40 +0000
-+++ sql/item.h 2012-08-24 13:29:01 +0000
-@@ -656,6 +656,7 @@
- #endif
- } /*lint -e1509 */
- void set_name(const char *str, uint length, CHARSET_INFO *cs);
-+ void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs);
- void set_name_for_rollback(THD *thd, const char *str, uint length,
- CHARSET_INFO *cs);
- void rename(char *new_name);
-
-=== modified file 'sql/item_func.cc'
---- sql/item_func.cc 2012-06-20 11:01:28 +0000
-+++ sql/item_func.cc 2012-08-24 13:29:01 +0000
-@@ -5443,10 +5443,10 @@
- }
-
-
--void Item_user_var_as_out_param::print(String *str, enum_query_type query_type)
-+void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
- {
- str->append('@');
-- str->append(name.str,name.length);
-+ append_identifier(thd, str, name.str, name.length);
- }
-
-
-
-=== modified file 'sql/item_func.h'
---- sql/item_func.h 2012-06-15 07:01:20 +0000
-+++ sql/item_func.h 2012-08-24 13:29:01 +0000
-@@ -1670,7 +1670,7 @@
- my_decimal *val_decimal(my_decimal *decimal_buffer);
- /* fix_fields() binds variable name with its entry structure */
- bool fix_fields(THD *thd, Item **ref);
-- virtual void print(String *str, enum_query_type query_type);
-+ void print_for_load(THD *thd, String *str);
- void set_null_value(CHARSET_INFO* cs);
- void set_value(const char *str, uint length, CHARSET_INFO* cs);
- };
-
-=== modified file 'sql/log.cc'
---- sql/log.cc 2012-08-09 15:22:00 +0000
-+++ sql/log.cc 2012-08-24 13:29:01 +0000
-@@ -52,6 +52,7 @@
- #include "sql_plugin.h"
- #include "rpl_handler.h"
- #include "debug_sync.h"
-+#include "sql_show.h"
-
- /* max size of the log message */
- #define MAX_LOG_BUFFER_SIZE 1024
-@@ -2073,9 +2074,8 @@
-
- String log_query;
- if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-@@ -2097,9 +2097,8 @@
- {
- String log_query;
- if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
-- log_query.append("`") ||
-- log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
-- log_query.append("`"))
-+ append_identifier(thd, &log_query,
-+ thd->lex->ident.str, thd->lex->ident.length))
- DBUG_RETURN(1);
- int errcode= query_error_code(thd, thd->killed == NOT_KILLED);
- Query_log_event qinfo(thd, log_query.ptr(), log_query.length(),
-
-=== modified file 'sql/log_event.cc'
---- sql/log_event.cc 2012-08-22 15:03:31 +0000
-+++ sql/log_event.cc 2012-08-24 13:29:01 +0000
-@@ -46,6 +46,7 @@
- #include "rpl_record.h"
- #include "transaction.h"
- #include <my_dir.h>
-+#include "sql_show.h"
-
- #endif /* MYSQL_CLIENT */
-
-@@ -471,29 +472,28 @@
- pretty_print_str()
- */
-
--static char *pretty_print_str(char *packet, const char *str, int len)
-+static void
-+pretty_print_str(String *packet, const char *str, int len)
- {
- const char *end= str + len;
-- char *pos= packet;
-- *pos++= '\'';
-+ packet->append(STRING_WITH_LEN("'"));
- while (str < end)
- {
- char c;
- switch ((c=*str++)) {
-- case '\n': *pos++= '\\'; *pos++= 'n'; break;
-- case '\r': *pos++= '\\'; *pos++= 'r'; break;
-- case '\\': *pos++= '\\'; *pos++= '\\'; break;
-- case '\b': *pos++= '\\'; *pos++= 'b'; break;
-- case '\t': *pos++= '\\'; *pos++= 't'; break;
-- case '\'': *pos++= '\\'; *pos++= '\''; break;
-- case 0 : *pos++= '\\'; *pos++= '0'; break;
-+ case '\n': packet->append(STRING_WITH_LEN("\\n")); break;
-+ case '\r': packet->append(STRING_WITH_LEN("\\r")); break;
-+ case '\\': packet->append(STRING_WITH_LEN("\\\\")); break;
-+ case '\b': packet->append(STRING_WITH_LEN("\\b")); break;
-+ case '\t': packet->append(STRING_WITH_LEN("\\t")); break;
-+ case '\'': packet->append(STRING_WITH_LEN("\\'")); break;
-+ case 0 : packet->append(STRING_WITH_LEN("\\0")); break;
- default:
-- *pos++= c;
-+ packet->append(&c, 1);
- break;
- }
- }
-- *pos++= '\'';
-- return pos;
-+ packet->append(STRING_WITH_LEN("'"));
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -926,7 +926,7 @@
- Log_event::pack_info()
- */
-
--void Log_event::pack_info(Protocol *protocol)
-+void Log_event::pack_info(THD *thd, Protocol *protocol)
- {
- protocol->store("", &my_charset_bin);
- }
-@@ -935,7 +935,8 @@
- /**
- Only called by SHOW BINLOG EVENTS
- */
--int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos)
-+int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos)
- {
- const char *p= strrchr(log_name, FN_LIBCHAR);
- const char *event_type;
-@@ -949,7 +950,7 @@
- protocol->store(event_type, strlen(event_type), &my_charset_bin);
- protocol->store((uint32) server_id);
- protocol->store((ulonglong) log_pos);
-- pack_info(protocol);
-+ pack_info(thd, protocol);
- return protocol->write();
- }
- #endif /* HAVE_REPLICATION */
-@@ -2448,27 +2449,22 @@
- show the catalog ??
- */
-
--void Query_log_event::pack_info(Protocol *protocol)
-+void Query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- // TODO: show the catalog ??
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len);
- if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
- && db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf.append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, &buf, db, db_len);
-+ buf.append("; ");
- }
- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf);
-+ buf.append(query, q_len);
-+ protocol->store(&buf);
- }
- #endif
-
-@@ -3334,11 +3330,17 @@
- }
- else if (db)
- {
-+ /* Room for expand ` to `` + initial/final ` + \0 */
-+ char buf[FN_REFLEN*2+3];
-+
- different_db= memcmp(print_event_info->db, db, db_len + 1);
- if (different_db)
- memcpy(print_event_info->db, db, db_len + 1);
- if (db[0] && different_db)
-- my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
-+ {
-+ my_snprintf(buf, sizeof(buf), "%`s", db);
-+ my_b_printf(file, "use %s%s\n", buf, print_event_info->delimiter);
-+ }
- }
-
- end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
-@@ -4003,7 +4005,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Start_log_event_v3::pack_info(Protocol *protocol)
-+void Start_log_event_v3::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
- pos= strmov(buf, "Server ver: ");
-@@ -4779,131 +4781,113 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--uint Load_log_event::get_query_buffer_length()
--{
-- return
-- 5 + db_len + 3 + // "use DB; "
-- 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
-- 11 + // "CONCURRENT "
-- 7 + // LOCAL
-- 9 + // " REPLACE or IGNORE "
-- 13 + table_name_len*2 + // "INTO TABLE `table`"
-- 21 + sql_ex.field_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
-- 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
-- 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
-- 21 + sql_ex.line_term_len*4 + 2 + // " LINES TERMINATED BY 'str'"
-- 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
-- 15 + 22 + // " IGNORE xxx LINES"
-- 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
--}
--
--
--void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
-- char **end, char **fn_start, char **fn_end)
--{
-- char *pos= buf;
--
-+void Load_log_event::print_query(THD *thd, bool need_db, const char *cs,
-+ String *buf, my_off_t *fn_start,
-+ my_off_t *fn_end, const char *qualify_db)
-+{
- if (need_db && db && db_len)
- {
-- pos= strmov(pos, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-+ buf->append(STRING_WITH_LEN("use "));
-+ append_identifier(thd, buf, db, db_len);
-+ buf->append(STRING_WITH_LEN("; "));
- }
-
-- pos= strmov(pos, "LOAD DATA ");
-+ buf->append(STRING_WITH_LEN("LOAD DATA "));
-
- if (is_concurrent)
-- pos= strmov(pos, "CONCURRENT ");
-+ buf->append(STRING_WITH_LEN("CONCURRENT "));
-
- if (fn_start)
-- *fn_start= pos;
-+ *fn_start= buf->length();
-
- if (check_fname_outside_temp_buf())
-- pos= strmov(pos, "LOCAL ");
-- pos= strmov(pos, "INFILE '");
-- memcpy(pos, fname, fname_len);
-- pos= strmov(pos+fname_len, "' ");
-+ buf->append(STRING_WITH_LEN("LOCAL "));
-+ buf->append(STRING_WITH_LEN("INFILE '"));
-+ buf->append_for_single_quote(fname, fname_len);
-+ buf->append(STRING_WITH_LEN("' "));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
-- pos= strmov(pos, "REPLACE ");
-+ buf->append(STRING_WITH_LEN("REPLACE "));
- else if (sql_ex.opt_flags & IGNORE_FLAG)
-- pos= strmov(pos, "IGNORE ");
-+ buf->append(STRING_WITH_LEN("IGNORE "));
-
-- pos= strmov(pos ,"INTO");
-+ buf->append(STRING_WITH_LEN("INTO"));
-
- if (fn_end)
-- *fn_end= pos;
-+ *fn_end= buf->length();
-
-- pos= strmov(pos ," TABLE `");
-- memcpy(pos, table_name, table_name_len);
-- pos+= table_name_len;
-+ buf->append(STRING_WITH_LEN(" TABLE "));
-+ if (qualify_db)
-+ {
-+ append_identifier(thd, buf, qualify_db, strlen(qualify_db));
-+ buf->append(STRING_WITH_LEN("."));
-+ }
-+ append_identifier(thd, buf, table_name, table_name_len);
-
- if (cs != NULL)
- {
-- pos= strmov(pos ,"` CHARACTER SET ");
-- pos= strmov(pos , cs);
-+ buf->append(STRING_WITH_LEN(" CHARACTER SET "));
-+ buf->append(cs, strlen(cs));
- }
-- else
-- pos= strmov(pos, "`");
-
- /* We have to create all optional fields as the default is not empty */
-- pos= strmov(pos, " FIELDS TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len);
-+ buf->append(STRING_WITH_LEN(" FIELDS TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.field_term, sql_ex.field_term_len);
- if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
-- pos= strmov(pos, " OPTIONALLY ");
-- pos= strmov(pos, " ENCLOSED BY ");
-- pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len);
--
-- pos= strmov(pos, " ESCAPED BY ");
-- pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len);
--
-- pos= strmov(pos, " LINES TERMINATED BY ");
-- pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len);
-+ buf->append(STRING_WITH_LEN(" OPTIONALLY "));
-+ buf->append(STRING_WITH_LEN(" ENCLOSED BY "));
-+ pretty_print_str(buf, sql_ex.enclosed, sql_ex.enclosed_len);
-+
-+ buf->append(STRING_WITH_LEN(" ESCAPED BY "));
-+ pretty_print_str(buf, sql_ex.escaped, sql_ex.escaped_len);
-+
-+ buf->append(STRING_WITH_LEN(" LINES TERMINATED BY "));
-+ pretty_print_str(buf, sql_ex.line_term, sql_ex.line_term_len);
- if (sql_ex.line_start_len)
- {
-- pos= strmov(pos, " STARTING BY ");
-- pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len);
-+ buf->append(STRING_WITH_LEN(" STARTING BY "));
-+ pretty_print_str(buf, sql_ex.line_start, sql_ex.line_start_len);
- }
-
- if ((long) skip_lines > 0)
- {
-- pos= strmov(pos, " IGNORE ");
-- pos= longlong10_to_str((longlong) skip_lines, pos, 10);
-- pos= strmov(pos," LINES ");
-+ buf->append(STRING_WITH_LEN(" IGNORE "));
-+ buf->append_ulonglong(skip_lines);
-+ buf->append(STRING_WITH_LEN(" LINES "));
- }
-
- if (num_fields)
- {
- uint i;
- const char *field= fields;
-- pos= strmov(pos, " (");
-+ buf->append(STRING_WITH_LEN(" ("));
- for (i = 0; i < num_fields; i++)
- {
- if (i)
- {
-- *pos++= ' ';
-- *pos++= ',';
-+ /*
-+ Yes, the space and comma is reversed here. But this is mostly dead
-+ code, at most used when reading really old binlogs from old servers,
-+ so better just leave it as is...
-+ */
-+ buf->append(STRING_WITH_LEN(" ,"));
- }
-- memcpy(pos, field, field_lens[i]);
-- pos+= field_lens[i];
-+ append_identifier(thd, buf, field, field_lens[i]);
- field+= field_lens[i] + 1;
- }
-- *pos++= ')';
-+ buf->append(STRING_WITH_LEN(")"));
- }
--
-- *end= pos;
- }
-
-
--void Load_log_event::pack_info(Protocol *protocol)
-+void Load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *end;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
-
-- if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME))))
-- return;
-- print_query(TRUE, NULL, buf, &end, 0, 0);
-- protocol->store(buf, end-buf, &my_charset_bin);
-- my_free(buf);
-+ query_str.length(0);
-+ print_query(thd, TRUE, NULL, &query_str, 0, 0, NULL);
-+ protocol->store(query_str.ptr(), query_str.length(), &my_charset_bin);
- }
- #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
-
-@@ -5361,16 +5345,20 @@
- else
- {
- char llbuff[22];
-- char *end;
- enum enum_duplicates handle_dup;
- bool ignore= 0;
-+ char query_buffer[1024];
-+ String query_str(query_buffer, sizeof(query_buffer), system_charset_info);
- char *load_data_query;
-
-+ query_str.length(0);
- /*
- Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
- and written to slave's binlog if binlogging is on.
- */
-- if (!(load_data_query= (char *)thd->alloc(get_query_buffer_length() + 1)))
-+ print_query(thd, FALSE, NULL, &query_str, NULL, NULL, NULL);
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(),
-+ query_str.length())))
- {
- /*
- This will set thd->fatal_error in case of OOM. So we surely will notice
-@@ -5379,9 +5367,7 @@
- goto error;
- }
-
-- print_query(FALSE, NULL, load_data_query, &end, NULL, NULL);
-- *end= 0;
-- thd->set_query(load_data_query, (uint) (end - load_data_query));
-+ thd->set_query(load_data_query, (uint) (query_str.length()));
-
- if (sql_ex.opt_flags & REPLACE_FLAG)
- handle_dup= DUP_REPLACE;
-@@ -5559,7 +5545,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rotate_log_event::pack_info(Protocol *protocol)
-+void Rotate_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], buf[22];
- String tmp(buf1, sizeof(buf1), log_cs);
-@@ -5777,7 +5763,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Intvar_log_event::pack_info(Protocol *protocol)
-+void Intvar_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256], *pos;
- pos= strmake(buf, get_var_type_name(), sizeof(buf)-23);
-@@ -5931,7 +5917,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rand_log_event::pack_info(Protocol *protocol)
-+void Rand_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf1[256], *pos;
- pos= strmov(buf1,"rand_seed1=");
-@@ -6056,7 +6042,7 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Xid_log_event::pack_info(Protocol *protocol)
-+void Xid_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[128], *pos;
- pos= strmov(buf, "COMMIT /* xid=");
-@@ -6153,84 +6139,117 @@
- **************************************************************************/
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void User_var_log_event::pack_info(Protocol* protocol)
-+static bool
-+user_var_append_name_part(THD *thd, String *buf,
-+ const char *name, size_t name_len)
- {
-- char *buf= 0;
-- uint val_offset= 4 + name_len;
-- uint event_len= val_offset;
-+ return buf->append("@") ||
-+ append_identifier(thd, buf, name, name_len) ||
-+ buf->append("=");
-+}
-
-+void User_var_log_event::pack_info(THD *thd, Protocol* protocol)
-+{
- if (is_null)
- {
-- if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME))))
-+ char buf_mem[FN_REFLEN+7];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("NULL"))
- return;
-- strmov(buf + val_offset, "NULL");
-- event_len= val_offset + 4;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
- else
- {
- switch (type) {
- case REAL_RESULT:
-+ {
- double real_val;
-+ char buf2[MY_GCVT_MAX_FIELD_WIDTH+1];
-+ char buf_mem[FN_REFLEN + MY_GCVT_MAX_FIELD_WIDTH + 1];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- float8get(real_val, val);
-- if (!(buf= (char*) my_malloc(val_offset + MY_GCVT_MAX_FIELD_WIDTH + 1,
-- MYF(MY_WME))))
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2, my_gcvt(real_val, MY_GCVT_ARG_DOUBLE,
-+ MY_GCVT_MAX_FIELD_WIDTH, buf2, NULL)))
- return;
-- event_len+= my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
-- buf + val_offset, NULL);
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case INT_RESULT:
-- if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
-+ {
-+ char buf2[22];
-+ char buf_mem[FN_REFLEN + 22];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.length(0);
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2,
-+ longlong10_to_str(uint8korr(val), buf2,
-+ ((flags & User_var_log_event::UNSIGNED_F) ? 10 : -10))-buf2))
- return;
-- event_len= longlong10_to_str(uint8korr(val), buf + val_offset,
-- ((flags & User_var_log_event::UNSIGNED_F) ?
-- 10 : -10))-buf;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case DECIMAL_RESULT:
- {
-- if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH,
-- MYF(MY_WME))))
-- return;
-- String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin);
-+ char buf_mem[FN_REFLEN + DECIMAL_MAX_STR_LENGTH];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ char buf2[DECIMAL_MAX_STR_LENGTH+1];
-+ String str(buf2, sizeof(buf2), &my_charset_bin);
- my_decimal dec;
-+ buf.length(0);
- binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0],
- val[1]);
- my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str);
-- event_len= str.length() + val_offset;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append(buf2))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-- }
-+ }
- case STRING_RESULT:
-+ {
- /* 15 is for 'COLLATE' and other chars */
-- buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
-- MYF(MY_WME));
-+ char buf_mem[FN_REFLEN + 512 + 1 + 2*MY_CS_NAME_SIZE+15];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
- CHARSET_INFO *cs;
-- if (!buf)
-- return;
-+ buf.length(0);
- if (!(cs= get_charset(charset_number, MYF(0))))
- {
-- strmov(buf+val_offset, "???");
-- event_len+= 3;
-+ if (buf.append("???"))
-+ return;
- }
- else
- {
-- char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
-- p= str_to_hex(p, val, val_len);
-- p= strxmov(p, " COLLATE ", cs->name, NullS);
-- event_len= p-buf;
-+ size_t old_len;
-+ char *beg, *end;
-+ if (user_var_append_name_part(thd, &buf, name, name_len) ||
-+ buf.append("_") ||
-+ buf.append(cs->csname) ||
-+ buf.append(" "))
-+ return;
-+ old_len= buf.length();
-+ if (buf.reserve(old_len + val_len*2 + 2 + sizeof(" COLLATE ") +
-+ MY_CS_NAME_SIZE))
-+ return;
-+ beg= const_cast<char *>(buf.ptr()) + old_len;
-+ end= str_to_hex(beg, val, val_len);
-+ buf.length(old_len + (end - beg));
-+ if (buf.append(" COLLATE ") ||
-+ buf.append(cs->name))
-+ return;
- }
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- break;
-+ }
- case ROW_RESULT:
- default:
- DBUG_ASSERT(0);
- return;
- }
- }
-- buf[0]= '@';
-- buf[1]= '`';
-- memcpy(buf+2, name, name_len);
-- buf[2+name_len]= '`';
-- buf[3+name_len]= '=';
-- protocol->store(buf, event_len, &my_charset_bin);
-- my_free(buf);
- }
- #endif /* !MYSQL_CLIENT */
-
-@@ -6388,9 +6407,8 @@
- my_b_printf(&cache, "\tUser_var\n");
- }
-
-- my_b_printf(&cache, "SET @`");
-- my_b_write(&cache, (uchar*) name, (uint) (name_len));
-- my_b_printf(&cache, "`");
-+ my_b_printf(&cache, "SET @");
-+ my_b_write_backtick_quote(&cache, name, name_len);
-
- if (is_null)
- {
-@@ -6613,7 +6631,7 @@
- #endif
-
- #ifndef MYSQL_CLIENT
--void Slave_log_event::pack_info(Protocol *protocol)
-+void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256+HOSTNAME_LENGTH], *pos;
- pos= strmov(buf, "host=");
-@@ -6995,7 +7013,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Create_file_log_event::pack_info(Protocol *protocol)
-+void Create_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[SAFE_NAME_LEN*2 + 30 + 21*2], *pos;
- pos= strmov(buf, "db=");
-@@ -7181,7 +7199,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Append_block_log_event::pack_info(Protocol *protocol)
-+void Append_block_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- uint length;
-@@ -7338,7 +7356,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Delete_file_log_event::pack_info(Protocol *protocol)
-+void Delete_file_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -7437,7 +7455,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_log_event::pack_info(Protocol *protocol)
-+void Execute_load_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[64];
- uint length;
-@@ -7699,27 +7717,24 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Execute_load_query_log_event::pack_info(Protocol *protocol)
-+void Execute_load_query_log_event::pack_info(THD *thd, Protocol *protocol)
- {
-- char *buf, *pos;
-- if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
-- return;
-- pos= buf;
-+ char buf_mem[1024];
-+ String buf(buf_mem, sizeof(buf_mem), system_charset_info);
-+ buf.real_alloc(9 + db_len + q_len + 10 + 21);
- if (db && db_len)
- {
-- pos= strmov(buf, "use `");
-- memcpy(pos, db, db_len);
-- pos= strmov(pos+db_len, "`; ");
-- }
-- if (query && q_len)
-- {
-- memcpy(pos, query, q_len);
-- pos+= q_len;
-- }
-- pos= strmov(pos, " ;file_id=");
-- pos= int10_to_str((long) file_id, pos, 10);
-- protocol->store(buf, pos-buf, &my_charset_bin);
-- my_free(buf);
-+ if (buf.append("use ") ||
-+ append_identifier(thd, &buf, db, db_len) ||
-+ buf.append("; "))
-+ return;
-+ }
-+ if (query && q_len && buf.append(query, q_len))
-+ return;
-+ if (buf.append(" ;file_id=") ||
-+ buf.append_ulonglong(file_id))
-+ return;
-+ protocol->store(buf.ptr(), buf.length(), &my_charset_bin);
- }
-
-
-@@ -8682,7 +8697,7 @@
- #endif
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Rows_log_event::pack_info(Protocol *protocol)
-+void Rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-@@ -8786,7 +8801,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
--void Annotate_rows_log_event::pack_info(Protocol* protocol)
-+void Annotate_rows_log_event::pack_info(THD *thd, Protocol* protocol)
- {
- if (m_query_txt && m_query_len)
- protocol->store(m_query_txt, m_query_len, &my_charset_bin);
-@@ -9530,7 +9545,7 @@
- */
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Table_map_log_event::pack_info(Protocol *protocol)
-+void Table_map_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes= my_snprintf(buf, sizeof(buf),
-@@ -9551,7 +9566,7 @@
- {
- print_header(&print_event_info->head_cache, print_event_info, TRUE);
- my_b_printf(&print_event_info->head_cache,
-- "\tTable_map: `%s`.`%s` mapped to number %lu\n",
-+ "\tTable_map: %`s.%`s mapped to number %lu\n",
- m_dbnam, m_tblnam, m_table_id);
- print_base64(&print_event_info->body_cache, print_event_info, TRUE);
- }
-@@ -10884,7 +10899,7 @@
-
-
- #ifndef MYSQL_CLIENT
--void Incident_log_event::pack_info(Protocol *protocol)
-+void Incident_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- size_t bytes;
-
-=== modified file 'sql/log_event.h'
---- sql/log_event.h 2012-08-09 15:22:00 +0000
-+++ sql/log_event.h 2012-08-24 13:29:01 +0000
-@@ -1065,14 +1065,15 @@
- */
- static void init_show_field_list(List<Item>* field_list);
- #ifdef HAVE_REPLICATION
-- int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
-+ int net_send(THD *thd, Protocol *protocol, const char* log_name,
-+ my_off_t pos);
-
- /*
- pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
- a string to display to the user, so it resembles print().
- */
-
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
-
- #endif /* HAVE_REPLICATION */
- virtual const char* get_db()
-@@ -1809,7 +1810,7 @@
- bool using_trans, bool direct, bool suppress_use, int error);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -1939,7 +1940,7 @@
-
- #ifdef MYSQL_SERVER
- Slave_log_event(THD* thd_arg, Relay_log_info* rli);
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2172,9 +2173,9 @@
- const Format_description_log_event* description_event);
-
- public:
-- uint get_query_buffer_length();
-- void print_query(bool need_db, const char *cs, char *buf, char **end,
-- char **fn_start, char **fn_end);
-+ void print_query(THD *thd, bool need_db, const char *cs, String *buf,
-+ my_off_t *fn_start, my_off_t *fn_end,
-+ const char *qualify_db);
- ulong thread_id;
- ulong slave_proxy_id;
- uint32 table_name_len;
-@@ -2235,7 +2236,7 @@
- Name_resolution_context *context);
- const char* get_db() { return db; }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2332,7 +2333,7 @@
- #ifdef MYSQL_SERVER
- Start_log_event_v3();
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- Start_log_event_v3() {}
-@@ -2496,7 +2497,7 @@
- cache_type= Log_event::EVENT_NO_CACHE;
- }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2576,7 +2577,7 @@
- cache_type= Log_event::EVENT_NO_CACHE;
- }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2625,7 +2626,7 @@
- cache_type= Log_event::EVENT_NO_CACHE;
- }
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2687,7 +2688,7 @@
- if (direct)
- cache_type= Log_event::EVENT_NO_CACHE;
- }
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
- #endif
-@@ -2825,7 +2826,7 @@
- uint ident_len_arg,
- ulonglong pos_arg, uint flags);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2886,7 +2887,7 @@
- uchar* block_arg, uint block_len_arg,
- bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -2958,7 +2959,7 @@
- Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
- uint block_len_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- virtual int get_create_or_append() const;
- #endif /* HAVE_REPLICATION */
- #else
-@@ -2999,7 +3000,7 @@
- #ifdef MYSQL_SERVER
- Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3040,7 +3041,7 @@
- #ifdef MYSQL_SERVER
- Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3136,7 +3137,7 @@
- bool using_trans, bool direct,
- bool suppress_use, int errcode);
- #ifdef HAVE_REPLICATION
-- void pack_info(Protocol* protocol);
-+ void pack_info(THD *thd, Protocol* protocol);
- #endif /* HAVE_REPLICATION */
- #else
- void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
-@@ -3222,7 +3223,7 @@
- #endif
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol*);
-+ virtual void pack_info(THD *thd, Protocol*);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3636,7 +3637,7 @@
- #endif
-
- #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -3748,7 +3749,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-@@ -4195,7 +4196,7 @@
- #endif
-
- #ifdef MYSQL_SERVER
-- void pack_info(Protocol*);
-+ void pack_info(THD *thd, Protocol*);
- #endif
-
- Incident_log_event(const char *buf, uint event_len,
-
-=== modified file 'sql/log_event_old.cc'
---- sql/log_event_old.cc 2012-06-14 18:05:31 +0000
-+++ sql/log_event_old.cc 2012-08-24 13:29:01 +0000
-@@ -1935,7 +1935,7 @@
-
-
- #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
--void Old_rows_log_event::pack_info(Protocol *protocol)
-+void Old_rows_log_event::pack_info(THD *thd, Protocol *protocol)
- {
- char buf[256];
- char const *const flagstr=
-
-=== modified file 'sql/log_event_old.h'
---- sql/log_event_old.h 2012-03-13 14:38:43 +0000
-+++ sql/log_event_old.h 2012-08-24 12:02:32 +0000
-@@ -108,7 +108,7 @@
- flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
-
- #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-- virtual void pack_info(Protocol *protocol);
-+ virtual void pack_info(THD *thd, Protocol *protocol);
- #endif
-
- #ifdef MYSQL_CLIENT
-
-=== modified file 'sql/repl_failsafe.cc'
---- sql/repl_failsafe.cc 2012-01-13 14:50:02 +0000
-+++ sql/repl_failsafe.cc 2012-08-24 13:29:01 +0000
-@@ -35,7 +35,6 @@
- #include "rpl_mi.h"
- #include "rpl_filter.h"
- #include "log_event.h"
--#include "sql_db.h" // mysql_create_db
- #include <mysql.h>
-
- #define SLAVE_LIST_CHUNK 128
-
-=== modified file 'sql/rpl_record.cc'
---- sql/rpl_record.cc 2012-03-17 08:26:58 +0000
-+++ sql/rpl_record.cc 2012-08-24 13:29:01 +0000
-@@ -314,7 +314,7 @@
- if (!pack_ptr)
- {
- rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT,
-- "Could not read field `%s` of table `%s`.`%s`",
-+ "Could not read field %`s of table %`s.%`s",
- f->field_name, table->s->db.str,
- table->s->table_name.str);
- DBUG_RETURN(ER_SLAVE_CORRUPT_EVENT);
-
-=== modified file 'sql/sql_base.cc'
---- sql/sql_base.cc 2012-08-09 15:22:00 +0000
-+++ sql/sql_base.cc 2012-08-24 13:29:01 +0000
-@@ -3887,22 +3887,22 @@
- entry->file->implicit_emptied= 0;
- if (mysql_bin_log.is_open())
- {
-- char *query, *end;
-- uint query_buf_size= 20 + share->db.length + share->table_name.length +1;
-- if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
-+ char query_buf[2*FN_REFLEN + 21];
-+ String query(query_buf, sizeof(query_buf), system_charset_info);
-+ query.length(0);
-+ if (query.ptr())
- {
- /* this DELETE FROM is needed even with row-based binlogging */
-- end = strxmov(strmov(query, "DELETE FROM `"),
-- share->db.str,"`.`",share->table_name.str,"`", NullS);
-+ query.append("DELETE FROM ");
-+ append_identifier(thd, &query, share->db.str, share->db.length);
-+ query.append(".");
-+ append_identifier(thd, &query, share->table_name.str,
-+ share->table_name.length);
- int errcode= query_error_code(thd, TRUE);
- if (thd->binlog_query(THD::STMT_QUERY_TYPE,
-- query, (ulong)(end-query),
-+ query.ptr(), query.length(),
- FALSE, FALSE, FALSE, errcode))
-- {
-- my_free(query);
- return TRUE;
-- }
-- my_free(query);
- }
- else
- {
-@@ -3912,7 +3912,7 @@
- because of MYF(MY_WME) in my_malloc() above).
- */
- sql_print_error("When opening HEAP table, could not allocate memory "
-- "to write 'DELETE FROM `%s`.`%s`' to the binary log",
-+ "to write 'DELETE FROM %`s.%`s' to the binary log",
- share->db.str, share->table_name.str);
- delete entry->triggers;
- return TRUE;
-
-=== modified file 'sql/sql_db.cc'
---- sql/sql_db.cc 2012-01-13 14:50:02 +0000
-+++ sql/sql_db.cc 2012-08-24 13:29:01 +0000
-@@ -544,7 +544,6 @@
- bool silent)
- {
- char path[FN_REFLEN+16];
-- char tmp_query[FN_REFLEN+16];
- long result= 1;
- int error= 0;
- MY_STAT stat_info;
-@@ -622,17 +621,9 @@
- char *query;
- uint query_length;
-
-- if (!thd->query()) // Only in replication
-- {
-- query= tmp_query;
-- query_length= (uint) (strxmov(tmp_query,"create database `",
-- db, "`", NullS) - tmp_query);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-
- ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB,
- query, query_length,
-@@ -885,18 +876,11 @@
- {
- const char *query;
- ulong query_length;
-- if (!thd->query())
-- {
-- /* The client used the old obsolete mysql_drop_db() call */
-- query= path;
-- query_length= (uint) (strxmov(path, "drop database `", db, "`",
-- NullS) - path);
-- }
-- else
-- {
-- query= thd->query();
-- query_length= thd->query_length();
-- }
-+
-+ query= thd->query();
-+ query_length= thd->query_length();
-+ DBUG_ASSERT(query);
-+
- if (mysql_bin_log.is_open())
- {
- int errcode= query_error_code(thd, TRUE);
-@@ -940,6 +924,7 @@
- {
- uint tbl_name_len;
- bool exists;
-+ char quoted_name[FN_REFLEN+3];
-
- // Only write drop table to the binlog for tables that no longer exist.
- if (check_if_table_exists(thd, tbl, &exists))
-@@ -950,8 +935,8 @@
- if (exists)
- continue;
-
-- /* 3 for the quotes and the comma*/
-- tbl_name_len= strlen(tbl->table_name) + 3;
-+ my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name);
-+ tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */
- if (query_pos + tbl_name_len + 1 >= query_end)
- {
- /*
-@@ -966,9 +951,7 @@
- query_pos= query_data_start;
- }
-
-- *query_pos++ = '`';
-- query_pos= strmov(query_pos,tbl->table_name);
-- *query_pos++ = '`';
-+ query_pos= strmov(query_pos, quoted_name);
- *query_pos++ = ',';
- }
-
-
-=== modified file 'sql/sql_load.cc'
---- sql/sql_load.cc 2012-04-07 13:58:46 +0000
-+++ sql/sql_load.cc 2012-08-24 13:29:01 +0000
-@@ -39,6 +39,7 @@
- #include "sp_head.h"
- #include "sql_trigger.h"
- #include "sql_derived.h"
-+#include "sql_show.h"
-
- class XML_TAG {
- public:
-@@ -675,24 +676,28 @@
- bool transactional_table,
- int errcode)
- {
-- char *load_data_query,
-- *end,
-- *fname_start,
-- *fname_end,
-- *p= NULL;
-- size_t pl= 0;
-+ char *load_data_query;
-+ my_off_t fname_start,
-+ fname_end;
- List<Item> fv;
- Item *item, *val;
- int n;
-- const char *tbl= table_name_arg;
- const char *tdb= (thd->db != NULL ? thd->db : db_arg);
-- char name_buffer[SAFE_NAME_LEN*2];
-+ const char *qualify_db= NULL;
- char command_buffer[1024];
-- String string_buf(name_buffer, sizeof(name_buffer),
-- system_charset_info);
-- String pfields(command_buffer, sizeof(command_buffer),
-+ String query_str(command_buffer, sizeof(command_buffer),
- system_charset_info);
-
-+ Load_log_event lle(thd, ex, tdb, table_name_arg, fv, is_concurrent,
-+ duplicates, ignore, transactional_table);
-+
-+ /*
-+ force in a LOCAL if there was one in the original.
-+ */
-+ if (thd->lex->local_file)
-+ lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+
-+ query_str.length(0);
- if (!thd->db || strcmp(db_arg, thd->db))
- {
- /*
-@@ -700,49 +705,35 @@
- prefix table name with database name so that it
- becomes a FQ name.
- */
-- string_buf.length(0);
-- string_buf.append(db_arg);
-- string_buf.append("`");
-- string_buf.append(".");
-- string_buf.append("`");
-- string_buf.append(table_name_arg);
-- tbl= string_buf.c_ptr_safe();
-+ qualify_db= db_arg;
- }
--
-- Load_log_event lle(thd, ex, tdb, tbl, fv, is_concurrent,
-- duplicates, ignore, transactional_table);
--
-- /*
-- force in a LOCAL if there was one in the original.
-- */
-- if (thd->lex->local_file)
-- lle.set_fname_outside_temp_buf(ex->file_name, strlen(ex->file_name));
-+ lle.print_query(thd, FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-+ &query_str, &fname_start, &fname_end, qualify_db);
-
- /*
- prepare fields-list and SET if needed; print_query won't do that for us.
- */
-- pfields.length(0);
- if (!thd->lex->field_list.is_empty())
- {
- List_iterator<Item> li(thd->lex->field_list);
-
-- pfields.append(" (");
-+ query_str.append(" (");
- n= 0;
-
- while ((item= li++))
- {
- if (n++)
-- pfields.append(", ");
-+ query_str.append(", ");
- if (item->type() == Item::FIELD_ITEM)
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
-+ else
- {
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-+ /* Actually Item_user_var_as_out_param despite claiming STRING_ITEM. */
-+ DBUG_ASSERT(item->type() == Item::STRING_ITEM);
-+ ((Item_user_var_as_out_param *)item)->print_for_load(thd, &query_str);
- }
-- else
-- item->print(&pfields, QT_ORDINARY);
- }
-- pfields.append(")");
-+ query_str.append(")");
- }
-
- if (!thd->lex->update_list.is_empty())
-@@ -750,38 +741,25 @@
- List_iterator<Item> lu(thd->lex->update_list);
- List_iterator<Item> lv(thd->lex->value_list);
-
-- pfields.append(" SET ");
-+ query_str.append(" SET ");
- n= 0;
-
- while ((item= lu++))
- {
- val= lv++;
- if (n++)
-- pfields.append(", ");
-- pfields.append("`");
-- pfields.append(item->name);
-- pfields.append("`");
-- pfields.append(val->name);
-+ query_str.append(", ");
-+ append_identifier(thd, &query_str, item->name, strlen(item->name));
-+ query_str.append(val->name);
- }
- }
-
-- p= pfields.c_ptr_safe();
-- pl= pfields.length();
--
-- if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl)))
-+ if (!(load_data_query= (char *)thd->strmake(query_str.ptr(), query_str.length())))
- return TRUE;
-
-- lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL,
-- load_data_query, &end,
-- (char **)&fname_start, (char **)&fname_end);
--
-- strcpy(end, p);
-- end += pl;
--
- Execute_load_query_log_event
-- e(thd, load_data_query, end-load_data_query,
-- (uint) ((char*) fname_start - load_data_query - 1),
-- (uint) ((char*) fname_end - load_data_query),
-+ e(thd, load_data_query, query_str.length(),
-+ (uint) (fname_start - 1), (uint) fname_end,
- (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
- (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
- transactional_table, FALSE, FALSE, errcode);
-
-=== modified file 'sql/sql_repl.cc'
---- sql/sql_repl.cc 2012-08-09 15:22:00 +0000
-+++ sql/sql_repl.cc 2012-08-24 13:29:01 +0000
-@@ -2000,7 +2000,7 @@
- description_event->checksum_alg= ev->checksum_alg;
-
- if (event_count >= limit_start &&
-- ev->net_send(protocol, linfo.log_file_name, pos))
-+ ev->net_send(thd, protocol, linfo.log_file_name, pos))
- {
- errmsg = "Net error";
- delete ev;
-
-=== modified file 'sql/sql_select.cc'
---- sql/sql_select.cc 2012-08-21 12:24:43 +0000
-+++ sql/sql_select.cc 2012-08-24 13:29:01 +0000
-@@ -16481,7 +16481,7 @@
- && !table->in_use->killed)
- {
- push_warning_printf(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, error,
-- "Got error %d when reading table `%s`.`%s`",
-+ "Got error %d when reading table %`s.%`s",
- error, table->s->db.str, table->s->table_name.str);
- sql_print_error("Got error %d when reading table '%s'",
- error, table->s->path.str);
-
-=== modified file 'sql/sql_show.cc'
---- sql/sql_show.cc 2012-08-09 15:22:00 +0000
-+++ sql/sql_show.cc 2012-08-24 13:29:01 +0000
-@@ -992,9 +992,13 @@
- packet target string
- name the identifier to be appended
- name_length length of the appending identifier
-+
-+ RETURN VALUES
-+ true Error
-+ false Ok
- */
-
--void
-+bool
- append_identifier(THD *thd, String *packet, const char *name, uint length)
- {
- const char *name_end;
-@@ -1002,10 +1006,7 @@
- int q= get_quote_char_for_identifier(thd, name, length);
-
- if (q == EOF)
-- {
-- packet->append(name, length, packet->charset());
-- return;
-- }
-+ return packet->append(name, length, packet->charset());
-
- /*
- The identifier must be quoted as it includes a quote character or
-@@ -1014,7 +1015,8 @@
-
- (void) packet->reserve(length*2 + 2);
- quote_char= (char) q;
-- packet->append(&quote_char, 1, system_charset_info);
-+ if (packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-
- for (name_end= name+length ; name < name_end ; name+= length)
- {
-@@ -1029,11 +1031,13 @@
- */
- if (!length)
- length= 1;
-- if (length == 1 && chr == (uchar) quote_char)
-- packet->append(&quote_char, 1, system_charset_info);
-- packet->append(name, length, system_charset_info);
-+ if (length == 1 && chr == (uchar) quote_char &&
-+ packet->append(&quote_char, 1, system_charset_info))
-+ return true;
-+ if (packet->append(name, length, system_charset_info))
-+ return true;
- }
-- packet->append(&quote_char, 1, system_charset_info);
-+ return packet->append(&quote_char, 1, system_charset_info);
- }
-
-
-
-=== modified file 'sql/sql_show.h'
---- sql/sql_show.h 2011-06-30 15:46:53 +0000
-+++ sql/sql_show.h 2012-08-24 13:29:01 +0000
-@@ -90,7 +90,7 @@
-
- int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);
-
--void append_identifier(THD *thd, String *packet, const char *name,
-+bool append_identifier(THD *thd, String *packet, const char *name,
- uint length);
- void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
- int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
-
-=== modified file 'sql/sql_string.cc'
---- sql/sql_string.cc 2012-04-07 13:58:46 +0000
-+++ sql/sql_string.cc 2012-08-24 13:29:01 +0000
-@@ -1121,39 +1121,47 @@
-
-
-
--
--void String::print(String *str)
-+/*
-+ Append characters to a single-quoted string '...', escaping special
-+ characters as necessary.
-+ Does not add the enclosing quotes, this is left up to caller.
-+*/
-+void String::append_for_single_quote(const char *st, uint len)
- {
-- char *st= (char*)Ptr, *end= st+str_length;
-+ const char *end= st+len;
- for (; st < end; st++)
- {
- uchar c= *st;
- switch (c)
- {
- case '\\':
-- str->append(STRING_WITH_LEN("\\\\"));
-+ append(STRING_WITH_LEN("\\\\"));
- break;
- case '\0':
-- str->append(STRING_WITH_LEN("\\0"));
-+ append(STRING_WITH_LEN("\\0"));
- break;
- case '\'':
-- str->append(STRING_WITH_LEN("\\'"));
-+ append(STRING_WITH_LEN("\\'"));
- break;
- case '\n':
-- str->append(STRING_WITH_LEN("\\n"));
-+ append(STRING_WITH_LEN("\\n"));
- break;
- case '\r':
-- str->append(STRING_WITH_LEN("\\r"));
-+ append(STRING_WITH_LEN("\\r"));
- break;
- case '\032': // Ctrl-Z
-- str->append(STRING_WITH_LEN("\\Z"));
-+ append(STRING_WITH_LEN("\\Z"));
- break;
- default:
-- str->append(c);
-+ append(c);
- }
- }
- }
-
-+void String::print(String *str)
-+{
-+ str->append_for_single_quote(Ptr, str_length);
-+}
-
- /*
- Exchange state of this object and argument.
-
-=== modified file 'sql/sql_string.h'
---- sql/sql_string.h 2012-01-13 14:50:02 +0000
-+++ sql/sql_string.h 2012-08-24 13:29:01 +0000
-@@ -459,6 +459,7 @@
- return FALSE;
- }
- void print(String *print);
-+ void append_for_single_quote(const char *st, uint len);
-
- /* Swap two string objects. Efficient way to exchange data without memcpy. */
- void swap(String &s);
-
-=== modified file 'sql/sql_table.cc'
---- sql/sql_table.cc 2012-08-15 11:37:55 +0000
-+++ sql/sql_table.cc 2012-08-24 13:29:01 +0000
-@@ -2104,6 +2104,7 @@
- {
- bool is_trans;
- char *db=table->db;
-+ size_t db_length= table->db_length;
- handlerton *table_type;
- enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN;
-
-@@ -2165,14 +2166,14 @@
- Don't write the database name if it is the current one (or if
- thd->db is NULL).
- */
-- built_ptr_query->append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_ptr_query->append(db);
-- built_ptr_query->append("`.`");
-+ append_identifier(thd, built_ptr_query, db, db_length);
-+ built_ptr_query->append(".");
- }
-- built_ptr_query->append(table->table_name);
-- built_ptr_query->append("`,");
-+ append_identifier(thd, built_ptr_query, table->table_name,
-+ table->table_name_length);
-+ built_ptr_query->append(",");
- }
- /*
- This means that a temporary table was droped and as such there
-@@ -2228,15 +2229,15 @@
- Don't write the database name if it is the current one (or if
- thd->db is NULL).
- */
-- built_query.append("`");
- if (thd->db == NULL || strcmp(db,thd->db) != 0)
- {
-- built_query.append(db);
-- built_query.append("`.`");
-+ append_identifier(thd, &built_query, db, db_length);
-+ built_query.append(".");
- }
-
-- built_query.append(table->table_name);
-- built_query.append("`,");
-+ append_identifier(thd, &built_query, table->table_name,
-+ table->table_name_length);
-+ built_query.append(",");
- }
- }
- DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table");
-
-=== modified file 'sql/sql_truncate.cc'
---- sql/sql_truncate.cc 2012-05-16 22:47:28 +0000
-+++ sql/sql_truncate.cc 2012-08-24 13:29:01 +0000
-@@ -24,6 +24,7 @@
- #include "sql_acl.h" // DROP_ACL
- #include "sql_parse.h" // check_one_table_access()
- #include "sql_truncate.h"
-+#include "sql_show.h"
-
-
- /**
-@@ -35,7 +36,8 @@
- @return TRUE on failure, FALSE otherwise.
- */
-
--static bool fk_info_append_fields(String *str, List<LEX_STRING> *fields)
-+static bool fk_info_append_fields(THD *thd, String *str,
-+ List<LEX_STRING> *fields)
- {
- bool res= FALSE;
- LEX_STRING *field;
-@@ -43,9 +45,8 @@
-
- while ((field= it++))
- {
-- res|= str->append("`");
-- res|= str->append(field);
-- res|= str->append("`, ");
-+ res|= append_identifier(thd, str, field->str, field->length);
-+ res|= str->append(", ");
- }
-
- str->chop();
-@@ -76,20 +77,24 @@
- `db`.`tbl`, CONSTRAINT `id` FOREIGN KEY (`fk`) REFERENCES `db`.`tbl` (`fk`)
- */
-
-- res|= str.append('`');
-- res|= str.append(fk_info->foreign_db);
-- res|= str.append("`.`");
-- res|= str.append(fk_info->foreign_table);
-- res|= str.append("`, CONSTRAINT `");
-- res|= str.append(fk_info->foreign_id);
-- res|= str.append("` FOREIGN KEY (");
-- res|= fk_info_append_fields(&str, &fk_info->foreign_fields);
-- res|= str.append(") REFERENCES `");
-- res|= str.append(fk_info->referenced_db);
-- res|= str.append("`.`");
-- res|= str.append(fk_info->referenced_table);
-- res|= str.append("` (");
-- res|= fk_info_append_fields(&str, &fk_info->referenced_fields);
-+ res|= append_identifier(thd, &str, fk_info->foreign_db->str,
-+ fk_info->foreign_db->length);
-+ res|= str.append(".");
-+ res|= append_identifier(thd, &str, fk_info->foreign_table->str,
-+ fk_info->foreign_table->length);
-+ res|= str.append(", CONSTRAINT ");
-+ res|= append_identifier(thd, &str, fk_info->foreign_id->str,
-+ fk_info->foreign_id->length);
-+ res|= str.append(" FOREIGN KEY (");
-+ res|= fk_info_append_fields(thd, &str, &fk_info->foreign_fields);
-+ res|= str.append(") REFERENCES ");
-+ res|= append_identifier(thd, &str, fk_info->referenced_db->str,
-+ fk_info->referenced_db->length);
-+ res|= str.append(".");
-+ res|= append_identifier(thd, &str, fk_info->referenced_table->str,
-+ fk_info->referenced_table->length);
-+ res|= str.append(" (");
-+ res|= fk_info_append_fields(thd, &str, &fk_info->referenced_fields);
- res|= str.append(')');
-
- return res ? NULL : thd->strmake(str.ptr(), str.length());
-
-=== modified file 'sql/sql_yacc.yy'
---- sql/sql_yacc.yy 2012-08-09 15:22:00 +0000
-+++ sql/sql_yacc.yy 2012-08-24 13:29:01 +0000
-@@ -12144,7 +12144,7 @@
- if (lex->update_list.push_back($1) ||
- lex->value_list.push_back($4))
- MYSQL_YYABORT;
-- $4->set_name($3, (uint) ($5 - $3), YYTHD->charset());
-+ $4->set_name_no_truncate($3, (uint) ($5 - $3), YYTHD->charset());
- }
- ;
-
-
-=== modified file 'strings/my_vsnprintf.c'
---- strings/my_vsnprintf.c 2012-03-13 20:55:56 +0000
-+++ strings/my_vsnprintf.c 2012-08-24 13:29:01 +0000
-@@ -694,6 +694,51 @@
- int my_vfprintf(FILE *stream, const char* format, va_list args)
- {
- char cvtbuf[1024];
-- (void) my_vsnprintf(cvtbuf, sizeof(cvtbuf), format, args);
-- return fprintf(stream, "%s\n", cvtbuf);
-+ int alloc= 0;
-+ char *p= cvtbuf;
-+ size_t cur_len= sizeof(cvtbuf);
-+ int ret;
-+
-+ /*
-+ We do not know how much buffer we need.
-+ So start with a reasonably-sized stack-allocated buffer, and increase
-+ it exponentially until it is big enough.
-+ */
-+ for (;;)
-+ {
-+ size_t new_len;
-+ size_t actual= my_vsnprintf(p, cur_len, format, args);
-+ if (actual < cur_len - 1)
-+ break;
-+ /*
-+ Not enough space (or just enough with nothing to spare - but we cannot
-+ distinguish this case from the return value). Allocate a bigger buffer
-+ and try again.
-+ */
-+ if (alloc)
-+ (*my_str_free)(p);
-+ else
-+ alloc= 1;
-+ new_len= cur_len*2;
-+ if (new_len < cur_len)
-+ return 0; /* Overflow */
-+ cur_len= new_len;
-+ p= (*my_str_malloc)(cur_len);
-+ if (!p)
-+ return 0;
-+ }
-+ ret= fprintf(stream, "%s", p);
-+ if (alloc)
-+ (*my_str_free)(p);
-+ return ret;
-+}
-+
-+int my_fprintf(FILE *stream, const char* format, ...)
-+{
-+ int result;
-+ va_list args;
-+ va_start(args, format);
-+ result= my_vfprintf(stream, format, args);
-+ va_end(args);
-+ return result;
- }
-
diff --git a/percona/5.0.75-b12/innodb_check_fragmentation.patch b/percona/5.0.75-b12/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.75-b12/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.75-b12/innodb_fsync_source.patch b/percona/5.0.75-b12/innodb_fsync_source.patch
deleted file mode 100644
index 637a7d6..0000000
--- a/percona/5.0.75-b12/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r 61031ebb48ce innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Nov 03 05:07:56 2008 -0800
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r 61031ebb48ce innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/fil/fil0fil.c Mon Nov 03 05:07:56 2008 -0800
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4166,8 +4187,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4176,7 +4198,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4281,7 +4303,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4322,7 +4345,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r 61031ebb48ce innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/fil0fil.h Mon Nov 03 05:07:56 2008 -0800
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -621,14 +628,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -636,7 +655,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r 61031ebb48ce innobase/include/log0log.h
---- a/innobase/include/log0log.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/log0log.h Mon Nov 03 05:07:56 2008 -0800
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
-@@ -744,6 +767,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r 61031ebb48ce innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:07:56 2008 -0800
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1551,7 +1567,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1921,11 +1937,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1938,7 +1954,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2566,7 +2583,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2647,7 +2664,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3184,8 +3202,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3218,7 +3236,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3331,15 +3349,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r 61031ebb48ce innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:07:56 2008 -0800
-@@ -1638,6 +1638,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r 61031ebb48ce innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0sys.c Mon Nov 03 05:07:56 2008 -0800
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r 61031ebb48ce innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0trx.c Mon Nov 03 05:07:56 2008 -0800
-@@ -916,19 +916,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1659,18 +1661,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1906,19 +1911,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r 61031ebb48ce patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Mon Nov 03 05:07:56 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.75-b12/innodb_io_patches.patch b/percona/5.0.75-b12/innodb_io_patches.patch
deleted file mode 100644
index 0b3ccef..0000000
--- a/percona/5.0.75-b12/innodb_io_patches.patch
+++ /dev/null
@@ -1,672 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2008-12-19 02:19:35.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-01-09 15:51:10.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-01-09 15:40:46.000000000 +0900
-@@ -189,6 +189,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +400,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2008-12-19 02:19:35.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-01-09 15:53:18.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-01-09 15:40:46.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-01-09 15:54:33.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,14 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern uint srv_read_ahead;
-+extern ulint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2008-12-19 02:19:36.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-01-09 15:40:46.000000000 +0900
-@@ -3326,6 +3326,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-01-09 15:40:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-01-09 15:40:46.000000000 +0900
-@@ -2877,8 +2877,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2888,6 +2890,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2898,8 +2902,8 @@
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-@@ -3180,6 +3184,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3198,6 +3209,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3205,6 +3226,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-01-09 15:40:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-01-09 15:58:36.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -324,6 +326,22 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2214,6 +2232,8 @@
- ibool skip_sleep = FALSE;
- ulint i;
-
-+ dulint oldest_lsn;
-+
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
-@@ -2302,9 +2322,9 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-@@ -2317,7 +2337,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2326,6 +2346,49 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ } else if (srv_adaptive_checkpoint) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2352,10 +2415,10 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2365,7 +2428,7 @@
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2407,14 +2470,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2503,7 +2566,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2520,7 +2583,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2008-12-19 02:19:37.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-01-09 15:40:46.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ srv_n_read_io_threads, srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS * 8);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-01-09 15:59:05.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-01-09 15:40:46.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1403,6 +1404,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-01-09 15:59:41.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,13 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern uint srv_read_ahead;
-+extern ulong srv_adaptive_checkpoint;
- }
-
- bool innobase_init(void);
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-01-09 16:01:25.000000000 +0900
-@@ -5036,6 +5036,15 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED
- };
-@@ -5344,6 +5353,41 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. 0:disable 1:enable",
-+ (gptr*) &srv_adaptive_checkpoint, (gptr*) &srv_adaptive_checkpoint,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7637,6 +7636,22 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-01-09 16:05:22.000000000 +0900
-@@ -484,6 +484,37 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -847,6 +859,12 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -982,6 +1000,15 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -1482,6 +1501,13 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-01-12 11:20:31.000000000 +0900
-+++ b/sql/set_var.h 2009-01-12 15:26:35.000000000 +0900
-@@ -31,6 +31,10 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1114,6 +1118,9 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.75-b12/innodb_io_pattern.patch b/percona/5.0.75-b12/innodb_io_pattern.patch
deleted file mode 100644
index 604404f..0000000
--- a/percona/5.0.75-b12/innodb_io_pattern.patch
+++ /dev/null
@@ -1,688 +0,0 @@
-diff -r 2bbfde0e0e70 include/mysql_com.h
---- a/include/mysql_com.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/include/mysql_com.h Mon Dec 22 00:33:48 2008 -0800
-@@ -121,6 +121,9 @@
- #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-+
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-diff -r 2bbfde0e0e70 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Dec 22 00:33:11 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:33:48 2008 -0800
-@@ -653,6 +653,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1966,6 +1969,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2067,6 +2073,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2082,6 +2108,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2656,3 +2702,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r 2bbfde0e0e70 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Dec 22 00:33:48 2008 -0800
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r 2bbfde0e0e70 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/innobase/include/buf0types.h Mon Dec 22 00:33:48 2008 -0800
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r 2bbfde0e0e70 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Dec 22 00:33:48 2008 -0800
-@@ -141,6 +141,11 @@
- extern ulint srv_io_capacity;
- extern ulint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r 2bbfde0e0e70 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Dec 22 00:33:11 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Dec 22 00:33:48 2008 -0800
-@@ -337,6 +337,11 @@
-
- ulint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r 2bbfde0e0e70 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Dec 22 00:33:11 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Dec 22 00:33:48 2008 -0800
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r 2bbfde0e0e70 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Dec 22 00:33:11 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Dec 22 00:33:48 2008 -0800
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r 2bbfde0e0e70 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Dec 22 00:33:11 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Dec 22 00:33:48 2008 -0800
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r 2bbfde0e0e70 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Mon Dec 22 00:33:48 2008 -0800
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r 2bbfde0e0e70 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:48 2008 -0800
-@@ -1569,6 +1569,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6527,6 +6529,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r 2bbfde0e0e70 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/ha_innodb.h Mon Dec 22 00:33:48 2008 -0800
-@@ -240,6 +240,9 @@
- extern ulong srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- }
-
- bool innobase_init(void);
-@@ -266,6 +269,9 @@
- bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-+
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-
- void innobase_release_temporary_latches(THD *thd);
-
-diff -r 2bbfde0e0e70 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:33:48 2008 -0800
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r 2bbfde0e0e70 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:48 2008 -0800
-@@ -4983,6 +4983,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5382,6 +5385,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 2bbfde0e0e70 sql/set_var.cc
---- a/sql/set_var.cc Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/set_var.cc Mon Dec 22 00:33:48 2008 -0800
-@@ -501,6 +501,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -870,6 +876,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1012,6 +1021,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -3117,6 +3129,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r 2bbfde0e0e70 sql/set_var.h
---- a/sql/set_var.h Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/set_var.h Mon Dec 22 00:33:48 2008 -0800
-@@ -985,6 +985,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r 2bbfde0e0e70 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:33:48 2008 -0800
-@@ -7998,6 +7998,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 2bbfde0e0e70 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:33:48 2008 -0800
-@@ -32,6 +32,17 @@
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
- #endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
-@@ -4074,6 +4085,67 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4880,6 +4952,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5055,6 +5140,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 2bbfde0e0e70 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:33:11 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:33:48 2008 -0800
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8541,6 +8542,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9594,6 +9596,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.75-b12/innodb_locks_held.patch b/percona/5.0.75-b12/innodb_locks_held.patch
deleted file mode 100644
index 18c99f4..0000000
--- a/percona/5.0.75-b12/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r ae6708ab17e5 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Dec 22 00:32:07 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Dec 22 00:32:58 2008 -0800
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r ae6708ab17e5 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Dec 22 00:32:07 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Dec 22 00:32:58 2008 -0800
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r ae6708ab17e5 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Dec 22 00:32:07 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Dec 22 00:32:58 2008 -0800
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1694,24 +1696,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1805,6 +1789,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r ae6708ab17e5 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Dec 22 00:32:07 2008 -0800
-+++ b/libmysqld/set_var.cc Mon Dec 22 00:32:58 2008 -0800
-@@ -821,6 +821,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -936,6 +938,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r ae6708ab17e5 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Dec 22 00:32:58 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r ae6708ab17e5 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Dec 22 00:32:07 2008 -0800
-+++ b/sql/ha_innodb.h Mon Dec 22 00:32:58 2008 -0800
-@@ -238,6 +238,8 @@
- extern ulong srv_io_capacity;
- extern ulong srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
- }
-
- bool innobase_init(void);
-diff -r ae6708ab17e5 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:32:07 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:32:58 2008 -0800
-@@ -4969,6 +4969,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5308,6 +5310,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r ae6708ab17e5 sql/set_var.cc
---- a/sql/set_var.cc Mon Dec 22 00:32:07 2008 -0800
-+++ b/sql/set_var.cc Mon Dec 22 00:32:58 2008 -0800
-@@ -495,6 +495,12 @@
- &srv_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -862,6 +868,8 @@
- &sys_innodb_io_capacity,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -977,6 +985,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.75-b12/innodb_rw_lock.patch b/percona/5.0.75-b12/innodb_rw_lock.patch
deleted file mode 100644
index 3070bb0..0000000
--- a/percona/5.0.75-b12/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1459 +0,0 @@
-diff -r 962aec0d731c innobase/configure
---- a/innobase/configure Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/configure Thu Oct 09 08:30:28 2008 -0700
-@@ -20519,6 +20519,88 @@
-
- fi
- done
-+
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
-diff -r 962aec0d731c innobase/configure.in
---- a/innobase/configure.in Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/configure.in Thu Oct 09 08:30:28 2008 -0700
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -r 962aec0d731c innobase/ib_config.h
---- a/innobase/ib_config.h Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/ib_config.h Thu Oct 09 08:30:28 2008 -0700
-@@ -3,6 +3,9 @@
-
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-+
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-diff -r 962aec0d731c innobase/ib_config.h.in
---- a/innobase/ib_config.h.in Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/ib_config.h.in Thu Oct 09 08:30:28 2008 -0700
-@@ -2,6 +2,9 @@
-
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-+
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-diff -r 962aec0d731c innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/include/sync0rw.h Thu Oct 09 08:30:28 2008 -0700
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,11 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +432,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +442,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -r 962aec0d731c innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/include/sync0rw.ic Thu Oct 09 08:30:28 2008 -0700
-@@ -47,20 +47,52 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
- }
- UNIV_INLINE
- void
--rw_lock_set_waiters(
--/*================*/
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+ lock->s_waiters = flag;
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+ lock->x_waiters = flag;
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+ lock->wait_ex_waiters = flag;
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +100,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +140,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +149,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +179,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +225,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +261,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +307,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +344,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +373,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +395,55 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if ((lock->lock_word == RW_LOCK_BIAS)
-+ && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* x-unlock */
-+ __sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS);
-+ }
-+ } else {
-+ /* fail (x-lock) */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)
-+ && rw_lock_get_writer(lock) == RW_LOCK_EX) {
-+ goto relock;
-+ }
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +474,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +490,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,20 +525,36 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && lock->wait_ex_waiters)) {
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+#endif
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ else if (UNIV_UNLIKELY(last && lock->x_waiters)) {
-+#else
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+#endif
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(mutex);
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -409,13 +578,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +613,81 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+
-+ /* atomic operation may be safer about memory order. */
-+ rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-+ __sync_synchronize();
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+#else
-+ if (lock->writer_count == 0) {
-+#endif
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +712,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +726,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -r 962aec0d731c innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/sync/sync0arr.c Thu Oct 09 08:30:28 2008 -0700
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -r 962aec0d731c innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/sync/sync0rw.c Thu Oct 09 08:30:28 2008 -0700
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,6 +199,8 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
-@@ -199,7 +208,9 @@
- {
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
- ut_a((rw_lock_get_reader_count(lock) == 0)
-@@ -207,11 +218,17 @@
- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+ ut_a((rw_lock_get_s_waiters(lock) == 0)
-+ || (rw_lock_get_s_waiters(lock) == 1));
-+ ut_a((rw_lock_get_x_waiters(lock) == 0)
-+ || (rw_lock_get_x_waiters(lock) == 1));
-+ ut_a((rw_lock_get_wx_waiters(lock) == 0)
-+ || (rw_lock_get_wx_waiters(lock) == 1));
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +254,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +280,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +311,19 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +358,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +388,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+ if (lock->lock_word == RW_LOCK_BIAS) {
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS);
-+ }
-+ }
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* ??? */
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +552,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +578,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +612,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +628,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +646,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +661,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +898,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +910,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +920,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +944,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +991,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1022,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1049,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1119,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -r 962aec0d731c patch_info/innodb_rw_lock.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_rw_lock.info Thu Oct 09 08:30:28 2008 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.75-b12/innodb_show_bp.patch b/percona/5.0.75-b12/innodb_show_bp.patch
deleted file mode 100644
index a56ae9a..0000000
--- a/percona/5.0.75-b12/innodb_show_bp.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,13 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.75-b12/innodb_show_hashed_memory.patch b/percona/5.0.75-b12/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.75-b12/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.75-b12/microsec_process.patch b/percona/5.0.75-b12/microsec_process.patch
deleted file mode 100644
index 0e094e5..0000000
--- a/percona/5.0.75-b12/microsec_process.patch
+++ /dev/null
@@ -1,281 +0,0 @@
-diff -r 327ce7a34c91 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/information_schema.result Fri Nov 07 15:52:53 2008 -0800
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r 327ce7a34c91 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Fri Nov 07 15:52:53 2008 -0800
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r 327ce7a34c91 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Fri Nov 07 15:52:53 2008 -0800
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r 327ce7a34c91 sql/mysql_priv.h
---- a/sql/mysql_priv.h Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/mysql_priv.h Fri Nov 07 15:52:53 2008 -0800
-@@ -244,6 +244,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r 327ce7a34c91 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/sql_show.cc Fri Nov 07 15:52:53 2008 -0800
-@@ -1466,6 +1466,120 @@
- }
- send_eof(thd);
- DBUG_VOID_RETURN;
-+}
-+
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ const ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
- }
-
- /*****************************************************************************
-@@ -4821,6 +4941,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4845,6 +4981,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r 327ce7a34c91 sql/table.h
---- a/sql/table.h Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/table.h Fri Nov 07 15:52:53 2008 -0800
-@@ -378,6 +378,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
-diff -ruN mysql-5.0.67_highperf/patch_info/microsec_process.info mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+ChangeLog=
diff --git a/percona/5.0.75-b12/microslow_innodb.patch b/percona/5.0.75-b12/microslow_innodb.patch
deleted file mode 100644
index 763981f..0000000
--- a/percona/5.0.75-b12/microslow_innodb.patch
+++ /dev/null
@@ -1,2472 +0,0 @@
-diff -r 25523be1816e include/my_getopt.h
---- a/include/my_getopt.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/include/my_getopt.h Mon Dec 22 00:26:39 2008 -0800
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_DOUBLE 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 25523be1816e include/my_time.h
---- a/include/my_time.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/include/my_time.h Mon Dec 22 00:26:39 2008 -0800
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 25523be1816e innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:26:39 2008 -0800
-@@ -37,6 +37,9 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1089,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1141,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1157,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1189,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1302,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1275,6 +1321,12 @@
-
- break;
- }
-+ }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
- }
- }
-
-@@ -1296,12 +1348,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1383,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,13 +1498,18 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-@@ -1470,6 +1533,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1558,6 +1622,11 @@
- || (ibuf_count_get(block->space, block->offset) == 0));
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-diff -r 25523be1816e innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/buf/buf0rea.c Mon Dec 22 00:26:39 2008 -0800
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 25523be1816e innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/fil/fil0fil.c Mon Dec 22 00:26:39 2008 -0800
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 25523be1816e innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/include/buf0rea.h Mon Dec 22 00:26:39 2008 -0800
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 25523be1816e innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/include/fil0fil.h Mon Dec 22 00:26:39 2008 -0800
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 25523be1816e innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/include/os0file.h Mon Dec 22 00:26:39 2008 -0800
-@@ -10,6 +10,8 @@
- #define os0file_h
-
- #include "univ.i"
-+
-+#include "trx0types.h"
-
- #ifndef __WIN__
- #include <dirent.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 25523be1816e innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Dec 22 00:26:39 2008 -0800
-@@ -26,6 +26,8 @@
- at a time */
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-+
-+extern ibool srv_slow_log;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-diff -r 25523be1816e innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/include/trx0trx.h Mon Dec 22 00:26:39 2008 -0800
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 25523be1816e innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Dec 22 00:26:39 2008 -0800
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 25523be1816e innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/os/os0file.c Mon Dec 22 00:26:39 2008 -0800
-@@ -14,6 +14,7 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1904,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1918,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1947,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1967,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1980,6 +2003,13 @@
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-+
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- return(ret);
- }
-@@ -2103,7 +2133,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2143,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2208,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3168,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3422,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3462,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3496,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 25523be1816e innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Dec 22 00:26:39 2008 -0800
-@@ -47,6 +47,8 @@
- #include "dict0boot.h"
- #include "srv0start.h"
- #include "row0mysql.h"
-+
-+ibool srv_slow_log = 0;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
-@@ -996,6 +998,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1054,6 +1060,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1109,11 +1116,22 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-+
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- os_fast_mutex_lock(&srv_conc_mutex);
-
-diff -r 25523be1816e innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/innobase/trx/trx0trx.c Mon Dec 22 00:26:39 2008 -0800
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 25523be1816e mysys/my_getopt.c
---- a/mysys/my_getopt.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/mysys/my_getopt.c Mon Dec 22 00:26:39 2008 -0800
-@@ -1061,6 +1061,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_DOUBLE:
-+ printf("%6f\n", *((double*) value));
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 25523be1816e patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Mon Dec 22 00:26:39 2008 -0800
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 25523be1816e scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Mon Dec 22 00:25:06 2008 -0800
-+++ b/scripts/mysqldumpslow.sh Mon Dec 22 00:26:39 2008 -0800
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 25523be1816e sql-common/my_time.c
---- a/sql-common/my_time.c Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql-common/my_time.c Mon Dec 22 00:26:39 2008 -0800
-@@ -1252,3 +1252,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 25523be1816e sql/filesort.cc
---- a/sql/filesort.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/filesort.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 25523be1816e sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -805,9 +806,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1309,6 +1335,8 @@
- }
-
- /* -------------- Log files ---------------------------*/
-+
-+ srv_slow_log = (ibool) opt_slow_log;
-
- /* The default dir for log files is the datadir of MySQL */
-
-@@ -4673,6 +4701,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4938,6 +4972,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5025,6 +5065,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5089,6 +5135,12 @@
-
- if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) {
- trx->check_foreigns = FALSE;
-+ }
-+
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
- }
-
- name_len1 = strlen(from);
-@@ -6098,6 +6150,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6221,7 +6274,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 25523be1816e sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/ha_innodb.h Mon Dec 22 00:26:39 2008 -0800
-@@ -266,6 +266,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 25523be1816e sql/log.cc
---- a/sql/log.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/log.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -2229,11 +2229,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2243,7 +2244,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2273,22 +2275,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 25523be1816e sql/log_event.cc
---- a/sql/log_event.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/log_event.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -2039,6 +2039,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 25523be1816e sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:26:39 2008 -0800
-@@ -489,6 +489,78 @@
- #define WEEK_FIRST_WEEKDAY 4
-
- #define STRING_BUFFER_USUAL_SIZE 80
-+
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-
- enum enum_parsing_place
- {
-@@ -1345,6 +1417,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1356,7 +1429,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 25523be1816e sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -175,7 +175,6 @@
- static void getvolumename();
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
--
-
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
-@@ -409,10 +408,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -507,6 +508,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -584,7 +586,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3655,6 +3657,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4901,7 +4905,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -4992,11 +4996,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5386,8 +5396,17 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
-@@ -5753,6 +5772,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6055,11 +6077,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_DOUBLE,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6835,7 +6873,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7296,6 +7338,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7628,10 +7699,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 25523be1816e sql/set_var.cc
---- a/sql/set_var.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/set_var.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +285,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +331,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -694,6 +712,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -717,6 +738,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -770,6 +792,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -986,8 +1010,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1014,6 +1041,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1101,6 +1129,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1141,6 +1171,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1769,6 +1799,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1924,6 +1965,19 @@
- value= *(longlong*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
-+ }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
- }
- case SHOW_HA_ROWS:
- {
-@@ -2757,6 +2811,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3519,6 +3597,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 25523be1816e sql/set_var.h
---- a/sql/set_var.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/set_var.h Mon Dec 22 00:26:39 2008 -0800
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -377,7 +383,6 @@
- SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
--
-
- class sys_var_thd_ulonglong :public sys_var_thd
- {
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -477,6 +495,66 @@
- ulong *length);
- };
-
-+
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-
- class sys_var_thd_storage_engine :public sys_var_thd
- {
-@@ -1087,3 +1165,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 25523be1816e sql/slave.cc
---- a/sql/slave.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/slave.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -2925,6 +2925,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 25523be1816e sql/sql_cache.cc
---- a/sql/sql_cache.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_cache.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -1341,6 +1341,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1348,6 +1349,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 25523be1816e sql/sql_class.cc
---- a/sql/sql_class.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_class.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -188,7 +188,7 @@
- lock_id(&main_lock_id),
- user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2224,6 +2224,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2240,7 +2246,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2293,6 +2305,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 25523be1816e sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:26:39 2008 -0800
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -314,7 +321,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -520,13 +527,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -542,10 +550,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1121,6 +1132,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1177,6 +1194,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1285,10 +1307,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1678,11 +1714,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 25523be1816e sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,27 +2363,55 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-+ ulonglong start_of_query_timer= thd->start_timer;
- thd->end_time(); // Set start time
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+ if (thd->write_to_slow_log != TRUE && thd->variables.long_query_time < 1000000 &&
-+ (ulong) (thd->start_timer - thd->timer_after_lock) >= 1000000)
-+ thd->write_to_slow_log= TRUE;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE)
-+ return;
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time ||
-- (thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END)
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2664,6 +2702,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6084,6 +6120,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 25523be1816e sql/sql_select.cc
---- a/sql/sql_select.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_select.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -6221,8 +6221,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6237,8 +6240,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9302,6 +9308,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10162,6 +10169,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 25523be1816e sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:26:39 2008 -0800
-@@ -1532,6 +1532,12 @@
- value= ((char *) status_var + (ulonglong) value);
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
-+ break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
- break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
-diff -r 25523be1816e sql/structs.h
---- a/sql/structs.h Mon Dec 22 00:25:06 2008 -0800
-+++ b/sql/structs.h Mon Dec 22 00:26:39 2008 -0800
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.75-b12/mirror_binlog.patch b/percona/5.0.75-b12/mirror_binlog.patch
deleted file mode 100644
index 4dae799..0000000
--- a/percona/5.0.75-b12/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5036,6 +5037,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED
- };
-
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.75-b12/mysql-percona.rhel5.spec b/percona/5.0.75-b12/mysql-percona.rhel5.spec
deleted file mode 100644
index 044b347..0000000
--- a/percona/5.0.75-b12/mysql-percona.rhel5.spec
+++ /dev/null
@@ -1,1396 +0,0 @@
-%define mysql_vendor Percona Inc
-%{!?redhat_version:%define redhat_version 5}
-%define distribution rhel%{redhat_version}
-%define release 0.%{distribution}
-%define patchset b12
-
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'perconahighperf 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'percona 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-
-# Meta information
-# norootforbuild
-
-# use "rpmbuild --with yassl" or "rpm --define '_with_yassl 1'" (for RPM 3.x)
-# to build with yaSSL support (off by default)
-%{?_with_yassl:%define YASSL_BUILD 1}
-%{!?_with_yassl:%define YASSL_BUILD 0}
-
-# FIXME disabled until we move out the version strings from spec file
-## use "rpmbuild --with cluster" or "rpm --define '_with_cluster 1'" (for RPM 3.x)
-## to build with cluster support (off by default)
-##%{?_with_cluster:%define CLUSTER_BUILD 1}
-##%{!?_with_cluster:%define CLUSTER_BUILD 0}
-
-#
-# Product definitions - one of these has to be defined via the RPM build
-# options, e.g. "--define 'enterprise 1'"
-#
-%{!?enterprise:%define enterprise 0}
-%{!?enterprise_gpl:%define enterprise_gpl 0}
-%{!?classic:%define classic 0}
-%{!?cluster:%define cluster 0}
-%{!?cluster_gpl:%define cluster_gpl 0}
-%{!?community:%define community 0}
-%{!?percona:%define percona 0}
-%{!?perconahighperf:%define perconahighperf 0}
-%{!?mysqlversion:%define mysqlversion 5.0.67}
-#%define mysql_version 5.0.67
-
-# On SuSE 9 no separate "debuginfo" package is built. To enable basic
-# debugging on that platform, we don't strip binaries on SuSE 9. We
-# disable the strip of binaries by redefining the RPM macro
-# "__os_install_post" leaving out the script calls that normally does
-# this. We do this in all cases, as on platforms where "debuginfo" is
-# created, a script "find-debuginfo.sh" will be called that will do
-# the strip anyway, part of separating the executable and debug
-# information into separate files put into separate packages.
-#
-# Some references (shows more advanced conditional usage):
-# http://www.redhat.com/archives/rpm-list/2001-November/msg00257.html
-# http://www.redhat.com/archives/rpm-list/2003-February/msg00275.html
-# http://www.redhat.com/archives/rhl-devel-list/2004-January/msg01546.html
-# http://lists.opensuse.org/archive/opensuse-commit/2006-May/1171.html
-
-%define __os_install_post /usr/lib/rpm/brp-compress
-
-
-%if %{percona}
-%define comment MySQL Percona Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-%{patchset}
-%endif
-
-%if %{perconahighperf}
-%define comment MySQL Percona High Performance Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-highperf-%{patchset}
-%endif
-
-%if %{community}
-%define comment MySQL Community Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -community
-%endif
-
-%if %{enterprise}
-%define comment MySQL Enterprise Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise
-%endif
-
-%if %{enterprise_gpl}
-%define comment MySQL Enterprise Server
-%define commercial 0
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise-gpl
-%endif
-
-%if %{classic}
-%define comment MySQL Classic Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 0
-%define server_suffix -classic
-%endif
-
-
-%if %{COMMUNITY_BUILD}
-%define cluster_package_prefix -cluster
-%else
-%define cluster_package_prefix -
-%endif
-
-%define mysqld_user mysql
-%define mysqld_group mysql
-%define mysqldatadir /var/lib/mysql
-
-# We don't package all files installed into the build root by intention -
-# See BUG#998 for details.
-%define _unpackaged_files_terminate_build 0
-
-%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com
-Source0: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-%{version}.tar.gz
-
-Patch1: show_patches.patch
-Patch2: microslow_innodb.patch
-Patch3: userstatv2.patch
-Patch4: microsec_process.patch
-Patch5: innodb_io_patches.patch
-Patch6: mirror_binlog.patch
-Patch7: mysqld_safe_syslog.patch
-Patch8: innodb_locks_held.patch
-Patch9: innodb_show_bp.patch
-Patch10: innodb_show_hashed_memory.patch
-Patch11: innodb_check_fragmentation.patch
-Patch12: innodb_io_pattern.patch
-Patch13: innodb_fsync_source.patch
-Patch100: split_buf_pool_mutex_fixed_optimistic_safe.patch
-Patch101: innodb_rw_lock.patch
-
-
-Name: MySQL%{server_suffix}
-Summary: MySQL: a very fast and reliable SQL database server
-Group: Applications/Databases
-Version: %{mysqlversion}
-Release: %{release}
-Distribution: Red Hat Enterprise Linux %{redhat_version}
-License: GPL
-Source: mysql-%{mysqlversion}.tar.gz
-URL: http://www.mysql.com/
-Packager: Percona Build Team <info@percona.com>
-Vendor: %{mysql_vendor}
-Provides: msqlormysql MySQL-server mysql
-BuildRequires: gperf perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time
-
-# Think about what you use here since the first step is to
-# run a rm -rf
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-
-# From the manual
-%description
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-%package -n MySQL-server%{server_suffix}
-Summary: @COMMENT@ for Red Hat Enterprise Linux %{redhat_version}
-Group: Applications/Databases
-Requires: chkconfig coreutils shadow-utils grep procps
-Provides: msqlormysql mysql-server mysql MySQL MySQL-server
-Obsoletes: MySQL mysql mysql-server MySQL-server
-
-%description -n MySQL-server%{server_suffix}
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-This package includes the MySQL server binary
-%if %{INNODB_BUILD}
-(configured including InnoDB)
-%endif
-as well as related utilities to run and administer a MySQL server.
-
-If you want to access and work with the database, you have to install
-package "MySQL-client%{server_suffix}" as well!
-
-%package -n MySQL-client%{server_suffix}
-Summary: MySQL - Client
-Group: Applications/Databases
-Obsoletes: mysql-client MySQL-client
-Provides: mysql-client MySQL-client
-
-%description -n MySQL-client%{server_suffix}
-This package contains the standard MySQL clients and administration tools.
-
-%{see_base}
-
-%package -n MySQL-test%{server_suffix}
-Requires: mysql-client perl
-Summary: MySQL - Test suite
-Group: Applications/Databases
-Provides: mysql-test MySQL-test
-Obsoletes: mysql-test MySQL-test
-AutoReqProv: no
-
-%description -n MySQL-test%{server_suffix}
-This package contains the MySQL regression test suite.
-
-%{see_base}
-
-%package -n MySQL-devel%{server_suffix}
-Summary: MySQL - Development header files and libraries
-Group: Applications/Databases
-Provides: mysql-devel MySQL-devel
-Obsoletes: mysql-devel MySQL-devel
-
-%description -n MySQL-devel%{server_suffix}
-This package contains the development header files and libraries
-necessary to develop MySQL client applications.
-
-%{see_base}
-
-%package -n MySQL-shared%{server_suffix}
-Summary: MySQL - Shared libraries
-Group: Applications/Databases
-Provides: mysql-shared MySQL-shared
-# Obsoletes below to correct old missing Provides:/Obsoletes
-Obsoletes: mysql-shared MySQL-shared-standard MySQL-shared-pro
-Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl
-Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared
-
-%description -n MySQL-shared%{server_suffix}
-This package contains the shared libraries (*.so*) which certain
-languages and applications need to dynamically load and use MySQL.
-
-%prep
-%setup -n mysql-%{mysqlversion}
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-#%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
-%if %{perconahighperf}
-%patch100 -p1
-%patch101 -p1
-%endif
-
-%build
-
-pushd ..
-tar cfz mysql-%{mysqlversion}%{server_suffix}-src.tar.gz mysql-%{mysqlversion}
-mv mysql-%{mysqlversion}%{server_suffix}-src.tar.gz %{_topdir}
-popd
-
-BuildMySQL() {
-# Evaluate current setting of $DEBUG
-if [ $DEBUG -gt 0 ] ; then
- OPT_COMMENT='--with-comment="%{comment} - Debug (%{license})"'
- OPT_DEBUG='--with-debug'
-else
- OPT_COMMENT='--with-comment="%{comment} (%{license})"'
- OPT_DEBUG=''
-fi
-if [ $BINARYPKG -ne 1 ] ; then
- OPT_PATH='--exec-prefix=%{_exec_prefix} \
- --libexecdir=%{_sbindir} \
- --libdir=%{_libdir} \
- --sysconfdir=%{_sysconfdir} \
- --datadir=%{_datadir} \
- --localstatedir=%{mysqldatadir} \
- --infodir=%{_infodir} \
- --includedir=%{_includedir} \
- --mandir=%{_mandir}'
-else
- OPT_PATH='--prefix=/usr/local/mysql-%{mysqlversion}%{server_suffix}'
-fi
-
-# The --enable-assembler simply does nothing on systems that does not
-# support assembler speedups.
-sh -c "CFLAGS=\"${CFLAGS:-$RPM_OPT_FLAGS}\" \
- CXXFLAGS=\"${CXXFLAGS:-$RPM_OPT_FLAGS}\" \
- LDFLAGS=\"$LDFLAGS\" \
- ./configure \
- $* \
- --enable-assembler \
- --enable-local-infile \
- --with-mysqld-user=%{mysqld_user} \
- --with-unix-socket-path=/var/lib/mysql/mysql.sock \
- --with-pic \
- --prefix=/ \
- --with-extra-charsets=complex \
-%if %{YASSL_BUILD}
- --with-yassl \
-%endif
- $OPT_PATH \
- --enable-thread-safe-client \
-%if %{?comment:1}0
- $OPT_COMMENT \
-%endif
- $OPT_DEBUG \
- --with-readline \
- ; make -j8"
-}
-# end of function definition "BuildMySQL"
-
-
-BuildServer() {
-BuildMySQL "--disable-shared \
-%if %{?server_suffix:1}0
- --with-server-suffix='%{server_suffix}' \
-%endif
- --without-embedded-server \
-%if %{INNODB_BUILD}
- --with-innodb \
-%else
- --without-innodb \
-%endif
- --with-csv-storage-engine \
- --with-archive-storage-engine \
- --with-blackhole-storage-engine \
- --with-federated-storage-engine \
- --without-bench \
- --with-zlib-dir=bundled \
- --with-big-tables"
-
-if [ -n "$MYSQL_CONFLOG_DEST" ] ; then
- cp -fp config.log "$MYSQL_CONFLOG_DEST"
-fi
-
-if [ -f sql/.libs/mysqld ] ; then
- nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym
-else
- nm --numeric-sort sql/mysqld > sql/mysqld.sym
-fi
-}
-# end of function definition "BuildServer"
-
-
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Clean up the BuildRoot first
-[ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR;
-mkdir -p $RBR%{_libdir}/mysql $RBR%{_sbindir}
-
-# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and
-# including exceptions into the code
-if [ -z "$CXX" -a -z "$CC" ] ; then
- export CC="gcc" CXX="gcc"
-fi
-
-# Create the shared libs seperately to avoid a dependency for the client utilities
-DEBUG=0
-BINARYPKG=0
-BuildMySQL "--enable-shared --without-server"
-
-# Install shared libraries
-cp -av libmysql/.libs/*.so* $RBR/%{_libdir}
-cp -av libmysql_r/.libs/*.so* $RBR/%{_libdir}
-
-# Include libgcc.a in the devel subpackage (BUG 4921)
-if expr "$CC" : "gcc.*" > /dev/null && \
- expr "$CC" : ".* gcc.*" > /dev/null ; then
- libgcc=`$CC $CFLAGS --print-libgcc-file`
- if [ -f $libgcc ] ; then
- install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
- fi
-fi
-
-# Now create a debug server
-DEBUG=1
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt-debug
-fi
-
-# Get the debug server and its .sym file from the build tree
-if [ -f sql/.libs/mysqld ] ; then
- cp sql/.libs/mysqld $RBR%{_sbindir}/mysqld-debug
-else
- cp sql/mysqld $RBR%{_sbindir}/mysqld-debug
-fi
-
-cp sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld-debug.sym
-
-# Now, the binary package
-DEBUG=0
-BINARYPKG=1
-make clean distclean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-rm -fr /tmp/mysql-%{mysqlversion}%{server_suffix}
-make DESTDIR=/tmp/mysql-%{mysqlversion}%{server_suffix} install
-pushd /tmp/mysql-%{mysqlversion}%{server_suffix}/usr/local
-tar cfz mysql-%{mysqlversion}%{server_suffix}.tar.gz mysql-%{mysqlversion}%{server_suffix}
-mv mysql-%{mysqlversion}%{server_suffix}.tar.gz %{_topdir}
-popd
-
-# Now, the default server
-DEBUG=0
-BINARYPKG=0
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-
-
-%install
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Ensure that needed directories exists
-install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
-install -d $RBR%{mysqldatadir}/mysql
-install -d $RBR%{_datadir}/mysql-test
-install -d $RBR%{_datadir}/mysql/SELinux/RHEL4
-install -d $RBR%{_includedir}
-install -d $RBR%{_libdir}
-install -d $RBR%{_mandir}
-install -d $RBR%{_sbindir}
-
-make DESTDIR=$RBR benchdir_root=%{_datadir} install
-
-# install symbol files ( for stack trace resolution)
-install -m644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym
-
-# Install logrotate and autostart
-install -m644 $MBD/support-files/mysql-log-rotate \
- $RBR%{_sysconfdir}/logrotate.d/mysql
-install -m755 $MBD/support-files/mysql.server \
- $RBR%{_sysconfdir}/init.d/mysql
-
-# Create a symlink "rcmysql", pointing to the init.script. SuSE users
-# will appreciate that, as all services usually offer this.
-ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql
-
-# Create symbolic compatibility link safe_mysqld -> mysqld_safe
-# (safe_mysqld will be gone in MySQL 4.1)
-ln -sf ./mysqld_safe $RBR%{_bindir}/safe_mysqld
-
-# Touch the place where the my.cnf config file and mysqlmanager.passwd
-# (MySQL Instance Manager password file) might be located
-# Just to make sure it's in the file list and marked as a config file
-touch $RBR%{_sysconfdir}/my.cnf
-touch $RBR%{_sysconfdir}/mysqlmanager.passwd
-
-# Install SELinux files in datadir
-install -m600 $MBD/support-files/RHEL4-SElinux/mysql.{fc,te} \
- $RBR%{_datadir}/mysql/SELinux/RHEL4
-
-
-%pre -n MySQL-server%{server_suffix}
-# Check if we can safely upgrade. An upgrade is only safe if it's from one
-# of our RPMs in the same version family.
-
-installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
-if [ $? -eq 0 -a -n "$installed" ]; then
- vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
- version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
- myvendor='%{mysql_vendor}'
- myversion='%{mysqlversion}'
-
- old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
- new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
-
- [ -z "$vendor" ] && vendor='<unknown>'
- [ -z "$old_family" ] && old_family="<unrecognized version $version>"
- [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"
-
- error_text=
- if [ "$vendor" != "$myvendor" ]; then
- error_text="$error_text
-The current MySQL server package is provided by a different
-vendor ($vendor) than $myvendor. Some files may be installed
-to different locations, including log files and the service
-startup script in %{_sysconfdir}/init.d/.
-"
- fi
-
- if [ "$old_family" != "$new_family" ]; then
- error_text="$error_text
-Upgrading directly from MySQL $old_family to MySQL $new_family may not
-be safe in all cases. A manual dump and restore using mysqldump is
-recommended. It is important to review the MySQL manual's Upgrading
-section for version-specific incompatibilities.
-"
- fi
-
- if [ -n "$error_text" ]; then
- cat <<HERE >&2
-
-******************************************************************
-A MySQL server package ($installed) is installed.
-$error_text
-A manual upgrade is required.
-
-- Ensure that you have a complete, working backup of your data and my.cnf
- files
-- Shut down the MySQL server cleanly
-- Remove the existing MySQL packages. Usually this command will
- list the packages you should remove:
- rpm -qa | grep -i '^mysql-'
-
- You may choose to use 'rpm --nodeps -ev <package-name>' to remove
- the package which contains the mysqlclient shared library. The
- library will be reinstalled by the MySQL-shared-compat package.
-- Install the new MySQL packages supplied by $myvendor
-- Ensure that the MySQL server is started
-- Run the 'mysql_upgrade' program
-
-This is a brief description of the upgrade process. Important details
-can be found in the MySQL manual, in the Upgrading section.
-******************************************************************
-HERE
- exit 1
- fi
-fi
-
-# Shut down a previously installed server first
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
- echo "Giving mysqld 5 seconds to exit nicely"
- sleep 5
-fi
-
-%post -n MySQL-server%{server_suffix}
-mysql_datadir=%{mysqldatadir}
-
-# Create data directory
-mkdir -p $mysql_datadir/{mysql,test}
-
-# Make MySQL start/shutdown automatically when the machine does it.
-if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --add mysql
-fi
-
-
-
-# Create a MySQL user and group. Do not report any problems if it already
-# exists.
-groupadd -r %{mysqld_group} 2> /dev/null || true
-useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
-usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-
-# Change permissions so that the user that will run the MySQL daemon
-# owns all database files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Initiate databases
-%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
-
-# Upgrade databases if needed would go here - but it cannot be automated yet
-
-# Change permissions again to fix any new files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Fix permissions for the permission database so that only the user
-# can read them.
-chmod -R og-rw $mysql_datadir/mysql
-
-# install SELinux files - but don't override existing ones
-SETARGETDIR=/etc/selinux/targeted/src/policy
-SEDOMPROG=$SETARGETDIR/domains/program
-SECONPROG=$SETARGETDIR/file_contexts/program
-if [ -f /etc/redhat-release ] \
- && grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \
- || grep -q "CentOS release 4" /etc/redhat-release ; then
- echo
- echo
- echo 'Notes regarding SELinux on this platform:'
- echo '========================================='
- echo
- echo 'The default policy might cause server startup to fail because it is '
- echo 'not allowed to access critical files. In this case, please update '
- echo 'your installation. '
- echo
- echo 'The default policy might also cause inavailability of SSL related '
- echo 'features because the server is not allowed to access /dev/random '
- echo 'and /dev/urandom. If this is a problem, please do the following: '
- echo
- echo ' 1) install selinux-policy-targeted-sources from your OS vendor'
- echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':'
- echo ' allow mysqld_t random_device_t:chr_file read;'
- echo ' allow mysqld_t urandom_device_t:chr_file read;'
- echo ' 3) cd to '$SETARGETDIR' and issue the following command:'
- echo ' make load'
- echo
- echo
-fi
-
-if [ -x sbin/restorecon ] ; then
- sbin/restorecon -R var/lib/mysql
-fi
-
-# Restart in the same way that mysqld will be started normally.
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql start
- echo "Giving mysqld 2 seconds to start"
- sleep 2
-fi
-
-# Allow safe_mysqld to start mysqld and print a message before we exit
-sleep 2
-
-
-%preun -n MySQL-server%{server_suffix}
-if [ $1 = 0 ] ; then
- # Stop MySQL before uninstalling it
- if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null
- # Don't start it automatically anymore
- if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --del mysql
- fi
- fi
-fi
-
-# We do not remove the mysql user since it may still own a lot of
-# database files.
-
-# Clean up the BuildRoot
-%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
-
-%files -n MySQL-server%{server_suffix}
-%defattr(-,root,root,0755)
-
-%if %{commercial}
-%doc LICENSE.mysql
-%else
-%doc COPYING README
-%endif
-%doc support-files/my-*.cnf
-
-%doc %attr(644, root, root) %{_infodir}/mysql.info*
-
-%if %{INNODB_BUILD}
-%doc %attr(644, root, man) %{_mandir}/man1/innochecksum.1*
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/my_print_defaults.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisam_ftdump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamchk.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisampack.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_convert_table_format.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_explain_log.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_extensions.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqld.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
-%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
-%doc %attr(644, root, man) %{_mandir}/man1/replace.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
-%doc %attr(644, root, man) %{_mandir}/man1/safe_mysqld.1*
-
-%ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/mysqlmanager.passwd
-
-%if %{INNODB_BUILD}
-%attr(755, root, root) %{_bindir}/innochecksum
-%endif
-%attr(755, root, root) %{_bindir}/my_print_defaults
-%attr(755, root, root) %{_bindir}/myisam_ftdump
-%attr(755, root, root) %{_bindir}/myisamchk
-%attr(755, root, root) %{_bindir}/myisamlog
-%attr(755, root, root) %{_bindir}/myisampack
-%attr(755, root, root) %{_bindir}/mysql_convert_table_format
-%attr(755, root, root) %{_bindir}/mysql_explain_log
-%attr(755, root, root) %{_bindir}/mysql_fix_extensions
-%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
-%attr(755, root, root) %{_bindir}/mysql_install_db
-%attr(755, root, root) %{_bindir}/mysql_secure_installation
-%attr(755, root, root) %{_bindir}/mysql_setpermission
-%attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
-%attr(755, root, root) %{_bindir}/mysql_upgrade
-%attr(755, root, root) %{_bindir}/mysql_zap
-%attr(755, root, root) %{_bindir}/mysqlbug
-%attr(755, root, root) %{_bindir}/mysqld_multi
-%attr(755, root, root) %{_bindir}/mysqld_safe
-%attr(755, root, root) %{_bindir}/mysqldumpslow
-%attr(755, root, root) %{_bindir}/mysqlhotcopy
-%attr(755, root, root) %{_bindir}/mysqltest
-%attr(755, root, root) %{_bindir}/perror
-%attr(755, root, root) %{_bindir}/replace
-%attr(755, root, root) %{_bindir}/resolve_stack_dump
-%attr(755, root, root) %{_bindir}/resolveip
-%attr(755, root, root) %{_bindir}/safe_mysqld
-
-%attr(755, root, root) %{_sbindir}/mysqld
-%attr(755, root, root) %{_sbindir}/mysqld-debug
-%attr(755, root, root) %{_sbindir}/mysqlmanager
-%attr(755, root, root) %{_sbindir}/rcmysql
-%attr(644, root, root) %{_libdir}/mysql/mysqld.sym
-%attr(644, root, root) %{_libdir}/mysql/mysqld-debug.sym
-
-%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
-%attr(755, root, root) %{_sysconfdir}/init.d/mysql
-
-%attr(755, root, root) %{_datadir}/mysql/
-
-%files -n MySQL-client%{server_suffix}
-%defattr(-, root, root, 0755)
-%attr(755, root, root) %{_bindir}/msql2mysql
-%attr(755, root, root) %{_bindir}/mysql
-%attr(755, root, root) %{_bindir}/mysql_find_rows
-%attr(755, root, root) %{_bindir}/mysql_tableinfo
-%attr(755, root, root) %{_bindir}/mysql_upgrade_shell
-%attr(755, root, root) %{_bindir}/mysql_waitpid
-%attr(755, root, root) %{_bindir}/mysqlaccess
-%attr(755, root, root) %{_bindir}/mysqladmin
-%attr(755, root, root) %{_bindir}/mysqlbinlog
-%attr(755, root, root) %{_bindir}/mysqlcheck
-%attr(755, root, root) %{_bindir}/mysqldump
-%attr(755, root, root) %{_bindir}/mysqlimport
-%attr(755, root, root) %{_bindir}/mysqlshow
-
-%doc %attr(644, root, man) %{_mandir}/man1/msql2mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tableinfo.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_waitpid.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlaccess.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqladmin.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlbinlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlcheck.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1*
-
-%post -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%postun -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%files -n MySQL-devel%{server_suffix}
-%defattr(-, root, root, 0755)
-%if %{commercial}
-%else
-%doc EXCEPTIONS-CLIENT
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/comp_err.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1*
-%attr(755, root, root) %{_bindir}/comp_err
-%attr(755, root, root) %{_bindir}/mysql_config
-%dir %attr(755, root, root) %{_libdir}/mysql
-%{_includedir}/mysql
-%{_libdir}/mysql/libdbug.a
-%{_libdir}/mysql/libheap.a
-%{_libdir}/mysql/libmy*.a
-%{_libdir}/mysql/libmy*.la
-%{_libdir}/mysql/libvio.a
-%{_libdir}/mysql/libz*
-
-%files -n MySQL-shared%{server_suffix}
-%defattr(-, root, root, 0755)
-# Shared libraries (omit for architectures that don't support them)
-%{_libdir}/*.so*
-
-
-%files -n MySQL-test%{server_suffix}
-%defattr(-, root, root, 0755)
-%{_datadir}/mysql-test
-%attr(755, root, root) %{_bindir}/mysql_client_test
-%attr(755, root, root) %{_bindir}/mysqltestmanager
-%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen
-%attr(755, root, root) %{_bindir}/mysqltestmanagerc
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
-
-# The spec file changelog only includes changes made to the spec file
-# itself - note that they must be ordered by date (important when
-# merging BK trees)
-%changelog
-* Mon Jul 07 2008 Jonathan Perkin <jperkin@sun.com>
-
-- Add 'classic' product.
-
-* Wed Jun 11 2008 Kent Boortz <kent@mysql.com>
-
-- Removed the Example storage engine, it is not to be in products
-
-* Mon Feb 18 2008 Timothy Smith <tim@mysql.com>
-
-- Require a manual upgrade if the alread-installed mysql-server is
- from another vendor, or is of a different major version.
-
-* Fri Dec 14 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the "%doc" directive for all man pages and other documentation;
- also, some re-ordering to reduce differences between spec files.
-
-* Wed Oct 31 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Explicitly handle InnoDB using its own variable and "--with"/"--without"
- options, because the "configure" default is "yes".
-
-* Tue Jul 17 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the man page for "mysql-stress-test.pl" to the "test" RPM
- (consistency in fixing bug#21023, the script is handled by "Makefile.am")
-
-* Wed Jul 11 2007 Daniel Fischer <df@mysql.com>
-
-- Change the way broken SELinux policies on RHEL4 and CentOS 4
- are handled to be more likely to actually work
-
-* Thu Jun 05 2007 kent Boortz <kent@mysql.com>
-
-- Enabled the CSV engine in all builds
-
-* Thu May 3 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Spring cleanup
-
-* Thu Apr 19 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- If sbin/restorecon exists then run it
-
-* Wed Apr 18 2007 Kent Boortz <kent@mysql.com>
-
-- Packed unpacked files
-
- /usr/sbin/ndb_cpcd
- /usr/bin/mysql_upgrade_shell
- /usr/bin/innochecksum
- /usr/share/man/man1/ndb_cpcd.1.gz
- /usr/share/man/man1/innochecksum.1.gz
- /usr/share/man/man1/mysql_fix_extensions.1.gz
- /usr/share/man/man1/mysql_secure_installation.1.gz
- /usr/share/man/man1/mysql_tableinfo.1.gz
- /usr/share/man/man1/mysql_waitpid.1.gz
-
-- Commands currently not installed but that has man pages
-
- /usr/share/man/man1/make_win_bin_dist.1.gz
- /usr/share/man/man1/make_win_src_distribution.1.gz
- /usr/share/man/man1/mysql-stress-test.pl.1.gz
- /usr/share/man/man1/ndb_print_backup_file.1.gz
- /usr/share/man/man1/ndb_print_schema_file.1.gz
- /usr/share/man/man1/ndb_print_sys_file.1.gz
-
-* Thu Mar 22 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add "comment" options to the test runs, for better log analysis.
-
-* Wed Mar 21 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add even more man pages.
-
-* Fri Mar 16 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Build the server twice, once as "mysqld-debug" and once as "mysqld";
- test them both, and include them in the resulting file.
-- Consequences of the fix for bug#20166:
- Remove "mysql_create_system_tables",
- new "mysql_fix_privilege_tables.sql" is included implicitly.
-
-* Wed Mar 14 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options some more and change naming of community
- cluster RPMs to explicitly say 'cluster'.
-
-* Mon Mar 12 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options and other settings for 5.0 community builds.
-
-* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add several man pages which are now created.
-
-* Mon Jan 29 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Make sure SELinux works correctly. Files from Colin Charles.
-
-* Fri Jan 05 2007 Kent Boortz <kent@mysql.com>
-
-- Add CFLAGS to gcc call with --print-libgcc-file, to make sure the
- correct "libgcc.a" path is returned for the 32/64 bit architecture.
-
-* Tue Dec 19 2006 Joerg Bruehe <joerg@mysql.com>
-
-- The man page for "mysqld" is now in section 8.
-
-* Thu Dec 14 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Include the new man pages for "my_print_defaults" and "mysql_tzinfo_to_sql"
- in the server RPM.
-- The "mysqlmanager" man page was relocated to section 8, reflect that.
-
-* Fri Nov 17 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Really fix obsoletes/provides for community -> this
-- Make it possible to not run test by setting
- MYSQL_RPMBUILD_TEST to "no"
-
-* Wed Nov 15 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Switch from "make test*" to explicit calls of the test suite,
- so that "report features" can be used.
-
-* Wed Nov 15 2006 Kent Boortz <kent@mysql.com>
-
-- Added "--with cluster" and "--define cluster{_gpl}"
-
-* Tue Oct 24 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Shared need to Provide/Obsolete mysql-shared
-
-* Mon Oct 23 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Run sbin/restorecon after db init (Bug#12676)
-
-* Thu Jul 06 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Correct a typing error in my previous change.
-
-* Tue Jul 04 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Use the Perl script to run the tests, because it will automatically check
- whether the server is configured with SSL.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Revert all previous attempts to call "mysql_upgrade" during RPM upgrade,
- there are some more aspects which need to be solved before this is possible.
- For now, just ensure the binary "mysql_upgrade" is delivered and installed.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Move "mysqldumpslow" from the client RPM to the server RPM (bug#20216).
-
-* Wed Jun 21 2006 Joerg Bruehe <joerg@mysql.com>
-
-- To run "mysql_upgrade", we need a running server;
- start it in isolation and skip password checks.
-
-* Sat May 23 2006 Kent Boortz <kent@mysql.com>
-
-- Always compile for PIC, position independent code.
-
-* Fri Apr 28 2006 Kent Boortz <kent@mysql.com>
-
-- Install and run "mysql_upgrade"
-
-* Sat Apr 01 2006 Kent Boortz <kent@mysql.com>
-
-- Allow to override $LDFLAGS
-
-* Fri Jan 06 2006 Lenz Grimmer <lenz@mysql.com>
-
-- added a MySQL-test subpackage (BUG#16070)
-
-* Tue Dec 27 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Some minor alignment with the 4.1 version
-
-* Wed Dec 14 2005 Rodrigo Novo <rodrigo@mysql.com>
-
-- Cosmetic changes: source code location & rpm packager
-- Protect "nm -D" against libtool weirdness
-- Add libz.a & libz.la to the list of files for subpackage -devel
-- moved --with-zlib-dir=bundled out of BuildMySQL, as it doesn't makes
- sense for the shared package
-
-* Tue Nov 22 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Extend the file existence check for "init.d/mysql" on un-install
- to also guard the call to "insserv"/"chkconfig".
-
-* Wed Nov 16 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_client_test to the "client" subpackage (BUG#14546)
-
-* Tue Nov 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- changed default definitions to build a standard GPL release when not
- defining anything else
-- install the shared libs more elegantly by using "make install"
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Made yaSSL support an option (off by default)
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Enabled yaSSL support
-
-* Thu Oct 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added a usermod call to assign a potential existing mysql user to the
- correct user group (BUG#12823)
-- added a separate macro "mysqld_group" to be able to define the
- user group of the mysql user seperately, if desired.
-
-* Fri Oct 1 2005 Kent Boortz <kent@mysql.com>
-
-- Copy the config.log file to location outside
- the build tree
-
-* Fri Sep 30 2005 Lenz Grimmer <lenz@mysql.com>
-
-- don't use install-strip to install the binaries (strip segfaults on
- icc-compiled binaries on IA64)
-
-* Thu Sep 22 2005 Lenz Grimmer <lenz@mysql.com>
-
-- allow overriding the CFLAGS (needed for Intel icc compiles)
-- replace the CPPFLAGS=-DBIG_TABLES with "--with-big-tables" configure option
-
-* Fri Aug 19 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Protect against failing tests.
-
-* Thu Aug 04 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the creation of the mysql user group account in the postinstall
- section (BUG 12348)
-
-* Fri Jul 29 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed external RPM Requirements to better suit the target distribution
- (BUG 12233)
-
-* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- create a "mysql" user group and assign the mysql user account to that group
- in the server postinstall section. (BUG 10984)
-
-* Wed Jun 01 2005 Lenz Grimmer <lenz@mysql.com>
-
-- use "mysqldatadir" variable instead of hard-coding the path multiple times
-- use the "mysqld_user" variable on all occasions a user name is referenced
-- removed (incomplete) Brazilian translations
-- removed redundant release tags from the subpackage descriptions
-
-* Fri May 27 2005 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file list (removed libnisam.a and libmerge.a from the devel subpackage)
-- force running the test suite
-
-* Wed Apr 20 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Enabled the "blackhole" storage engine for the Max RPM
-
-* Wed Apr 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- removed the MySQL manual files (html/ps/texi) - they have been removed
- from the MySQL sources and are now available seperately.
-
-* Mon Apr 4 2005 Petr Chardin <petr@mysql.com>
-
-- old mysqlmanager, mysqlmanagerc and mysqlmanager-pwger renamed into
- mysqltestmanager, mysqltestmanager and mysqltestmanager-pwgen respectively
-
-* Fri Mar 18 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Disabled RAID in the Max binaries once and for all (it has finally been
- removed from the source tree)
-
-* Sun Feb 20 2005 Petr Chardin <petr@mysql.com>
-
-- Install MySQL Instance Manager together with mysqld, touch mysqlmanager
- password file
-
-* Mon Feb 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the compilation comments and moved them into the separate build sections
- for Max and Standard
-
-* Mon Feb 7 2005 Tomas Ulin <tomas@mysql.com>
-
-- enabled the "Ndbcluster" storage engine for the max binary
-- added extra make install in ndb subdir after Max build to get ndb binaries
-- added packages for ndbcluster storage engine
-
-* Fri Jan 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- replaced obsoleted "BuildPrereq" with "BuildRequires" instead
-
-* Thu Jan 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Federated" storage engine for the max binary
-
-* Tue Jan 04 2005 Petr Chardin <petr@mysql.com>
-
-- ISAM and merge storage engines were purged. As well as appropriate
- tools and manpages (isamchk and isamlog)
-
-* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Archive" storage engine for the max binary
-- enabled the "CSV" storage engine for the max binary
-- enabled the "Example" storage engine for the max binary
-
-* Thu Aug 26 2004 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860)
-
-* Fri Aug 20 2004 Lenz Grimmer <lenz@mysql.com>
-
-- do not link statically on IA64/AMD64 as these systems do not have
- a patched glibc installed
-
-* Tue Aug 10 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added libmygcc.a to the devel subpackage (required to link applications
- against the the embedded server libmysqld.a) (BUG 4921)
-
-* Mon Aug 09 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added EXCEPTIONS-CLIENT to the "devel" package
-
-* Thu Jul 29 2004 Lenz Grimmer <lenz@mysql.com>
-
-- disabled OpenSSL in the Max binaries again (the RPM packages were the
- only exception to this anyway) (BUG 1043)
-
-* Wed Jun 30 2004 Lenz Grimmer <lenz@mysql.com>
-
-- fixed server postinstall (mysql_install_db was called with the wrong
- parameter)
-
-* Thu Jun 24 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_tzinfo_to_sql to the server subpackage
-- run "make clean" instead of "make distclean"
-
-* Mon Apr 05 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added ncurses-devel to the build prerequisites (BUG 3377)
-
-* Thu Feb 12 2004 Lenz Grimmer <lenz@mysql.com>
-
-- when using gcc, _always_ use CXX=gcc
-- replaced Copyright with License field (Copyright is obsolete)
-
-* Tue Feb 03 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added myisam_ftdump to the Server package
-
-* Tue Jan 13 2004 Lenz Grimmer <lenz@mysql.com>
-
-- link the mysql client against libreadline instead of libedit (BUG 2289)
-
-* Mon Dec 22 2003 Lenz Grimmer <lenz@mysql.com>
-
-- marked /etc/logrotate.d/mysql as a config file (BUG 2156)
-
-* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file permissions (BUG 1672)
-
-* Thu Dec 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- made testing for gcc3 a bit more robust
-
-* Fri Dec 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_create_system_tables to the server subpackage
-
-* Fri Nov 21 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed dependency on MySQL-client from the MySQL-devel subpackage
- as it is not really required. (BUG 1610)
-
-* Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 1162 (removed macro names from the changelog)
-- Really fixed BUG 998 (disable the checking for installed but
- unpackaged files)
-
-* Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 959 (libmysqld not being compiled properly)
-- Fixed BUG 998 (RPM build errors): added missing files to the
- distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
- mysql_fix_privilege_tables.1), removed "-n" from install section.
-
-* Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed the GIF Icon (file was not included in the sources anyway)
-- removed unused variable shared_lib_version
-- do not run automake before building the standard binary
- (should not be necessary)
-- add server suffix '-standard' to standard binary (to be in line
- with the binary tarball distributions)
-- Use more RPM macros (_exec_prefix, _sbindir, _libdir, _sysconfdir,
- _datadir, _includedir) throughout the spec file.
-- allow overriding CC and CXX (required when building with other compilers)
-
-* Fri May 16 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-enabled RAID again
-
-* Wed Apr 30 2003 Lenz Grimmer <lenz@mysql.com>
-
-- disabled MyISAM RAID (--with-raid) - it throws an assertion which
- needs to be investigated first.
-
-* Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_secure_installation to server subpackage
- (BUG 141)
-
-* Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-added missing pre- and post(un)install scripts to server subpackage
-- added config file /etc/my.cnf to the file list (just for completeness)
-- make sure to create the datadir with 755 permissions
-
-* Mon Jan 27 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed unused CC and CXX variables
-- CFLAGS and CXXFLAGS should honor RPM_OPT_FLAGS
-
-* Fri Jan 24 2003 Lenz Grimmer <lenz@mysql.com>
-
-- renamed package "MySQL" to "MySQL-server"
-- fixed Copyright tag
-- added mysql_waitpid to client subpackage (required for mysql-test-run)
-
-* Wed Nov 27 2002 Lenz Grimmer <lenz@mysql.com>
-
-- moved init script from /etc/rc.d/init.d to /etc/init.d (the majority of
- Linux distributions now support this scheme as proposed by the LSB either
- directly or via a compatibility symlink)
-- Use new "restart" init script action instead of starting and stopping
- separately
-- Be more flexible in activating the automatic bootup - use insserv (on
- older SuSE versions) or chkconfig (Red Hat, newer SuSE versions and
- others) to create the respective symlinks
-
-* Wed Sep 25 2002 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL >= 4.0 to avoid version mismatches
- (mixing 3.23 and 4.0 packages)
-
-* Fri Aug 09 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Turn off OpenSSL in MySQL-Max for now until it works properly again
-- enable RAID for the Max binary instead
-- added compatibility link: safe_mysqld -> mysqld_safe to ease the
- transition from 3.23
-
-* Thu Jul 18 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Reworked the build steps a little bit: the Max binary is supposed
- to include OpenSSL, which cannot be linked statically, thus trying
- to statically link against a special glibc is futile anyway
-- because of this, it is not required to make yet another build run
- just to compile the shared libs (saves a lot of time)
-- updated package description of the Max subpackage
-- clean up the BuildRoot directory afterwards
-
-* Mon Jul 15 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Updated Packager information
-- Fixed the build options: the regular package is supposed to
- include InnoDB and linked statically, while the Max package
- should include BDB and SSL support
-
-* Fri May 03 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Use more RPM macros (e.g. infodir, mandir) to make the spec
- file more portable
-- reorganized the installation of documentation files: let RPM
- take care of this
-- reorganized the file list: actually install man pages along
- with the binaries of the respective subpackage
-- do not include libmysqld.a in the devel subpackage as well, if we
- have a special "embedded" subpackage
-- reworked the package descriptions
-
-* Mon Oct 8 2001 Monty
-
-- Added embedded server as a separate RPM
-
-* Fri Apr 13 2001 Monty
-
-- Added mysqld-max to the distribution
-
-* Tue Jan 2 2001 Monty
-
-- Added mysql-test to the bench package
-
-* Fri Aug 18 2000 Tim Smith <tim@mysql.com>
-
-- Added separate libmysql_r directory; now both a threaded
- and non-threaded library is shipped.
-
-* Wed Sep 28 1999 David Axmark <davida@mysql.com>
-
-- Added the support-files/my-example.cnf to the docs directory.
-
-- Removed devel dependency on base since it is about client
- development.
-
-* Wed Sep 8 1999 David Axmark <davida@mysql.com>
-
-- Cleaned up some for 3.23.
-
-* Thu Jul 1 1999 David Axmark <davida@mysql.com>
-
-- Added support for shared libraries in a separate sub
- package. Original fix by David Fox (dsfox@cogsci.ucsd.edu)
-
-- The --enable-assembler switch is now automatically disables on
- platforms there assembler code is unavailable. This should allow
- building this RPM on non i386 systems.
-
-* Mon Feb 22 1999 David Axmark <david@detron.se>
-
-- Removed unportable cc switches from the spec file. The defaults can
- now be overridden with environment variables. This feature is used
- to compile the official RPM with optimal (but compiler version
- specific) switches.
-
-- Removed the repetitive description parts for the sub rpms. Maybe add
- again if RPM gets a multiline macro capability.
-
-- Added support for a pt_BR translation. Translation contributed by
- Jorge Godoy <jorge@bestway.com.br>.
-
-* Wed Nov 4 1998 David Axmark <david@detron.se>
-
-- A lot of changes in all the rpm and install scripts. This may even
- be a working RPM :-)
-
-* Sun Aug 16 1998 David Axmark <david@detron.se>
-
-- A developers changelog for MySQL is available in the source RPM. And
- there is a history of major user visible changed in the Reference
- Manual. Only RPM specific changes will be documented here.
diff --git a/percona/5.0.75-b12/mysqld_safe_syslog.patch b/percona/5.0.75-b12/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.75-b12/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.75-b12/series b/percona/5.0.75-b12/series
deleted file mode 100644
index 8332124..0000000
--- a/percona/5.0.75-b12/series
+++ /dev/null
@@ -1,15 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-#mirror_binlog.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_show_hashed_memory.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-split_buf_pool_mutex_fixed_optimistic_safe.patch
-innodb_rw_lock.patch
diff --git a/percona/5.0.75-b12/show_patches.patch b/percona/5.0.75-b12/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.75-b12/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.75-b12/split_buf_pool_mutex_fixed_optimistic_safe.patch b/percona/5.0.75-b12/split_buf_pool_mutex_fixed_optimistic_safe.patch
deleted file mode 100644
index 016d667..0000000
--- a/percona/5.0.75-b12/split_buf_pool_mutex_fixed_optimistic_safe.patch
+++ /dev/null
@@ -1,1305 +0,0 @@
-diff -r 2e0c46e78b50 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:33:59 2008 -0800
-@@ -548,6 +548,19 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_create(&(buf_pool->free_mutex));
-+ mutex_create(&(buf_pool->hash_mutex));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->hash_mutex), SYNC_NO_ORDER_CHECK);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -723,6 +736,10 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -859,12 +876,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->LRU_mutex));
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
- }
-
-@@ -880,7 +897,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -888,7 +905,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -899,7 +916,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -909,7 +926,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- }
-
- /*************************************************************************
-@@ -950,11 +967,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(block);
- }
-@@ -971,7 +988,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -979,7 +996,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
- }
-
- /************************************************************************
-@@ -998,7 +1015,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1008,7 +1025,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(is_hashed);
- }
-@@ -1050,7 +1067,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1058,7 +1075,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(block);
- }
-@@ -1079,7 +1096,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1087,7 +1104,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(block);
- }
-@@ -1166,26 +1183,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ // mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ mutex_enter_fast(&(buf_pool->hash_mutex));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ mutex_exit(&(buf_pool->hash_mutex));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1204,7 +1228,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ // mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1216,7 +1240,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1233,7 +1257,9 @@
- LRU list and we must put it to awe_LRU_free_mapped list once
- mapped to a frame */
-
-+ mutex_enter_fast(&(buf_pool->mutex));
- buf_awe_map_page_to_frame(block, TRUE);
-+ mutex_exit(&buf_pool->mutex);
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -1241,7 +1267,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1791,7 +1817,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1806,7 +1833,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- buf_block_free(block);
-
-@@ -1821,10 +1849,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1873,7 +1905,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1884,7 +1917,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- buf_block_free(free_block);
-
-@@ -1907,6 +1941,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1918,7 +1953,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1932,7 +1967,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1968,6 +2003,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2050,9 +2086,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2061,9 +2094,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2094,6 +2130,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2102,10 +2140,25 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-+
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
-@@ -2131,6 +2184,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2138,9 +2194,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2168,11 +2221,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2191,10 +2244,22 @@
- ulint n_flush = 0;
- ulint n_free = 0;
- ulint n_page = 0;
-+ ulint n_single_flush_tmp = 0;
-+ ulint n_lru_flush_tmp = 0;
-+ ulint n_list_flush_tmp = 0;
-
- ut_ad(buf_pool);
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-+
- mutex_enter(&(buf_pool->mutex));
-+ n_single_flush_tmp = buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE];
-+ n_list_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LIST];
-+ n_lru_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LRU];
-+ mutex_exit(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2262,11 +2327,14 @@
- }
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
-- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+ ut_a(n_single_flush_tmp == n_single_flush);
-+ ut_a(n_list_flush_tmp == n_list_flush);
-+ ut_a(n_lru_flush_tmp == n_lru_flush);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2298,7 +2366,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2351,7 +2421,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2386,8 +2458,6 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2403,7 +2473,6 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2431,7 +2500,9 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2439,7 +2510,9 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ratio);
- }
-@@ -2459,6 +2532,9 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -2532,6 +2608,9 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
- }
-
-@@ -2562,8 +2641,6 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2584,8 +2661,6 @@
-
- mutex_exit(&block->mutex);
- }
--
-- mutex_exit(&(buf_pool->mutex));
-
- return(TRUE);
- }
-@@ -2625,11 +2700,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Dec 22 00:33:59 2008 -0800
-@@ -117,12 +117,14 @@
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* I permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -536,18 +538,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +748,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +782,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +793,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(count);
- }
-@@ -849,7 +853,14 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+
- for (;;) {
- /* If we have flushed enough, leave the loop */
- if (page_count >= min_n) {
-@@ -895,7 +906,10 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- old_page_count = page_count;
-
-@@ -908,7 +922,10 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -930,6 +947,13 @@
- break;
- }
- }
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex));
-
- (buf_pool->init_flush)[flush_type] = FALSE;
-
-@@ -989,10 +1013,14 @@
- buf_block_t* block;
- ulint n_replaceable;
- ulint distance = 0;
--
-- mutex_enter(&(buf_pool->mutex));
-+
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-+ //mutex_enter(&(buf_pool->free_mutex));
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-+
-+ //mutex_exit(&(buf_pool->free_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
-@@ -1014,7 +1042,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1033,8 +1061,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1044,7 +1073,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1094,11 +1123,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0lru.c Mon Dec 22 00:33:59 2008 -0800
-@@ -79,7 +79,10 @@
- ibool all_freed;
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-
- all_freed = TRUE;
-
-@@ -117,7 +120,10 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -147,7 +153,10 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -170,14 +179,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -186,7 +195,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -210,13 +219,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -231,9 +242,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ mutex_enter(&(buf_pool->hash_mutex));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ mutex_exit(&(buf_pool->hash_mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -246,14 +265,25 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
- freed = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ mutex_exit(&(buf_pool->hash_mutex));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -264,13 +294,21 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-+ mutex_exit(&(buf_pool->mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- return(FALSE);
- }
- }
-+ if (!freed) {
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -322,7 +360,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -330,7 +369,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -353,7 +393,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex)); /* LRU info:optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -437,7 +477,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -449,7 +489,7 @@
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -486,7 +526,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -958,7 +998,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1001,7 +1041,10 @@
-
- if (buf_pool->LRU_old) {
- ut_a(buf_pool->LRU_old_len == old_len);
-- }
-+ }
-+
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
-@@ -1013,7 +1056,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1029,7 +1072,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1073,5 +1116,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0rea.c Mon Dec 22 00:33:59 2008 -0800
-@@ -236,10 +236,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ mutex_enter(&(buf_pool->hash_mutex));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -250,8 +252,9 @@
- recent_blocks++;
- }
- }
-+ mutex_exit(&(buf_pool->hash_mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -347,7 +350,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -450,6 +453,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -463,6 +467,7 @@
-
- fail_count = 0;
-
-+ mutex_enter(&(buf_pool->hash_mutex));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -479,12 +484,13 @@
- pred_block = block;
- }
- }
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -492,10 +498,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ mutex_enter(&(buf_pool->hash_mutex));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- return(0);
- }
-@@ -511,7 +518,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -587,7 +594,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -655,7 +662,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -727,7 +734,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r 2e0c46e78b50 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Dec 22 00:33:59 2008 -0800
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ mutex_t hash_mutex;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r 2e0c46e78b50 innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -112,7 +112,7 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -122,7 +122,7 @@
- lsn = block->oldest_modification;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -392,18 +392,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +425,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +433,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -632,9 +632,9 @@
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->flush_list_mutex);
- buf_flush_note_modification(block, mtr);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->flush_list_mutex);
- }
-
- mutex_enter(&block->mutex);
-diff -r 2e0c46e78b50 innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.h Mon Dec 22 00:33:59 2008 -0800
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r 2e0c46e78b50 innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -84,7 +84,7 @@
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
-@@ -102,5 +102,5 @@
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-diff -r 2e0c46e78b50 innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/log/log0recv.c Mon Dec 22 00:33:59 2008 -0800
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->hash_mutex));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->hash_mutex));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r 2e0c46e78b50 patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info Mon Dec 22 00:33:59 2008 -0800
-@@ -0,0 +1,6 @@
-+File=split_buf_pool_mutex_fixed_optimistic_safe.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.75-b12/userstatv2.patch b/percona/5.0.75-b12/userstatv2.patch
deleted file mode 100644
index de796c0..0000000
--- a/percona/5.0.75-b12/userstatv2.patch
+++ /dev/null
@@ -1,4463 +0,0 @@
-diff -r 1270c564d514 BUILD/Makefile.in
---- a/BUILD/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/BUILD/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -169,6 +169,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 Docs/Makefile.in
---- a/Docs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/Docs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 Makefile.in
---- a/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -191,6 +191,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 SSL/Makefile.in
---- a/SSL/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/SSL/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 aclocal.m4
---- a/aclocal.m4 Mon Dec 22 00:26:39 2008 -0800
-+++ b/aclocal.m4 Mon Dec 22 00:31:13 2008 -0800
-@@ -1597,7 +1597,7 @@
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
-- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
- fi
-
-@@ -4305,6 +4305,9 @@
- # Is the compiler the GNU C compiler?
- with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-+gcc_ver=\`gcc -dumpversion\`
-+
- # An ERE matcher.
- EGREP=$lt_EGREP
-
-@@ -4438,11 +4441,11 @@
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
--predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-+predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place after the objects being linked to create a
- # shared library.
--postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-+postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
-@@ -4454,7 +4457,7 @@
-
- # The library search path used internally by the compiler when linking
- # a shared library.
--compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-+compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Method to check whether dependent libraries are shared objects.
- deplibs_check_method=$lt_deplibs_check_method
-@@ -4534,7 +4537,7 @@
- link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
- # Compile-time system search path for libraries
--sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Run-time system search path for libraries
- sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-@@ -6370,6 +6373,7 @@
- done
- done
- done
-+IFS=$as_save_IFS
- lt_ac_max=0
- lt_ac_count=0
- # Add /usr/xpg4/bin/sed as it is typically found on Solaris
-@@ -6402,6 +6406,7 @@
- done
- ])
- SED=$lt_cv_path_SED
-+AC_SUBST([SED])
- AC_MSG_RESULT([$SED])
- ])
-
-diff -r 1270c564d514 client/Makefile.in
---- a/client/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/client/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -268,6 +268,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/cmd-line-utils/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -177,6 +177,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/cmd-line-utils/libedit/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/cmd-line-utils/readline/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -195,6 +195,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 configure
---- a/configure Mon Dec 22 00:26:39 2008 -0800
-+++ b/configure Mon Dec 22 00:31:13 2008 -0800
-@@ -477,7 +477,7 @@
- #endif"
-
- ac_subdirs_all="$ac_subdirs_all innobase"
--ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MYSQL_NO_DASH_VERSION MYSQL_BASE_VERSION MYSQL_VERSION_ID MYSQL_PREVIOUS_BASE_VERSION PROTOCOL_VERSION DOT_FRM_VERSION SHARED_LIB_MAJOR_VERSION SHARED_LIB_VERSION NDB_SHARED_LIB_MAJOR_VERSION NDB_SHARED_LIB_VERSION AVAILABLE_LANGUAGES NDB_VERSION_MAJOR NDB_VERSION_MINOR NDB_VERSION_BUILD NDB_VERSION_STATUS SYSTEM_TYPE MACHINE_TYPE CONF_COMMAND SAVE_CC SAVE_CXX SAVE_ASFLAGS SAVE_CFLAGS SAVE_CXXFLAGS SAVE_LDFLAGS SAVE_CXXLDFLAGS CXXLDFLAGS AR RANLIB DARWIN_MWCC_TRUE DARWIN_MWCC_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CPP CC_VERSION CXX_VERSION AS ac_ct_RANLIB EGREP LN_S ECHO ac_ct_AR CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NM YACC PDFMANUAL DVIS uname_prog ASFLAGS LD ARFLAGS LD_VERSION_SCRIPT MYSQLD_DEFAULT_SWITCHES TARGET_LINUX LN LN_CP_F MV RM CP SED CMP CHMOD HOSTNAME TAR PERL PERL5 DOXYGEN PDFLATEX MAKEINDEX ICHECK PS FIND_PROC KILL CHECK_PID CCAS CCASFLAGS NOINST_LDFLAGS MYSQL_SERVER_SUFFIX ASSEMBLER_x86_TRUE ASSEMBLER_x86_FALSE ASSEMBLER_sparc32_TRUE ASSEMBLER_sparc32_FALSE ASSEMBLER_sparc64_TRUE ASSEMBLER_sparc64_FALSE ASSEMBLER_TRUE ASSEMBLER_FALSE MYSQL_UNIX_ADDR MYSQL_TCP_PORT MYSQL_TCP_PORT_DEFAULT MYSQLD_USER GETCONF ac_ct_GETCONF zlib_dir ZLIB_LIBS ZLIB_DEPS ZLIB_INCLUDES WRAPLIBS pstack_dirs pstack_libs COMPILE_PSTACK_TRUE COMPILE_PSTACK_FALSE LIBDL MYSQLD_EXTRA_LDFLAGS CLIENT_EXTRA_LDFLAGS MYSQLD_EXTRA_LIBS LIB_EXTRA_CCFLAGS LM_CFLAGS COMPILATION_COMMENT ALLOCA MAKE_SHELL TERMCAP_LIB LIBEDIT_LOBJECTS tools_dirs openssl_libs openssl_includes yassl_taocrypt_extra_cxxflags yassl_h_ln_cmd yassl_libs yassl_dir HAVE_YASSL_TRUE HAVE_YASSL_FALSE libmysqld_dirs linked_libmysqld_targets docs_dirs extra_docs bench_dirs readline_dir readline_topdir readline_basedir readline_link readline_h_ln_cmd bdb_includes bdb_libs bdb_libs_with_path innodb_includes innodb_libs innodb_system_libs NDB_SCI_INCLUDES NDB_SCI_LIBS NDB_LD_VERSION_SCRIPT HAVE_NDBCLUSTER_DB_TRUE HAVE_NDBCLUSTER_DB_FALSE ndbcluster_includes ndbcluster_libs ndbcluster_system_libs ndb_mgmclient_libs man_dirs man1_files man8_files CLIENT_LIBS NON_THREADED_LIBS STATIC_NSS_FLAGS sql_client_dirs linked_client_targets netware_dir linked_netware_sources HAVE_NETWARE_TRUE HAVE_NETWARE_FALSE THREAD_LOBJECTS BUILD_INNODB_TOOLS_TRUE BUILD_INNODB_TOOLS_FALSE subdirs sql_server_dirs thread_dirs server_scripts sql_union_dirs GXX NDB_DEFS ndb_cxxflags_fix ndb_port ndb_transporter_opt_objs ndb_bin_am_ldflags ndb_opt_subdirs NDB_SIZEOF_CHARP NDB_SIZEOF_CHAR NDB_SIZEOF_SHORT NDB_SIZEOF_INT NDB_SIZEOF_LONG NDB_SIZEOF_LONG_LONG MAKE_BINARY_DISTRIBUTION_OPTIONS LIBOBJS LTLIBOBJS'
-+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MYSQL_NO_DASH_VERSION MYSQL_BASE_VERSION MYSQL_VERSION_ID MYSQL_PREVIOUS_BASE_VERSION PROTOCOL_VERSION DOT_FRM_VERSION SHARED_LIB_MAJOR_VERSION SHARED_LIB_VERSION NDB_SHARED_LIB_MAJOR_VERSION NDB_SHARED_LIB_VERSION AVAILABLE_LANGUAGES NDB_VERSION_MAJOR NDB_VERSION_MINOR NDB_VERSION_BUILD NDB_VERSION_STATUS SYSTEM_TYPE MACHINE_TYPE CONF_COMMAND SAVE_CC SAVE_CXX SAVE_ASFLAGS SAVE_CFLAGS SAVE_CXXFLAGS SAVE_LDFLAGS SAVE_CXXLDFLAGS CXXLDFLAGS AR RANLIB DARWIN_MWCC_TRUE DARWIN_MWCC_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CPP CC_VERSION CXX_VERSION AS ac_ct_RANLIB SED EGREP LN_S ECHO ac_ct_AR CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL NM YACC PDFMANUAL DVIS uname_prog ASFLAGS LD ARFLAGS LD_VERSION_SCRIPT MYSQLD_DEFAULT_SWITCHES TARGET_LINUX LN LN_CP_F MV RM CP SED CMP CHMOD HOSTNAME TAR PERL PERL5 DOXYGEN PDFLATEX MAKEINDEX ICHECK PS FIND_PROC KILL CHECK_PID CCAS CCASFLAGS NOINST_LDFLAGS MYSQL_SERVER_SUFFIX ASSEMBLER_x86_TRUE ASSEMBLER_x86_FALSE ASSEMBLER_sparc32_TRUE ASSEMBLER_sparc32_FALSE ASSEMBLER_sparc64_TRUE ASSEMBLER_sparc64_FALSE ASSEMBLER_TRUE ASSEMBLER_FALSE MYSQL_UNIX_ADDR MYSQL_TCP_PORT MYSQL_TCP_PORT_DEFAULT MYSQLD_USER GETCONF ac_ct_GETCONF zlib_dir ZLIB_LIBS ZLIB_DEPS ZLIB_INCLUDES WRAPLIBS pstack_dirs pstack_libs COMPILE_PSTACK_TRUE COMPILE_PSTACK_FALSE LIBDL MYSQLD_EXTRA_LDFLAGS CLIENT_EXTRA_LDFLAGS MYSQLD_EXTRA_LIBS LIB_EXTRA_CCFLAGS LM_CFLAGS COMPILATION_COMMENT ALLOCA MAKE_SHELL TERMCAP_LIB LIBEDIT_LOBJECTS tools_dirs openssl_libs openssl_includes yassl_taocrypt_extra_cxxflags yassl_h_ln_cmd yassl_libs yassl_dir HAVE_YASSL_TRUE HAVE_YASSL_FALSE libmysqld_dirs linked_libmysqld_targets docs_dirs extra_docs bench_dirs readline_dir readline_topdir readline_basedir readline_link readline_h_ln_cmd bdb_includes bdb_libs bdb_libs_with_path innodb_includes innodb_libs innodb_system_libs NDB_SCI_INCLUDES NDB_SCI_LIBS NDB_LD_VERSION_SCRIPT HAVE_NDBCLUSTER_DB_TRUE HAVE_NDBCLUSTER_DB_FALSE ndbcluster_includes ndbcluster_libs ndbcluster_system_libs ndb_mgmclient_libs man_dirs man1_files man8_files CLIENT_LIBS NON_THREADED_LIBS STATIC_NSS_FLAGS sql_client_dirs linked_client_targets netware_dir linked_netware_sources HAVE_NETWARE_TRUE HAVE_NETWARE_FALSE THREAD_LOBJECTS BUILD_INNODB_TOOLS_TRUE BUILD_INNODB_TOOLS_FALSE subdirs sql_server_dirs thread_dirs server_scripts sql_union_dirs GXX NDB_DEFS ndb_cxxflags_fix ndb_port ndb_transporter_opt_objs ndb_bin_am_ldflags ndb_opt_subdirs NDB_SIZEOF_CHARP NDB_SIZEOF_CHAR NDB_SIZEOF_SHORT NDB_SIZEOF_INT NDB_SIZEOF_LONG NDB_SIZEOF_LONG_LONG MAKE_BINARY_DISTRIBUTION_OPTIONS LIBOBJS LTLIBOBJS'
- ac_subst_files=''
-
- # Initialize some variables set by options.
-@@ -38236,7 +38236,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -41644,7 +41728,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-@@ -42984,6 +43068,7 @@
- s,@MAKE_SHELL@,$MAKE_SHELL,;t t
- s,@TERMCAP_LIB@,$TERMCAP_LIB,;t t
- s,@LIBEDIT_LOBJECTS@,$LIBEDIT_LOBJECTS,;t t
-+s,@LIBRT@,$LIBRT,;t t
- s,@tools_dirs@,$tools_dirs,;t t
- s,@openssl_libs@,$openssl_libs,;t t
- s,@openssl_includes@,$openssl_includes,;t t
-diff -r 1270c564d514 configure.in
---- a/configure.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/configure.in Mon Dec 22 00:31:13 2008 -0800
-@@ -2098,7 +2098,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2713,7 +2724,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 1270c564d514 dbug/Makefile.in
---- a/dbug/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/dbug/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -214,6 +214,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/Makefile.in
---- a/extra/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -259,6 +259,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -162,6 +162,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/taocrypt/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -162,6 +162,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -172,6 +172,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -182,6 +182,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -172,6 +172,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/extra/yassl/testsuite/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -175,6 +175,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 heap/Makefile.in
---- a/heap/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/heap/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 include/Makefile.in
---- a/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 include/mysql_com.h
---- a/include/mysql_com.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/include/mysql_com.h Mon Dec 22 00:31:13 2008 -0800
-@@ -106,6 +106,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 1270c564d514 libmysql/Makefile.in
---- a/libmysql/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/libmysql/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -278,6 +278,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/libmysql_r/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -275,6 +275,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/libmysqld/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -264,6 +264,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/libmysqld/examples/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 man/Makefile.in
---- a/man/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/man/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 myisam/Makefile.in
---- a/myisam/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/myisam/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -257,6 +257,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/myisammrg/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysql-test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -181,6 +181,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysql-test/ndb/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -170,6 +170,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Dec 22 00:31:13 2008 -0800
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- show global status like "Uptime_%";
- Variable_name Value
-diff -r 1270c564d514 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Dec 22 00:31:13 2008 -0800
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 1270c564d514 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Dec 22 00:31:13 2008 -0800
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 1270c564d514 mysys/Makefile.in
---- a/mysys/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/mysys/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -249,6 +249,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/Makefile.in
---- a/ndb/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -191,6 +191,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/docs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -172,6 +172,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -220,6 +220,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/debugger/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -225,6 +225,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -233,6 +233,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/logger/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -219,6 +219,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -233,6 +233,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/portlib/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/transporter/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -219,6 +219,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/common/util/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/cw/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -226,6 +226,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -225,6 +225,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -226,6 +226,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -226,6 +226,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -219,6 +219,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -219,6 +219,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -218,6 +218,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/error/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/kernel/vm/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -229,6 +229,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/mgmapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -226,6 +226,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/mgmclient/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -236,6 +236,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/mgmsrv/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -232,6 +232,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/src/ndbapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -236,6 +236,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/ndbapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -613,6 +613,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -305,6 +305,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/run-test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -264,6 +264,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -234,6 +234,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/test/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -347,6 +347,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/ndb/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -333,6 +333,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 netware/Makefile.in
---- a/netware/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/netware/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 os2/Makefile.in
---- a/os2/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/os2/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 os2/include/Makefile.in
---- a/os2/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/os2/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/os2/include/sys/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Mon Dec 22 00:31:13 2008 -0800
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 1270c564d514 pstack/Makefile.in
---- a/pstack/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/pstack/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/pstack/aout/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 regex/Makefile.in
---- a/regex/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/regex/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 scripts/Makefile.in
---- a/scripts/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/scripts/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -198,6 +198,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 server-tools/Makefile.in
---- a/server-tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/server-tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -175,6 +175,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/server-tools/instance-manager/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -223,6 +223,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -285,6 +285,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -3316,6 +3316,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3588,6 +3590,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3635,6 +3639,8 @@
- innodb_srv_conc_enter_innodb(prebuilt->trx);
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-+
-+ if (error == DB_SUCCESS) rows_changed++;
-
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
-@@ -4068,6 +4074,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 1270c564d514 sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/ha_myisam.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1518,13 +1520,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1535,6 +1541,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1545,6 +1558,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1555,6 +1575,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1565,6 +1592,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1575,6 +1609,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1585,6 +1626,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1595,6 +1643,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1611,6 +1666,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1628,6 +1690,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1642,6 +1705,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 1270c564d514 sql/handler.cc
---- a/sql/handler.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/handler.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -725,6 +725,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -829,6 +831,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- if (all)
- thd->transaction_rollback_request= FALSE;
-@@ -1212,6 +1215,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1442,6 +1446,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2276,6 +2282,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 1270c564d514 sql/handler.h
---- a/sql/handler.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/handler.h Mon Dec 22 00:31:13 2008 -0800
-@@ -30,6 +30,10 @@
- #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
- defined(HAVE_NDBCLUSTER_DB)
- #define USING_TRANSACTIONS
-+#endif
-+
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
- #endif
-
- // the following is for checking tables
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 1270c564d514 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:31:13 2008 -0800
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 1270c564d514 sql/log.cc
---- a/sql/log.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/log.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -1899,18 +1899,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1926,6 +1932,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1936,6 +1944,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2057,6 +2067,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2103,6 +2114,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2171,6 +2183,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2179,6 +2193,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 1270c564d514 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:31:13 2008 -0800
-@@ -818,7 +818,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1396,6 +1404,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1426,6 +1435,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1472,6 +1482,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 1270c564d514 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -414,6 +414,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -450,6 +451,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -550,6 +552,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1191,6 +1197,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1305,6 +1315,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3152,6 +3166,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3423,6 +3441,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3505,6 +3527,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4189,6 +4213,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5007,6 +5032,7 @@
- OPT_PROFILING,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6450,6 +6476,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 1270c564d514 sql/set_var.cc
---- a/sql/set_var.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/set_var.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -323,6 +323,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -825,6 +826,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1171,6 +1173,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 1270c564d514 sql/share/Makefile.in
---- a/sql/share/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/share/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 sql/sql_base.cc
---- a/sql/sql_base.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_base.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 1270c564d514 sql/sql_class.cc
---- a/sql/sql_class.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_class.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -236,6 +236,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -369,6 +376,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -408,6 +497,9 @@
-
- void THD::change_user(void)
- {
-+ pthread_mutex_lock(&LOCK_status);
-+ add_to_status(&global_status_var, &status_var);
-+ pthread_mutex_unlock(&LOCK_status);
- cleanup();
- cleanup_done= 0;
- init();
-@@ -892,6 +984,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1062,6 +1181,7 @@
- }
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1154,6 +1274,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2088,6 +2209,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2095,6 +2217,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 1270c564d514 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:31:13 2008 -0800
-@@ -1298,6 +1298,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1487,6 +1489,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1593,6 +1597,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1648,6 +1695,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1877,7 +1929,13 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-+
-+ char *get_client_host_port(THD *client);
-
- public:
- /**
-@@ -1921,6 +1979,11 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-+#define LIST_PROCESS_HOST_LEN 64
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 1270c564d514 sql/sql_delete.cc
---- a/sql/sql_delete.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_delete.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -869,6 +870,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 1270c564d514 sql/sql_insert.cc
---- a/sql/sql_insert.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_insert.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -989,6 +989,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3036,6 +3037,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 1270c564d514 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:31:13 2008 -0800
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 1270c564d514 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -145,6 +151,17 @@
- #ifndef EMBEDDED_LIBRARY
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-+
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1607,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1618,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1690,7 @@
- net->vio && net->error && net->report_error)
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1710,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2043,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2208,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4424,6 +4876,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4731,6 +5192,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5567,6 +6029,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5602,6 +6065,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5634,11 +6098,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5672,6 +6140,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5704,6 +6173,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5735,6 +6205,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5788,8 +6264,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5806,9 +6282,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6317,6 +6796,30 @@
- */
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
-@@ -6396,6 +6899,39 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error)
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7407,8 +7943,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 1270c564d514 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -80,6 +80,9 @@
- #else
- #include <mysql_com.h>
- #endif
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-
- /* A result class used to send cursor rows using the binary protocol. */
-
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,40 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error)
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2342,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #ifdef ENABLED_PROFILING
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2410,46 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error)
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2543,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2600,39 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error)
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2665,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2502,6 +2704,39 @@
- stmt->state= Query_arena::PREPARED;
-
- send_ok(thd);
-+
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error)
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-
- DBUG_VOID_RETURN;
- }
-diff -r 1270c564d514 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -530,6 +530,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1858,6 +1859,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4468,6 +4763,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4477,6 +4843,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4485,6 +4853,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4510,10 +4880,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 1270c564d514 sql/sql_update.cc
---- a/sql/sql_update.cc Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_update.cc Mon Dec 22 00:31:13 2008 -0800
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 1270c564d514 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:31:13 2008 -0800
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8244,6 +8249,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8448,9 +8485,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9439,6 +9481,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9491,6 +9534,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9600,6 +9644,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9616,6 +9661,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9636,6 +9682,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 1270c564d514 sql/structs.h
---- a/sql/structs.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/structs.h Mon Dec 22 00:31:13 2008 -0800
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[USERNAME_LENGTH + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[USERNAME_LENGTH + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 1270c564d514 sql/table.h
---- a/sql/table.h Mon Dec 22 00:26:39 2008 -0800
-+++ b/sql/table.h Mon Dec 22 00:31:13 2008 -0800
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 1270c564d514 strings/Makefile.in
---- a/strings/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/strings/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -361,6 +361,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/support-files/MacOSX/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 support-files/Makefile.in
---- a/support-files/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/support-files/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -191,6 +191,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -169,6 +169,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 tests/Makefile.in
---- a/tests/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/tests/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 tools/Makefile.in
---- a/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -189,6 +189,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 vio/Makefile.in
---- a/vio/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/vio/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -198,6 +198,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 win/Makefile.in
---- a/win/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/win/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1270c564d514 zlib/Makefile.in
---- a/zlib/Makefile.in Mon Dec 22 00:26:39 2008 -0800
-+++ b/zlib/Makefile.in Mon Dec 22 00:31:13 2008 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.77-b13/innodb_check_fragmentation.patch b/percona/5.0.77-b13/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.77-b13/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.77-b13/innodb_dict_size_limit.patch b/percona/5.0.77-b13/innodb_dict_size_limit.patch
deleted file mode 100644
index 8ef4e36..0000000
--- a/percona/5.0.77-b13/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,477 +0,0 @@
-diff -ru mysql-5.0.75_base/innobase/dict/dict0boot.c mysql-5.0.75/innobase/dict/dict0boot.c
---- mysql-5.0.75_base/innobase/dict/dict0boot.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0boot.c 2009-01-23 19:28:25.000000000 +0900
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0crea.c mysql-5.0.75/innobase/dict/dict0crea.c
---- mysql-5.0.75_base/innobase/dict/dict0crea.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0crea.c 2009-01-23 19:41:38.000000000 +0900
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1266,6 +1269,11 @@
-
- trx->op_info = "";
-
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0dict.c mysql-5.0.75/innobase/dict/dict0dict.c
---- mysql-5.0.75_base/innobase/dict/dict0dict.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0dict.c 2009-01-26 16:03:29.000000000 +0900
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -787,6 +791,8 @@
- table->n_mysql_handles_opened++;
- }
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-
-- ut_error;
-+ //ut_error;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1341,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-diff -ru mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c
---- mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c 2009-01-23 11:44:18.000000000 +0900
-+++ mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c 2009-01-23 19:22:54.000000000 +0900
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.h mysql-5.0.75/innobase/include/dict0dict.h
---- mysql-5.0.75_base/innobase/include/dict0dict.h 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.h 2009-01-23 21:46:22.000000000 +0900
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.ic mysql-5.0.75/innobase/include/dict0dict.ic
---- mysql-5.0.75_base/innobase/include/dict0dict.ic 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.ic 2009-01-23 18:35:55.000000000 +0900
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -ru mysql-5.0.75_base/innobase/include/srv0srv.h mysql-5.0.75/innobase/include/srv0srv.h
---- mysql-5.0.75_base/innobase/include/srv0srv.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/include/srv0srv.h 2009-01-27 10:47:26.000000000 +0900
-@@ -146,6 +146,8 @@
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-
-+extern ulint srv_dict_size_limit;
-+
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
- extern ulong srv_io_pattern_trace_running;
-@@ -545,6 +547,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -ru mysql-5.0.75_base/innobase/srv/srv0srv.c mysql-5.0.75/innobase/srv/srv0srv.c
---- mysql-5.0.75_base/innobase/srv/srv0srv.c 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/srv/srv0srv.c 2009-01-27 10:52:19.000000000 +0900
-@@ -345,6 +345,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-
-+ulint srv_dict_size_limit = 0;
-+
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
- ulint srv_io_pattern_trace_running = 0;
-@@ -1936,6 +1938,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -ru mysql-5.0.75_base/sql/ha_innodb.cc mysql-5.0.75/sql/ha_innodb.cc
---- mysql-5.0.75_base/sql/ha_innodb.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.cc 2009-01-27 10:54:08.000000000 +0900
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -ru mysql-5.0.75_base/sql/ha_innodb.h mysql-5.0.75/sql/ha_innodb.h
---- mysql-5.0.75_base/sql/ha_innodb.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.h 2009-01-26 15:49:37.000000000 +0900
-@@ -242,6 +242,7 @@
- extern ulong srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -ru mysql-5.0.75_base/sql/mysqld.cc mysql-5.0.75/sql/mysqld.cc
---- mysql-5.0.75_base/sql/mysqld.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/mysqld.cc 2009-01-26 15:29:45.000000000 +0900
-@@ -5053,6 +5053,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_RPL_MIRROR_BINLOG,
- OPT_SYNC_MIRROR_BINLOG,
-@@ -5406,6 +5407,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -ru mysql-5.0.75_base/sql/set_var.cc mysql-5.0.75/sql/set_var.cc
---- mysql-5.0.75_base/sql/set_var.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/set_var.cc 2009-01-26 15:46:45.000000000 +0900
-@@ -522,6 +522,8 @@
- &innodb_read_ahead_typelib, fix_innodb_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -905,6 +907,7 @@
- &sys_innodb_flush_neighbor_pages,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1056,6 +1059,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
-diff -ruN mysql-5.0.75_base/mysql-test/r/innodb_dict_size_limit.result mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result 2009-01-27 11:43:46.000000000 +0900
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -ruN mysql-5.0.75_base/mysql-test/t/innodb_dict_size_limit.test mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test 2009-01-27 11:43:36.000000000 +0900
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -ruN mysql-5.0.75_base/patch_info/innodb_dict_size_limit.info mysql-5.0.75/patch_info/innodb_dict_size_limit.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/patch_info/innodb_dict_size_limit.info 2009-01-26 15:46:45.000000000 +0900
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
diff --git a/percona/5.0.77-b13/innodb_fsync_source.patch b/percona/5.0.77-b13/innodb_fsync_source.patch
deleted file mode 100644
index 637a7d6..0000000
--- a/percona/5.0.77-b13/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r 61031ebb48ce innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Nov 03 05:07:56 2008 -0800
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r 61031ebb48ce innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/fil/fil0fil.c Mon Nov 03 05:07:56 2008 -0800
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4166,8 +4187,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4176,7 +4198,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4281,7 +4303,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4322,7 +4345,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r 61031ebb48ce innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/fil0fil.h Mon Nov 03 05:07:56 2008 -0800
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -621,14 +628,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -636,7 +655,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r 61031ebb48ce innobase/include/log0log.h
---- a/innobase/include/log0log.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/log0log.h Mon Nov 03 05:07:56 2008 -0800
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
-@@ -744,6 +767,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r 61031ebb48ce innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:07:56 2008 -0800
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1551,7 +1567,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1921,11 +1937,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1938,7 +1954,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2566,7 +2583,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2647,7 +2664,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3184,8 +3202,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3218,7 +3236,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3331,15 +3349,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r 61031ebb48ce innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:07:56 2008 -0800
-@@ -1638,6 +1638,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r 61031ebb48ce innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0sys.c Mon Nov 03 05:07:56 2008 -0800
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r 61031ebb48ce innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0trx.c Mon Nov 03 05:07:56 2008 -0800
-@@ -916,19 +916,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1659,18 +1661,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1906,19 +1911,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r 61031ebb48ce patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Mon Nov 03 05:07:56 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.77-b13/innodb_io_patches.patch b/percona/5.0.77-b13/innodb_io_patches.patch
deleted file mode 100644
index 0b3ccef..0000000
--- a/percona/5.0.77-b13/innodb_io_patches.patch
+++ /dev/null
@@ -1,672 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2008-12-19 02:19:35.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-01-09 15:51:10.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-01-09 15:40:46.000000000 +0900
-@@ -189,6 +189,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +400,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2008-12-19 02:19:35.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-01-09 15:53:18.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-01-09 15:40:46.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-01-09 15:40:22.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-01-09 15:54:33.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,14 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern uint srv_read_ahead;
-+extern ulint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2008-12-19 02:19:36.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-01-09 15:40:46.000000000 +0900
-@@ -3326,6 +3326,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-01-09 15:40:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-01-09 15:40:46.000000000 +0900
-@@ -2877,8 +2877,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2888,6 +2890,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2898,8 +2902,8 @@
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-@@ -3180,6 +3184,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3198,6 +3209,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3205,6 +3226,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-01-09 15:40:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-01-09 15:58:36.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -324,6 +326,22 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2214,6 +2232,8 @@
- ibool skip_sleep = FALSE;
- ulint i;
-
-+ dulint oldest_lsn;
-+
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
-@@ -2302,9 +2322,9 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-@@ -2317,7 +2337,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2326,6 +2346,49 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ } else if (srv_adaptive_checkpoint) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2352,10 +2415,10 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2365,7 +2428,7 @@
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2407,14 +2470,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2503,7 +2566,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2520,7 +2583,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2008-12-19 02:19:37.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-01-09 15:40:46.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ srv_n_read_io_threads, srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS * 8);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-01-09 15:59:05.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-01-09 15:40:46.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1403,6 +1404,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-01-09 15:59:41.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,13 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern uint srv_read_ahead;
-+extern ulong srv_adaptive_checkpoint;
- }
-
- bool innobase_init(void);
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-01-09 16:01:25.000000000 +0900
-@@ -5036,6 +5036,15 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED
- };
-@@ -5344,6 +5353,41 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. 0:disable 1:enable",
-+ (gptr*) &srv_adaptive_checkpoint, (gptr*) &srv_adaptive_checkpoint,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7637,6 +7636,22 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-01-09 15:40:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-01-09 16:05:22.000000000 +0900
-@@ -484,6 +484,37 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -847,6 +859,12 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -982,6 +1000,15 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -1482,6 +1501,13 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-01-12 11:20:31.000000000 +0900
-+++ b/sql/set_var.h 2009-01-12 15:26:35.000000000 +0900
-@@ -31,6 +31,10 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1114,6 +1118,9 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.77-b13/innodb_io_pattern.patch b/percona/5.0.77-b13/innodb_io_pattern.patch
deleted file mode 100644
index 26c9b69..0000000
--- a/percona/5.0.77-b13/innodb_io_pattern.patch
+++ /dev/null
@@ -1,688 +0,0 @@
-diff -r 5060df9888d7 include/mysql_com.h
---- a/include/mysql_com.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/include/mysql_com.h Tue Feb 17 22:33:58 2009 -0800
-@@ -121,6 +121,9 @@
- #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-+
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-diff -r 5060df9888d7 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/buf/buf0buf.c Tue Feb 17 22:33:58 2009 -0800
-@@ -653,6 +653,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1966,6 +1969,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2067,6 +2073,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2082,6 +2108,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2656,3 +2702,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r 5060df9888d7 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0buf.h Tue Feb 17 22:33:58 2009 -0800
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r 5060df9888d7 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0types.h Tue Feb 17 22:33:58 2009 -0800
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r 5060df9888d7 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:58 2009 -0800
-@@ -145,6 +145,11 @@
- extern ulint srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r 5060df9888d7 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:58 2009 -0800
-@@ -344,6 +344,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r 5060df9888d7 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema.result Tue Feb 17 22:33:58 2009 -0800
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r 5060df9888d7 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:58 2009 -0800
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r 5060df9888d7 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:58 2009 -0800
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r 5060df9888d7 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Tue Feb 17 22:33:58 2009 -0800
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r 5060df9888d7 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -1569,6 +1569,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6535,6 +6537,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r 5060df9888d7 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:58 2009 -0800
-@@ -244,6 +244,9 @@
- extern ulong srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- }
-
- bool innobase_init(void);
-@@ -270,6 +273,9 @@
- bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-+
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-
- void innobase_release_temporary_latches(THD *thd);
-
-diff -r 5060df9888d7 sql/lex.h
---- a/sql/lex.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/lex.h Tue Feb 17 22:33:58 2009 -0800
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r 5060df9888d7 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -5026,6 +5026,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5445,6 +5448,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 5060df9888d7 sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -528,6 +528,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -901,6 +907,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1047,6 +1056,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -3160,6 +3172,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r 5060df9888d7 sql/set_var.h
---- a/sql/set_var.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.h Tue Feb 17 22:33:58 2009 -0800
-@@ -989,6 +989,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r 5060df9888d7 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -8009,6 +8009,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 5060df9888d7 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -32,6 +32,17 @@
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
- #endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
-@@ -4088,6 +4099,67 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4894,6 +4966,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5069,6 +5154,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 5060df9888d7 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_yacc.yy Tue Feb 17 22:33:58 2009 -0800
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8541,6 +8542,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9594,6 +9596,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.77-b13/innodb_locks_held.patch b/percona/5.0.77-b13/innodb_locks_held.patch
deleted file mode 100644
index a4ae8ab..0000000
--- a/percona/5.0.77-b13/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r 7d3d7786b927 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:47 2009 -0800
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r 7d3d7786b927 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/lock/lock0lock.c Tue Feb 17 22:33:47 2009 -0800
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r 7d3d7786b927 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:47 2009 -0800
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1703,24 +1705,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1813,6 +1797,25 @@
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-+
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
-diff -r 7d3d7786b927 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/libmysqld/set_var.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -821,6 +821,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -936,6 +938,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r 7d3d7786b927 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Tue Feb 17 22:33:47 2009 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r 7d3d7786b927 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:47 2009 -0800
-@@ -242,6 +242,8 @@
- extern ulong srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
- }
-
- bool innobase_init(void);
-diff -r 7d3d7786b927 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -5012,6 +5012,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5356,6 +5358,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r 7d3d7786b927 sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -522,6 +522,12 @@
- &innodb_read_ahead_typelib, fix_innodb_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -893,6 +899,8 @@
- &sys_innodb_flush_neighbor_pages,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1008,6 +1016,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.77-b13/innodb_rw_lock.patch b/percona/5.0.77-b13/innodb_rw_lock.patch
deleted file mode 100644
index f7a3166..0000000
--- a/percona/5.0.77-b13/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1472 +0,0 @@
-diff -r 962aec0d731c innobase/configure
---- a/innobase/configure Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/configure Thu Oct 09 08:30:28 2008 -0700
-@@ -20519,6 +20519,88 @@
-
- fi
- done
-+
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
-diff -r 962aec0d731c innobase/configure.in
---- a/innobase/configure.in Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/configure.in Thu Oct 09 08:30:28 2008 -0700
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -r 962aec0d731c innobase/ib_config.h
---- a/innobase/ib_config.h Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/ib_config.h Thu Oct 09 08:30:28 2008 -0700
-@@ -3,6 +3,9 @@
-
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-+
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-diff -r 962aec0d731c innobase/ib_config.h.in
---- a/innobase/ib_config.h.in Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/ib_config.h.in Thu Oct 09 08:30:28 2008 -0700
-@@ -2,6 +2,9 @@
-
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-+
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-diff -r 962aec0d731c innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/include/sync0rw.h Thu Oct 09 08:30:28 2008 -0700
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +432,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +442,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -r 962aec0d731c innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/include/sync0rw.ic Thu Oct 09 08:30:28 2008 -0700
-@@ -47,20 +47,52 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
- }
- UNIV_INLINE
- void
--rw_lock_set_waiters(
--/*================*/
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+ lock->s_waiters = flag;
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+ lock->x_waiters = flag;
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+ lock->wait_ex_waiters = flag;
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +100,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +140,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +149,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +179,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +225,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +261,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +307,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +344,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +373,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +395,55 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if ((lock->lock_word == RW_LOCK_BIAS)
-+ && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* x-unlock */
-+ __sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS);
-+ }
-+ } else {
-+ /* fail (x-lock) */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)
-+ && rw_lock_get_writer(lock) == RW_LOCK_EX) {
-+ goto relock;
-+ }
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +474,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +490,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,20 +525,36 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && lock->wait_ex_waiters)) {
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+#endif
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ else if (UNIV_UNLIKELY(last && lock->x_waiters)) {
-+#else
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+#endif
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(mutex);
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -409,13 +578,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +613,81 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+
-+ /* atomic operation may be safer about memory order. */
-+ rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-+ __sync_synchronize();
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+#else
-+ if (lock->writer_count == 0) {
-+#endif
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +712,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +726,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -r 962aec0d731c innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/sync/sync0arr.c Thu Oct 09 08:30:28 2008 -0700
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -r 962aec0d731c innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c Thu Oct 09 08:28:53 2008 -0700
-+++ b/innobase/sync/sync0rw.c Thu Oct 09 08:30:28 2008 -0700
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,6 +199,8 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
-@@ -199,7 +208,9 @@
- {
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
- ut_a((rw_lock_get_reader_count(lock) == 0)
-@@ -207,11 +218,17 @@
- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+ ut_a((rw_lock_get_s_waiters(lock) == 0)
-+ || (rw_lock_get_s_waiters(lock) == 1));
-+ ut_a((rw_lock_get_x_waiters(lock) == 0)
-+ || (rw_lock_get_x_waiters(lock) == 1));
-+ ut_a((rw_lock_get_wx_waiters(lock) == 0)
-+ || (rw_lock_get_wx_waiters(lock) == 1));
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +254,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +280,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +311,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-+
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->wait_ex_waiters && lock->lock_word == RW_LOCK_BIAS) {
-+ rw_lock_set_wx_waiters(lock, 0);
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +358,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +388,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* ??? */
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +552,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +578,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +612,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +628,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +646,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +661,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +898,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +910,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +920,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +944,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +991,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1022,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1049,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1119,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -r 962aec0d731c patch_info/innodb_rw_lock.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_rw_lock.info Thu Oct 09 08:30:28 2008 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.77-b13/innodb_show_bp.patch b/percona/5.0.77-b13/innodb_show_bp.patch
deleted file mode 100644
index a56ae9a..0000000
--- a/percona/5.0.77-b13/innodb_show_bp.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,13 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.77-b13/innodb_show_hashed_memory.patch b/percona/5.0.77-b13/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.77-b13/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.77-b13/microsec_process.patch b/percona/5.0.77-b13/microsec_process.patch
deleted file mode 100644
index 0e094e5..0000000
--- a/percona/5.0.77-b13/microsec_process.patch
+++ /dev/null
@@ -1,281 +0,0 @@
-diff -r 327ce7a34c91 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/information_schema.result Fri Nov 07 15:52:53 2008 -0800
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r 327ce7a34c91 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Fri Nov 07 15:52:53 2008 -0800
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r 327ce7a34c91 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Fri Nov 07 15:44:23 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Fri Nov 07 15:52:53 2008 -0800
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r 327ce7a34c91 sql/mysql_priv.h
---- a/sql/mysql_priv.h Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/mysql_priv.h Fri Nov 07 15:52:53 2008 -0800
-@@ -244,6 +244,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r 327ce7a34c91 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/sql_show.cc Fri Nov 07 15:52:53 2008 -0800
-@@ -1466,6 +1466,120 @@
- }
- send_eof(thd);
- DBUG_VOID_RETURN;
-+}
-+
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ const ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
- }
-
- /*****************************************************************************
-@@ -4821,6 +4941,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4845,6 +4981,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r 327ce7a34c91 sql/table.h
---- a/sql/table.h Fri Nov 07 15:44:23 2008 -0800
-+++ b/sql/table.h Fri Nov 07 15:52:53 2008 -0800
-@@ -378,6 +378,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
-diff -ruN mysql-5.0.67_highperf/patch_info/microsec_process.info mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+ChangeLog=
diff --git a/percona/5.0.77-b13/microslow_innodb.patch b/percona/5.0.77-b13/microslow_innodb.patch
deleted file mode 100644
index 6c21043..0000000
--- a/percona/5.0.77-b13/microslow_innodb.patch
+++ /dev/null
@@ -1,2472 +0,0 @@
-diff -r 04958490fc6d include/my_getopt.h
---- a/include/my_getopt.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/include/my_getopt.h Tue Feb 17 22:33:00 2009 -0800
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_DOUBLE 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 04958490fc6d include/my_time.h
---- a/include/my_time.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/include/my_time.h Tue Feb 17 22:33:00 2009 -0800
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 04958490fc6d innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/buf/buf0buf.c Tue Feb 17 22:33:00 2009 -0800
-@@ -37,6 +37,9 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1089,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1141,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1157,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1189,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1302,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1275,6 +1321,12 @@
-
- break;
- }
-+ }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
- }
- }
-
-@@ -1296,12 +1348,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1383,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,13 +1498,18 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-@@ -1470,6 +1533,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1558,6 +1622,11 @@
- || (ibuf_count_get(block->space, block->offset) == 0));
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-diff -r 04958490fc6d innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/buf/buf0rea.c Tue Feb 17 22:33:00 2009 -0800
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 04958490fc6d innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/fil/fil0fil.c Tue Feb 17 22:33:00 2009 -0800
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 04958490fc6d innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/buf0rea.h Tue Feb 17 22:33:00 2009 -0800
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 04958490fc6d innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/fil0fil.h Tue Feb 17 22:33:00 2009 -0800
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 04958490fc6d innobase/include/os0file.h
---- a/innobase/include/os0file.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/os0file.h Tue Feb 17 22:33:00 2009 -0800
-@@ -10,6 +10,8 @@
- #define os0file_h
-
- #include "univ.i"
-+
-+#include "trx0types.h"
-
- #ifndef __WIN__
- #include <dirent.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 04958490fc6d innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:00 2009 -0800
-@@ -26,6 +26,8 @@
- at a time */
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-+
-+extern ibool srv_slow_log;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-diff -r 04958490fc6d innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/trx0trx.h Tue Feb 17 22:33:00 2009 -0800
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 04958490fc6d innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/lock/lock0lock.c Tue Feb 17 22:33:00 2009 -0800
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 04958490fc6d innobase/os/os0file.c
---- a/innobase/os/os0file.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/os/os0file.c Tue Feb 17 22:33:00 2009 -0800
-@@ -14,6 +14,7 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1904,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1918,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1947,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1967,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1980,6 +2003,13 @@
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-+
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- return(ret);
- }
-@@ -2103,7 +2133,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2143,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2208,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3168,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3422,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3462,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3496,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 04958490fc6d innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:00 2009 -0800
-@@ -47,6 +47,8 @@
- #include "dict0boot.h"
- #include "srv0start.h"
- #include "row0mysql.h"
-+
-+ibool srv_slow_log = 0;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
-@@ -996,6 +998,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1054,6 +1060,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1109,11 +1116,22 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-+
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- os_fast_mutex_lock(&srv_conc_mutex);
-
-diff -r 04958490fc6d innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/trx/trx0trx.c Tue Feb 17 22:33:00 2009 -0800
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 04958490fc6d mysys/my_getopt.c
---- a/mysys/my_getopt.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/mysys/my_getopt.c Tue Feb 17 22:33:00 2009 -0800
-@@ -1061,6 +1061,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_DOUBLE:
-+ printf("%6f\n", *((double*) value));
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 04958490fc6d patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Tue Feb 17 22:33:00 2009 -0800
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 04958490fc6d scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Tue Feb 17 22:32:27 2009 -0800
-+++ b/scripts/mysqldumpslow.sh Tue Feb 17 22:33:00 2009 -0800
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 04958490fc6d sql-common/my_time.c
---- a/sql-common/my_time.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql-common/my_time.c Tue Feb 17 22:33:00 2009 -0800
-@@ -1252,3 +1252,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 04958490fc6d sql/filesort.cc
---- a/sql/filesort.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/filesort.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 04958490fc6d sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -805,9 +806,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1309,6 +1335,8 @@
- }
-
- /* -------------- Log files ---------------------------*/
-+
-+ srv_slow_log = (ibool) opt_slow_log;
-
- /* The default dir for log files is the datadir of MySQL */
-
-@@ -4681,6 +4709,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4946,6 +4980,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5033,6 +5073,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5097,6 +5143,12 @@
-
- if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) {
- trx->check_foreigns = FALSE;
-+ }
-+
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
- }
-
- name_len1 = strlen(from);
-@@ -6106,6 +6158,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6229,7 +6282,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 04958490fc6d sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:00 2009 -0800
-@@ -266,6 +266,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 04958490fc6d sql/log.cc
---- a/sql/log.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/log.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2284,11 +2284,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2298,7 +2299,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2328,22 +2330,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 04958490fc6d sql/log_event.cc
---- a/sql/log_event.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/log_event.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2039,6 +2039,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 04958490fc6d sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/mysql_priv.h Tue Feb 17 22:33:00 2009 -0800
-@@ -494,6 +494,78 @@
- #define WEEK_FIRST_WEEKDAY 4
-
- #define STRING_BUFFER_USUAL_SIZE 80
-+
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-
- enum enum_parsing_place
- {
-@@ -1351,6 +1423,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1362,7 +1435,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 04958490fc6d sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -175,7 +175,6 @@
- static void getvolumename();
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
--
-
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
-@@ -409,10 +408,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -507,6 +509,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -584,7 +587,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3693,6 +3696,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4943,7 +4948,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5034,11 +5039,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5428,8 +5440,17 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
-@@ -5795,6 +5816,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6097,11 +6121,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_DOUBLE,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6878,7 +6922,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7339,6 +7387,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7671,10 +7748,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 04958490fc6d sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -694,6 +714,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -717,6 +741,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -770,6 +795,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -986,8 +1013,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1014,6 +1044,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1101,6 +1132,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1141,6 +1174,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1769,6 +1803,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1924,6 +1969,19 @@
- value= *(longlong*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
-+ }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
- }
- case SHOW_HA_ROWS:
- {
-@@ -2757,6 +2815,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3526,6 +3608,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 04958490fc6d sql/set_var.h
---- a/sql/set_var.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/set_var.h Tue Feb 17 22:33:00 2009 -0800
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -377,7 +383,6 @@
- SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
--
-
- class sys_var_thd_ulonglong :public sys_var_thd
- {
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -477,6 +495,66 @@
- ulong *length);
- };
-
-+
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-
- class sys_var_thd_storage_engine :public sys_var_thd
- {
-@@ -1087,3 +1165,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 04958490fc6d sql/slave.cc
---- a/sql/slave.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/slave.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2925,6 +2925,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 04958490fc6d sql/sql_cache.cc
---- a/sql/sql_cache.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_cache.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1341,6 +1341,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1348,6 +1349,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 04958490fc6d sql/sql_class.cc
---- a/sql/sql_class.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_class.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -188,7 +188,7 @@
- lock_id(&main_lock_id),
- user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2224,6 +2224,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2240,7 +2246,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2293,6 +2305,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 04958490fc6d sql/sql_class.h
---- a/sql/sql_class.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_class.h Tue Feb 17 22:33:00 2009 -0800
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1128,6 +1133,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1184,6 +1195,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1292,10 +1308,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1685,11 +1715,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 04958490fc6d sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,27 +2363,55 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-+ ulonglong start_of_query_timer= thd->start_timer;
- thd->end_time(); // Set start time
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+ if (thd->write_to_slow_log != TRUE && thd->variables.long_query_time < 1000000 &&
-+ (ulong) (thd->start_timer - thd->timer_after_lock) >= 1000000)
-+ thd->write_to_slow_log= TRUE;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE)
-+ return;
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time ||
-- (thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END)
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2664,6 +2702,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6084,6 +6124,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 04958490fc6d sql/sql_select.cc
---- a/sql/sql_select.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_select.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -6224,8 +6224,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6240,8 +6243,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9305,6 +9311,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10165,6 +10172,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 04958490fc6d sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1544,6 +1544,12 @@
- value= ((char *) status_var + (ulonglong) value);
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
-+ break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
- break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
-diff -r 04958490fc6d sql/structs.h
---- a/sql/structs.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/structs.h Tue Feb 17 22:33:00 2009 -0800
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.77-b13/mirror_binlog.patch b/percona/5.0.77-b13/mirror_binlog.patch
deleted file mode 100644
index 4dae799..0000000
--- a/percona/5.0.77-b13/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5036,6 +5037,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED
- };
-
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.77-b13/mysql-percona.rhel5.spec b/percona/5.0.77-b13/mysql-percona.rhel5.spec
deleted file mode 100644
index dab9292..0000000
--- a/percona/5.0.77-b13/mysql-percona.rhel5.spec
+++ /dev/null
@@ -1,1413 +0,0 @@
-%define mysql_vendor Percona Inc
-%{!?redhat_version:%define redhat_version 5}
-%define distribution rhel%{redhat_version}
-%define release 0.%{distribution}
-%define patchset b13
-
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'perconahighperf 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'percona 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-
-# Meta information
-# norootforbuild
-
-# use "rpmbuild --with yassl" or "rpm --define '_with_yassl 1'" (for RPM 3.x)
-# to build with yaSSL support (off by default)
-%{?_with_yassl:%define YASSL_BUILD 1}
-%{!?_with_yassl:%define YASSL_BUILD 0}
-
-# FIXME disabled until we move out the version strings from spec file
-## use "rpmbuild --with cluster" or "rpm --define '_with_cluster 1'" (for RPM 3.x)
-## to build with cluster support (off by default)
-##%{?_with_cluster:%define CLUSTER_BUILD 1}
-##%{!?_with_cluster:%define CLUSTER_BUILD 0}
-
-#
-# Product definitions - one of these has to be defined via the RPM build
-# options, e.g. "--define 'enterprise 1'"
-#
-%{!?enterprise:%define enterprise 0}
-%{!?enterprise_gpl:%define enterprise_gpl 0}
-%{!?classic:%define classic 0}
-%{!?cluster:%define cluster 0}
-%{!?cluster_gpl:%define cluster_gpl 0}
-%{!?community:%define community 0}
-%{!?percona:%define percona 0}
-%{!?perconahighperf:%define perconahighperf 0}
-%{!?mysqlversion:%define mysqlversion 5.0.67}
-#%define mysql_version 5.0.67
-
-# On SuSE 9 no separate "debuginfo" package is built. To enable basic
-# debugging on that platform, we don't strip binaries on SuSE 9. We
-# disable the strip of binaries by redefining the RPM macro
-# "__os_install_post" leaving out the script calls that normally does
-# this. We do this in all cases, as on platforms where "debuginfo" is
-# created, a script "find-debuginfo.sh" will be called that will do
-# the strip anyway, part of separating the executable and debug
-# information into separate files put into separate packages.
-#
-# Some references (shows more advanced conditional usage):
-# http://www.redhat.com/archives/rpm-list/2001-November/msg00257.html
-# http://www.redhat.com/archives/rpm-list/2003-February/msg00275.html
-# http://www.redhat.com/archives/rhl-devel-list/2004-January/msg01546.html
-# http://lists.opensuse.org/archive/opensuse-commit/2006-May/1171.html
-
-%define __os_install_post /usr/lib/rpm/brp-compress
-
-
-%if %{percona}
-%define comment MySQL Percona Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-%{patchset}
-%endif
-
-%if %{perconahighperf}
-%define comment MySQL Percona High Performance Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-highperf-%{patchset}
-%endif
-
-%if %{community}
-%define comment MySQL Community Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -community
-%endif
-
-%if %{enterprise}
-%define comment MySQL Enterprise Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise
-%endif
-
-%if %{enterprise_gpl}
-%define comment MySQL Enterprise Server
-%define commercial 0
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise-gpl
-%endif
-
-%if %{classic}
-%define comment MySQL Classic Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 0
-%define server_suffix -classic
-%endif
-
-
-%if %{COMMUNITY_BUILD}
-%define cluster_package_prefix -cluster
-%else
-%define cluster_package_prefix -
-%endif
-
-%define mysqld_user mysql
-%define mysqld_group mysql
-%define mysqldatadir /var/lib/mysql
-
-# We don't package all files installed into the build root by intention -
-# See BUG#998 for details.
-%define _unpackaged_files_terminate_build 0
-
-%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com
-Source0: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-%{version}.tar.gz
-
-Patch1: show_patches.patch
-Patch2: microslow_innodb.patch
-Patch3: userstatv2.patch
-Patch4: microsec_process.patch
-Patch5: innodb_io_patches.patch
-Patch6: mirror_binlog.patch
-Patch7: mysqld_safe_syslog.patch
-Patch8: innodb_locks_held.patch
-Patch9: innodb_show_bp.patch
-Patch10: innodb_show_hashed_memory.patch
-Patch11: innodb_check_fragmentation.patch
-Patch12: innodb_io_pattern.patch
-Patch13: innodb_fsync_source.patch
-Patch14: innodb_dict_size_limit.patch
-Patch100: split_buf_pool_mutex_fixed_optimistic_safe.patch
-Patch101: innodb_rw_lock.patch
-
-
-Name: MySQL%{server_suffix}
-Summary: MySQL: a very fast and reliable SQL database server
-Group: Applications/Databases
-Version: %{mysqlversion}
-Release: %{release}
-Distribution: Red Hat Enterprise Linux %{redhat_version}
-License: GPL
-Source: mysql-%{mysqlversion}.tar.gz
-URL: http://www.mysql.com/
-Packager: Percona Build Team <info@percona.com>
-Vendor: %{mysql_vendor}
-Provides: msqlormysql MySQL-server mysql
-BuildRequires: gperf perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time
-
-# Think about what you use here since the first step is to
-# run a rm -rf
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-
-# From the manual
-%description
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-%package -n MySQL-server%{server_suffix}
-Summary: @COMMENT@ for Red Hat Enterprise Linux %{redhat_version}
-Group: Applications/Databases
-Requires: chkconfig coreutils shadow-utils grep procps
-Provides: msqlormysql mysql-server mysql MySQL MySQL-server
-Obsoletes: MySQL mysql mysql-server MySQL-server
-
-%description -n MySQL-server%{server_suffix}
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-This package includes the MySQL server binary
-%if %{INNODB_BUILD}
-(configured including InnoDB)
-%endif
-as well as related utilities to run and administer a MySQL server.
-
-If you want to access and work with the database, you have to install
-package "MySQL-client%{server_suffix}" as well!
-
-%package -n MySQL-client%{server_suffix}
-Summary: MySQL - Client
-Group: Applications/Databases
-Obsoletes: mysql-client MySQL-client
-Provides: mysql-client MySQL-client
-
-%description -n MySQL-client%{server_suffix}
-This package contains the standard MySQL clients and administration tools.
-
-%{see_base}
-
-%package -n MySQL-test%{server_suffix}
-Requires: mysql-client perl
-Summary: MySQL - Test suite
-Group: Applications/Databases
-Provides: mysql-test MySQL-test
-Obsoletes: mysql-test MySQL-test
-AutoReqProv: no
-
-%description -n MySQL-test%{server_suffix}
-This package contains the MySQL regression test suite.
-
-%{see_base}
-
-%package -n MySQL-devel%{server_suffix}
-Summary: MySQL - Development header files and libraries
-Group: Applications/Databases
-Provides: mysql-devel MySQL-devel
-Obsoletes: mysql-devel MySQL-devel
-
-%description -n MySQL-devel%{server_suffix}
-This package contains the development header files and libraries
-necessary to develop MySQL client applications.
-
-%{see_base}
-
-%package -n MySQL-shared%{server_suffix}
-Summary: MySQL - Shared libraries
-Group: Applications/Databases
-Provides: mysql-shared MySQL-shared
-# Obsoletes below to correct old missing Provides:/Obsoletes
-Obsoletes: mysql-shared MySQL-shared-standard MySQL-shared-pro
-Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl
-Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared
-
-%description -n MySQL-shared%{server_suffix}
-This package contains the shared libraries (*.so*) which certain
-languages and applications need to dynamically load and use MySQL.
-
-%prep
-%setup -n mysql-%{mysqlversion}
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-#%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
-%patch14 -p1
-%if %{perconahighperf}
-%patch100 -p1
-%patch101 -p1
-%endif
-
-%build
-
-pushd ..
-tar cfz mysql-%{mysqlversion}%{server_suffix}-src.tar.gz mysql-%{mysqlversion}
-mv mysql-%{mysqlversion}%{server_suffix}-src.tar.gz %{_topdir}
-popd
-
-BuildMySQL() {
-# Evaluate current setting of $DEBUG
-if [ $DEBUG -gt 0 ] ; then
- OPT_COMMENT='--with-comment="%{comment} - Debug (%{license})"'
- OPT_DEBUG='--with-debug'
-else
- OPT_COMMENT='--with-comment="%{comment} (%{license})"'
- OPT_DEBUG=''
-fi
-if [ $BINARYPKG -ne 1 ] ; then
- OPT_PATH='--exec-prefix=%{_exec_prefix} \
- --libexecdir=%{_sbindir} \
- --libdir=%{_libdir} \
- --sysconfdir=%{_sysconfdir} \
- --datadir=%{_datadir} \
- --localstatedir=%{mysqldatadir} \
- --infodir=%{_infodir} \
- --includedir=%{_includedir} \
- --mandir=%{_mandir}'
-else
- OPT_PATH='--prefix=/usr/local/mysql-%{mysqlversion}%{server_suffix}'
-fi
-
-# The --enable-assembler simply does nothing on systems that does not
-# support assembler speedups.
-sh -c "CFLAGS=\"${CFLAGS:-$RPM_OPT_FLAGS}\" \
- CXXFLAGS=\"${CXXFLAGS:-$RPM_OPT_FLAGS}\" \
- LDFLAGS=\"$LDFLAGS\" \
- ./configure \
- $* \
- --enable-assembler \
- --enable-local-infile \
- --with-mysqld-user=%{mysqld_user} \
- --with-unix-socket-path=/var/lib/mysql/mysql.sock \
- --with-pic \
- --prefix=/ \
- --with-extra-charsets=complex \
-%if %{YASSL_BUILD}
- --with-yassl \
-%endif
- $OPT_PATH \
- --enable-thread-safe-client \
-%if %{?comment:1}0
- $OPT_COMMENT \
-%endif
- $OPT_DEBUG \
- --with-readline \
- ; make -j8"
-}
-# end of function definition "BuildMySQL"
-
-
-BuildServer() {
-BuildMySQL "--disable-shared \
-%if %{?server_suffix:1}0
- --with-server-suffix='%{server_suffix}' \
-%endif
- --without-embedded-server \
-%if %{INNODB_BUILD}
- --with-innodb \
-%else
- --without-innodb \
-%endif
- --with-csv-storage-engine \
- --with-archive-storage-engine \
- --with-blackhole-storage-engine \
- --with-federated-storage-engine \
- --without-bench \
- --with-zlib-dir=bundled \
- --with-big-tables"
-
-if [ -n "$MYSQL_CONFLOG_DEST" ] ; then
- cp -fp config.log "$MYSQL_CONFLOG_DEST"
-fi
-
-if [ -f sql/.libs/mysqld ] ; then
- nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym
-else
- nm --numeric-sort sql/mysqld > sql/mysqld.sym
-fi
-}
-# end of function definition "BuildServer"
-
-
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Clean up the BuildRoot first
-[ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR;
-mkdir -p $RBR%{_libdir}/mysql $RBR%{_sbindir}
-
-# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and
-# including exceptions into the code
-if [ -z "$CXX" -a -z "$CC" ] ; then
- export CC="gcc" CXX="gcc"
-fi
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-
-
-if [ "%{redhat_version}" = "5" ] ; then
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-fi
-
-if [ "%{redhat_version}" != "5" ] ; then
-export CC="gcc4" CXX="gcc4"
-export CFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-export CXXFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-fi
-
-
-# Create the shared libs seperately to avoid a dependency for the client utilities
-DEBUG=0
-BINARYPKG=0
-BuildMySQL "--enable-shared --without-server"
-
-# Install shared libraries
-cp -av libmysql/.libs/*.so* $RBR/%{_libdir}
-cp -av libmysql_r/.libs/*.so* $RBR/%{_libdir}
-
-# Include libgcc.a in the devel subpackage (BUG 4921)
-if expr "$CC" : "gcc.*" > /dev/null && \
- expr "$CC" : ".* gcc.*" > /dev/null ; then
- libgcc=`$CC $CFLAGS --print-libgcc-file`
- if [ -f $libgcc ] ; then
- install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
- fi
-fi
-
-# Now create a debug server
-DEBUG=1
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt-debug
-fi
-
-# Get the debug server and its .sym file from the build tree
-if [ -f sql/.libs/mysqld ] ; then
- cp sql/.libs/mysqld $RBR%{_sbindir}/mysqld-debug
-else
- cp sql/mysqld $RBR%{_sbindir}/mysqld-debug
-fi
-
-cp sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld-debug.sym
-
-# Now, the binary package
-DEBUG=0
-BINARYPKG=1
-make clean distclean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-rm -fr /tmp/mysql-%{mysqlversion}%{server_suffix}
-make DESTDIR=/tmp/mysql-%{mysqlversion}%{server_suffix} install
-pushd /tmp/mysql-%{mysqlversion}%{server_suffix}/usr/local
-tar cfz mysql-%{mysqlversion}%{server_suffix}.tar.gz mysql-%{mysqlversion}%{server_suffix}
-mv mysql-%{mysqlversion}%{server_suffix}.tar.gz %{_topdir}
-popd
-
-# Now, the default server
-DEBUG=0
-BINARYPKG=0
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-
-
-%install
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Ensure that needed directories exists
-install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
-install -d $RBR%{mysqldatadir}/mysql
-install -d $RBR%{_datadir}/mysql-test
-install -d $RBR%{_datadir}/mysql/SELinux/RHEL4
-install -d $RBR%{_includedir}
-install -d $RBR%{_libdir}
-install -d $RBR%{_mandir}
-install -d $RBR%{_sbindir}
-
-make DESTDIR=$RBR benchdir_root=%{_datadir} install
-
-# install symbol files ( for stack trace resolution)
-install -m644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym
-
-# Install logrotate and autostart
-install -m644 $MBD/support-files/mysql-log-rotate \
- $RBR%{_sysconfdir}/logrotate.d/mysql
-install -m755 $MBD/support-files/mysql.server \
- $RBR%{_sysconfdir}/init.d/mysql
-
-# Create a symlink "rcmysql", pointing to the init.script. SuSE users
-# will appreciate that, as all services usually offer this.
-ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql
-
-# Create symbolic compatibility link safe_mysqld -> mysqld_safe
-# (safe_mysqld will be gone in MySQL 4.1)
-ln -sf ./mysqld_safe $RBR%{_bindir}/safe_mysqld
-
-# Touch the place where the my.cnf config file and mysqlmanager.passwd
-# (MySQL Instance Manager password file) might be located
-# Just to make sure it's in the file list and marked as a config file
-touch $RBR%{_sysconfdir}/my.cnf
-touch $RBR%{_sysconfdir}/mysqlmanager.passwd
-
-# Install SELinux files in datadir
-install -m600 $MBD/support-files/RHEL4-SElinux/mysql.{fc,te} \
- $RBR%{_datadir}/mysql/SELinux/RHEL4
-
-
-%pre -n MySQL-server%{server_suffix}
-# Check if we can safely upgrade. An upgrade is only safe if it's from one
-# of our RPMs in the same version family.
-
-installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
-if [ $? -eq 0 -a -n "$installed" ]; then
- vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
- version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
- myvendor='%{mysql_vendor}'
- myversion='%{mysqlversion}'
-
- old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
- new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
-
- [ -z "$vendor" ] && vendor='<unknown>'
- [ -z "$old_family" ] && old_family="<unrecognized version $version>"
- [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"
-
- error_text=
- if [ "$vendor" != "$myvendor" ]; then
- error_text="$error_text
-The current MySQL server package is provided by a different
-vendor ($vendor) than $myvendor. Some files may be installed
-to different locations, including log files and the service
-startup script in %{_sysconfdir}/init.d/.
-"
- fi
-
- if [ "$old_family" != "$new_family" ]; then
- error_text="$error_text
-Upgrading directly from MySQL $old_family to MySQL $new_family may not
-be safe in all cases. A manual dump and restore using mysqldump is
-recommended. It is important to review the MySQL manual's Upgrading
-section for version-specific incompatibilities.
-"
- fi
-
- if [ -n "$error_text" ]; then
- cat <<HERE >&2
-
-******************************************************************
-A MySQL server package ($installed) is installed.
-$error_text
-A manual upgrade is required.
-
-- Ensure that you have a complete, working backup of your data and my.cnf
- files
-- Shut down the MySQL server cleanly
-- Remove the existing MySQL packages. Usually this command will
- list the packages you should remove:
- rpm -qa | grep -i '^mysql-'
-
- You may choose to use 'rpm --nodeps -ev <package-name>' to remove
- the package which contains the mysqlclient shared library. The
- library will be reinstalled by the MySQL-shared-compat package.
-- Install the new MySQL packages supplied by $myvendor
-- Ensure that the MySQL server is started
-- Run the 'mysql_upgrade' program
-
-This is a brief description of the upgrade process. Important details
-can be found in the MySQL manual, in the Upgrading section.
-******************************************************************
-HERE
- exit 1
- fi
-fi
-
-# Shut down a previously installed server first
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
- echo "Giving mysqld 5 seconds to exit nicely"
- sleep 5
-fi
-
-%post -n MySQL-server%{server_suffix}
-mysql_datadir=%{mysqldatadir}
-
-# Create data directory
-mkdir -p $mysql_datadir/{mysql,test}
-
-# Make MySQL start/shutdown automatically when the machine does it.
-if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --add mysql
-fi
-
-
-
-# Create a MySQL user and group. Do not report any problems if it already
-# exists.
-groupadd -r %{mysqld_group} 2> /dev/null || true
-useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
-usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-
-# Change permissions so that the user that will run the MySQL daemon
-# owns all database files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Initiate databases
-%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
-
-# Upgrade databases if needed would go here - but it cannot be automated yet
-
-# Change permissions again to fix any new files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Fix permissions for the permission database so that only the user
-# can read them.
-chmod -R og-rw $mysql_datadir/mysql
-
-# install SELinux files - but don't override existing ones
-SETARGETDIR=/etc/selinux/targeted/src/policy
-SEDOMPROG=$SETARGETDIR/domains/program
-SECONPROG=$SETARGETDIR/file_contexts/program
-if [ -f /etc/redhat-release ] \
- && grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \
- || grep -q "CentOS release 4" /etc/redhat-release ; then
- echo
- echo
- echo 'Notes regarding SELinux on this platform:'
- echo '========================================='
- echo
- echo 'The default policy might cause server startup to fail because it is '
- echo 'not allowed to access critical files. In this case, please update '
- echo 'your installation. '
- echo
- echo 'The default policy might also cause inavailability of SSL related '
- echo 'features because the server is not allowed to access /dev/random '
- echo 'and /dev/urandom. If this is a problem, please do the following: '
- echo
- echo ' 1) install selinux-policy-targeted-sources from your OS vendor'
- echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':'
- echo ' allow mysqld_t random_device_t:chr_file read;'
- echo ' allow mysqld_t urandom_device_t:chr_file read;'
- echo ' 3) cd to '$SETARGETDIR' and issue the following command:'
- echo ' make load'
- echo
- echo
-fi
-
-if [ -x sbin/restorecon ] ; then
- sbin/restorecon -R var/lib/mysql
-fi
-
-# Restart in the same way that mysqld will be started normally.
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql start
- echo "Giving mysqld 2 seconds to start"
- sleep 2
-fi
-
-# Allow safe_mysqld to start mysqld and print a message before we exit
-sleep 2
-
-
-%preun -n MySQL-server%{server_suffix}
-if [ $1 = 0 ] ; then
- # Stop MySQL before uninstalling it
- if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null
- # Don't start it automatically anymore
- if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --del mysql
- fi
- fi
-fi
-
-# We do not remove the mysql user since it may still own a lot of
-# database files.
-
-# Clean up the BuildRoot
-%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
-
-%files -n MySQL-server%{server_suffix}
-%defattr(-,root,root,0755)
-
-%if %{commercial}
-%doc LICENSE.mysql
-%else
-%doc COPYING README
-%endif
-%doc support-files/my-*.cnf
-
-%doc %attr(644, root, root) %{_infodir}/mysql.info*
-
-%if %{INNODB_BUILD}
-%doc %attr(644, root, man) %{_mandir}/man1/innochecksum.1*
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/my_print_defaults.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisam_ftdump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamchk.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisampack.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_convert_table_format.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_explain_log.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_extensions.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqld.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
-%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
-%doc %attr(644, root, man) %{_mandir}/man1/replace.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
-%doc %attr(644, root, man) %{_mandir}/man1/safe_mysqld.1*
-
-%ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/mysqlmanager.passwd
-
-%if %{INNODB_BUILD}
-%attr(755, root, root) %{_bindir}/innochecksum
-%endif
-%attr(755, root, root) %{_bindir}/my_print_defaults
-%attr(755, root, root) %{_bindir}/myisam_ftdump
-%attr(755, root, root) %{_bindir}/myisamchk
-%attr(755, root, root) %{_bindir}/myisamlog
-%attr(755, root, root) %{_bindir}/myisampack
-%attr(755, root, root) %{_bindir}/mysql_convert_table_format
-%attr(755, root, root) %{_bindir}/mysql_explain_log
-%attr(755, root, root) %{_bindir}/mysql_fix_extensions
-%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
-%attr(755, root, root) %{_bindir}/mysql_install_db
-%attr(755, root, root) %{_bindir}/mysql_secure_installation
-%attr(755, root, root) %{_bindir}/mysql_setpermission
-%attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
-%attr(755, root, root) %{_bindir}/mysql_upgrade
-%attr(755, root, root) %{_bindir}/mysql_zap
-%attr(755, root, root) %{_bindir}/mysqlbug
-%attr(755, root, root) %{_bindir}/mysqld_multi
-%attr(755, root, root) %{_bindir}/mysqld_safe
-%attr(755, root, root) %{_bindir}/mysqldumpslow
-%attr(755, root, root) %{_bindir}/mysqlhotcopy
-%attr(755, root, root) %{_bindir}/mysqltest
-%attr(755, root, root) %{_bindir}/perror
-%attr(755, root, root) %{_bindir}/replace
-%attr(755, root, root) %{_bindir}/resolve_stack_dump
-%attr(755, root, root) %{_bindir}/resolveip
-%attr(755, root, root) %{_bindir}/safe_mysqld
-
-%attr(755, root, root) %{_sbindir}/mysqld
-%attr(755, root, root) %{_sbindir}/mysqld-debug
-%attr(755, root, root) %{_sbindir}/mysqlmanager
-%attr(755, root, root) %{_sbindir}/rcmysql
-%attr(644, root, root) %{_libdir}/mysql/mysqld.sym
-%attr(644, root, root) %{_libdir}/mysql/mysqld-debug.sym
-
-%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
-%attr(755, root, root) %{_sysconfdir}/init.d/mysql
-
-%attr(755, root, root) %{_datadir}/mysql/
-
-%files -n MySQL-client%{server_suffix}
-%defattr(-, root, root, 0755)
-%attr(755, root, root) %{_bindir}/msql2mysql
-%attr(755, root, root) %{_bindir}/mysql
-%attr(755, root, root) %{_bindir}/mysql_find_rows
-%attr(755, root, root) %{_bindir}/mysql_tableinfo
-%attr(755, root, root) %{_bindir}/mysql_upgrade_shell
-%attr(755, root, root) %{_bindir}/mysql_waitpid
-%attr(755, root, root) %{_bindir}/mysqlaccess
-%attr(755, root, root) %{_bindir}/mysqladmin
-%attr(755, root, root) %{_bindir}/mysqlbinlog
-%attr(755, root, root) %{_bindir}/mysqlcheck
-%attr(755, root, root) %{_bindir}/mysqldump
-%attr(755, root, root) %{_bindir}/mysqlimport
-%attr(755, root, root) %{_bindir}/mysqlshow
-
-%doc %attr(644, root, man) %{_mandir}/man1/msql2mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tableinfo.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_waitpid.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlaccess.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqladmin.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlbinlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlcheck.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1*
-
-%post -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%postun -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%files -n MySQL-devel%{server_suffix}
-%defattr(-, root, root, 0755)
-%if %{commercial}
-%else
-%doc EXCEPTIONS-CLIENT
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/comp_err.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1*
-%attr(755, root, root) %{_bindir}/comp_err
-%attr(755, root, root) %{_bindir}/mysql_config
-%dir %attr(755, root, root) %{_libdir}/mysql
-%{_includedir}/mysql
-%{_libdir}/mysql/libdbug.a
-%{_libdir}/mysql/libheap.a
-%{_libdir}/mysql/libmy*.a
-%{_libdir}/mysql/libmy*.la
-%{_libdir}/mysql/libvio.a
-%{_libdir}/mysql/libz*
-
-%files -n MySQL-shared%{server_suffix}
-%defattr(-, root, root, 0755)
-# Shared libraries (omit for architectures that don't support them)
-%{_libdir}/*.so*
-
-
-%files -n MySQL-test%{server_suffix}
-%defattr(-, root, root, 0755)
-%{_datadir}/mysql-test
-%attr(755, root, root) %{_bindir}/mysql_client_test
-%attr(755, root, root) %{_bindir}/mysqltestmanager
-%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen
-%attr(755, root, root) %{_bindir}/mysqltestmanagerc
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
-
-# The spec file changelog only includes changes made to the spec file
-# itself - note that they must be ordered by date (important when
-# merging BK trees)
-%changelog
-* Mon Jul 07 2008 Jonathan Perkin <jperkin@sun.com>
-
-- Add 'classic' product.
-
-* Wed Jun 11 2008 Kent Boortz <kent@mysql.com>
-
-- Removed the Example storage engine, it is not to be in products
-
-* Mon Feb 18 2008 Timothy Smith <tim@mysql.com>
-
-- Require a manual upgrade if the alread-installed mysql-server is
- from another vendor, or is of a different major version.
-
-* Fri Dec 14 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the "%doc" directive for all man pages and other documentation;
- also, some re-ordering to reduce differences between spec files.
-
-* Wed Oct 31 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Explicitly handle InnoDB using its own variable and "--with"/"--without"
- options, because the "configure" default is "yes".
-
-* Tue Jul 17 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the man page for "mysql-stress-test.pl" to the "test" RPM
- (consistency in fixing bug#21023, the script is handled by "Makefile.am")
-
-* Wed Jul 11 2007 Daniel Fischer <df@mysql.com>
-
-- Change the way broken SELinux policies on RHEL4 and CentOS 4
- are handled to be more likely to actually work
-
-* Thu Jun 05 2007 kent Boortz <kent@mysql.com>
-
-- Enabled the CSV engine in all builds
-
-* Thu May 3 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Spring cleanup
-
-* Thu Apr 19 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- If sbin/restorecon exists then run it
-
-* Wed Apr 18 2007 Kent Boortz <kent@mysql.com>
-
-- Packed unpacked files
-
- /usr/sbin/ndb_cpcd
- /usr/bin/mysql_upgrade_shell
- /usr/bin/innochecksum
- /usr/share/man/man1/ndb_cpcd.1.gz
- /usr/share/man/man1/innochecksum.1.gz
- /usr/share/man/man1/mysql_fix_extensions.1.gz
- /usr/share/man/man1/mysql_secure_installation.1.gz
- /usr/share/man/man1/mysql_tableinfo.1.gz
- /usr/share/man/man1/mysql_waitpid.1.gz
-
-- Commands currently not installed but that has man pages
-
- /usr/share/man/man1/make_win_bin_dist.1.gz
- /usr/share/man/man1/make_win_src_distribution.1.gz
- /usr/share/man/man1/mysql-stress-test.pl.1.gz
- /usr/share/man/man1/ndb_print_backup_file.1.gz
- /usr/share/man/man1/ndb_print_schema_file.1.gz
- /usr/share/man/man1/ndb_print_sys_file.1.gz
-
-* Thu Mar 22 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add "comment" options to the test runs, for better log analysis.
-
-* Wed Mar 21 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add even more man pages.
-
-* Fri Mar 16 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Build the server twice, once as "mysqld-debug" and once as "mysqld";
- test them both, and include them in the resulting file.
-- Consequences of the fix for bug#20166:
- Remove "mysql_create_system_tables",
- new "mysql_fix_privilege_tables.sql" is included implicitly.
-
-* Wed Mar 14 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options some more and change naming of community
- cluster RPMs to explicitly say 'cluster'.
-
-* Mon Mar 12 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options and other settings for 5.0 community builds.
-
-* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add several man pages which are now created.
-
-* Mon Jan 29 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Make sure SELinux works correctly. Files from Colin Charles.
-
-* Fri Jan 05 2007 Kent Boortz <kent@mysql.com>
-
-- Add CFLAGS to gcc call with --print-libgcc-file, to make sure the
- correct "libgcc.a" path is returned for the 32/64 bit architecture.
-
-* Tue Dec 19 2006 Joerg Bruehe <joerg@mysql.com>
-
-- The man page for "mysqld" is now in section 8.
-
-* Thu Dec 14 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Include the new man pages for "my_print_defaults" and "mysql_tzinfo_to_sql"
- in the server RPM.
-- The "mysqlmanager" man page was relocated to section 8, reflect that.
-
-* Fri Nov 17 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Really fix obsoletes/provides for community -> this
-- Make it possible to not run test by setting
- MYSQL_RPMBUILD_TEST to "no"
-
-* Wed Nov 15 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Switch from "make test*" to explicit calls of the test suite,
- so that "report features" can be used.
-
-* Wed Nov 15 2006 Kent Boortz <kent@mysql.com>
-
-- Added "--with cluster" and "--define cluster{_gpl}"
-
-* Tue Oct 24 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Shared need to Provide/Obsolete mysql-shared
-
-* Mon Oct 23 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Run sbin/restorecon after db init (Bug#12676)
-
-* Thu Jul 06 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Correct a typing error in my previous change.
-
-* Tue Jul 04 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Use the Perl script to run the tests, because it will automatically check
- whether the server is configured with SSL.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Revert all previous attempts to call "mysql_upgrade" during RPM upgrade,
- there are some more aspects which need to be solved before this is possible.
- For now, just ensure the binary "mysql_upgrade" is delivered and installed.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Move "mysqldumpslow" from the client RPM to the server RPM (bug#20216).
-
-* Wed Jun 21 2006 Joerg Bruehe <joerg@mysql.com>
-
-- To run "mysql_upgrade", we need a running server;
- start it in isolation and skip password checks.
-
-* Sat May 23 2006 Kent Boortz <kent@mysql.com>
-
-- Always compile for PIC, position independent code.
-
-* Fri Apr 28 2006 Kent Boortz <kent@mysql.com>
-
-- Install and run "mysql_upgrade"
-
-* Sat Apr 01 2006 Kent Boortz <kent@mysql.com>
-
-- Allow to override $LDFLAGS
-
-* Fri Jan 06 2006 Lenz Grimmer <lenz@mysql.com>
-
-- added a MySQL-test subpackage (BUG#16070)
-
-* Tue Dec 27 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Some minor alignment with the 4.1 version
-
-* Wed Dec 14 2005 Rodrigo Novo <rodrigo@mysql.com>
-
-- Cosmetic changes: source code location & rpm packager
-- Protect "nm -D" against libtool weirdness
-- Add libz.a & libz.la to the list of files for subpackage -devel
-- moved --with-zlib-dir=bundled out of BuildMySQL, as it doesn't makes
- sense for the shared package
-
-* Tue Nov 22 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Extend the file existence check for "init.d/mysql" on un-install
- to also guard the call to "insserv"/"chkconfig".
-
-* Wed Nov 16 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_client_test to the "client" subpackage (BUG#14546)
-
-* Tue Nov 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- changed default definitions to build a standard GPL release when not
- defining anything else
-- install the shared libs more elegantly by using "make install"
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Made yaSSL support an option (off by default)
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Enabled yaSSL support
-
-* Thu Oct 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added a usermod call to assign a potential existing mysql user to the
- correct user group (BUG#12823)
-- added a separate macro "mysqld_group" to be able to define the
- user group of the mysql user seperately, if desired.
-
-* Fri Oct 1 2005 Kent Boortz <kent@mysql.com>
-
-- Copy the config.log file to location outside
- the build tree
-
-* Fri Sep 30 2005 Lenz Grimmer <lenz@mysql.com>
-
-- don't use install-strip to install the binaries (strip segfaults on
- icc-compiled binaries on IA64)
-
-* Thu Sep 22 2005 Lenz Grimmer <lenz@mysql.com>
-
-- allow overriding the CFLAGS (needed for Intel icc compiles)
-- replace the CPPFLAGS=-DBIG_TABLES with "--with-big-tables" configure option
-
-* Fri Aug 19 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Protect against failing tests.
-
-* Thu Aug 04 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the creation of the mysql user group account in the postinstall
- section (BUG 12348)
-
-* Fri Jul 29 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed external RPM Requirements to better suit the target distribution
- (BUG 12233)
-
-* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- create a "mysql" user group and assign the mysql user account to that group
- in the server postinstall section. (BUG 10984)
-
-* Wed Jun 01 2005 Lenz Grimmer <lenz@mysql.com>
-
-- use "mysqldatadir" variable instead of hard-coding the path multiple times
-- use the "mysqld_user" variable on all occasions a user name is referenced
-- removed (incomplete) Brazilian translations
-- removed redundant release tags from the subpackage descriptions
-
-* Fri May 27 2005 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file list (removed libnisam.a and libmerge.a from the devel subpackage)
-- force running the test suite
-
-* Wed Apr 20 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Enabled the "blackhole" storage engine for the Max RPM
-
-* Wed Apr 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- removed the MySQL manual files (html/ps/texi) - they have been removed
- from the MySQL sources and are now available seperately.
-
-* Mon Apr 4 2005 Petr Chardin <petr@mysql.com>
-
-- old mysqlmanager, mysqlmanagerc and mysqlmanager-pwger renamed into
- mysqltestmanager, mysqltestmanager and mysqltestmanager-pwgen respectively
-
-* Fri Mar 18 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Disabled RAID in the Max binaries once and for all (it has finally been
- removed from the source tree)
-
-* Sun Feb 20 2005 Petr Chardin <petr@mysql.com>
-
-- Install MySQL Instance Manager together with mysqld, touch mysqlmanager
- password file
-
-* Mon Feb 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the compilation comments and moved them into the separate build sections
- for Max and Standard
-
-* Mon Feb 7 2005 Tomas Ulin <tomas@mysql.com>
-
-- enabled the "Ndbcluster" storage engine for the max binary
-- added extra make install in ndb subdir after Max build to get ndb binaries
-- added packages for ndbcluster storage engine
-
-* Fri Jan 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- replaced obsoleted "BuildPrereq" with "BuildRequires" instead
-
-* Thu Jan 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Federated" storage engine for the max binary
-
-* Tue Jan 04 2005 Petr Chardin <petr@mysql.com>
-
-- ISAM and merge storage engines were purged. As well as appropriate
- tools and manpages (isamchk and isamlog)
-
-* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Archive" storage engine for the max binary
-- enabled the "CSV" storage engine for the max binary
-- enabled the "Example" storage engine for the max binary
-
-* Thu Aug 26 2004 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860)
-
-* Fri Aug 20 2004 Lenz Grimmer <lenz@mysql.com>
-
-- do not link statically on IA64/AMD64 as these systems do not have
- a patched glibc installed
-
-* Tue Aug 10 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added libmygcc.a to the devel subpackage (required to link applications
- against the the embedded server libmysqld.a) (BUG 4921)
-
-* Mon Aug 09 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added EXCEPTIONS-CLIENT to the "devel" package
-
-* Thu Jul 29 2004 Lenz Grimmer <lenz@mysql.com>
-
-- disabled OpenSSL in the Max binaries again (the RPM packages were the
- only exception to this anyway) (BUG 1043)
-
-* Wed Jun 30 2004 Lenz Grimmer <lenz@mysql.com>
-
-- fixed server postinstall (mysql_install_db was called with the wrong
- parameter)
-
-* Thu Jun 24 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_tzinfo_to_sql to the server subpackage
-- run "make clean" instead of "make distclean"
-
-* Mon Apr 05 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added ncurses-devel to the build prerequisites (BUG 3377)
-
-* Thu Feb 12 2004 Lenz Grimmer <lenz@mysql.com>
-
-- when using gcc, _always_ use CXX=gcc
-- replaced Copyright with License field (Copyright is obsolete)
-
-* Tue Feb 03 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added myisam_ftdump to the Server package
-
-* Tue Jan 13 2004 Lenz Grimmer <lenz@mysql.com>
-
-- link the mysql client against libreadline instead of libedit (BUG 2289)
-
-* Mon Dec 22 2003 Lenz Grimmer <lenz@mysql.com>
-
-- marked /etc/logrotate.d/mysql as a config file (BUG 2156)
-
-* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file permissions (BUG 1672)
-
-* Thu Dec 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- made testing for gcc3 a bit more robust
-
-* Fri Dec 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_create_system_tables to the server subpackage
-
-* Fri Nov 21 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed dependency on MySQL-client from the MySQL-devel subpackage
- as it is not really required. (BUG 1610)
-
-* Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 1162 (removed macro names from the changelog)
-- Really fixed BUG 998 (disable the checking for installed but
- unpackaged files)
-
-* Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 959 (libmysqld not being compiled properly)
-- Fixed BUG 998 (RPM build errors): added missing files to the
- distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
- mysql_fix_privilege_tables.1), removed "-n" from install section.
-
-* Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed the GIF Icon (file was not included in the sources anyway)
-- removed unused variable shared_lib_version
-- do not run automake before building the standard binary
- (should not be necessary)
-- add server suffix '-standard' to standard binary (to be in line
- with the binary tarball distributions)
-- Use more RPM macros (_exec_prefix, _sbindir, _libdir, _sysconfdir,
- _datadir, _includedir) throughout the spec file.
-- allow overriding CC and CXX (required when building with other compilers)
-
-* Fri May 16 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-enabled RAID again
-
-* Wed Apr 30 2003 Lenz Grimmer <lenz@mysql.com>
-
-- disabled MyISAM RAID (--with-raid) - it throws an assertion which
- needs to be investigated first.
-
-* Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_secure_installation to server subpackage
- (BUG 141)
-
-* Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-added missing pre- and post(un)install scripts to server subpackage
-- added config file /etc/my.cnf to the file list (just for completeness)
-- make sure to create the datadir with 755 permissions
-
-* Mon Jan 27 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed unused CC and CXX variables
-- CFLAGS and CXXFLAGS should honor RPM_OPT_FLAGS
-
-* Fri Jan 24 2003 Lenz Grimmer <lenz@mysql.com>
-
-- renamed package "MySQL" to "MySQL-server"
-- fixed Copyright tag
-- added mysql_waitpid to client subpackage (required for mysql-test-run)
-
-* Wed Nov 27 2002 Lenz Grimmer <lenz@mysql.com>
-
-- moved init script from /etc/rc.d/init.d to /etc/init.d (the majority of
- Linux distributions now support this scheme as proposed by the LSB either
- directly or via a compatibility symlink)
-- Use new "restart" init script action instead of starting and stopping
- separately
-- Be more flexible in activating the automatic bootup - use insserv (on
- older SuSE versions) or chkconfig (Red Hat, newer SuSE versions and
- others) to create the respective symlinks
-
-* Wed Sep 25 2002 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL >= 4.0 to avoid version mismatches
- (mixing 3.23 and 4.0 packages)
-
-* Fri Aug 09 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Turn off OpenSSL in MySQL-Max for now until it works properly again
-- enable RAID for the Max binary instead
-- added compatibility link: safe_mysqld -> mysqld_safe to ease the
- transition from 3.23
-
-* Thu Jul 18 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Reworked the build steps a little bit: the Max binary is supposed
- to include OpenSSL, which cannot be linked statically, thus trying
- to statically link against a special glibc is futile anyway
-- because of this, it is not required to make yet another build run
- just to compile the shared libs (saves a lot of time)
-- updated package description of the Max subpackage
-- clean up the BuildRoot directory afterwards
-
-* Mon Jul 15 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Updated Packager information
-- Fixed the build options: the regular package is supposed to
- include InnoDB and linked statically, while the Max package
- should include BDB and SSL support
-
-* Fri May 03 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Use more RPM macros (e.g. infodir, mandir) to make the spec
- file more portable
-- reorganized the installation of documentation files: let RPM
- take care of this
-- reorganized the file list: actually install man pages along
- with the binaries of the respective subpackage
-- do not include libmysqld.a in the devel subpackage as well, if we
- have a special "embedded" subpackage
-- reworked the package descriptions
-
-* Mon Oct 8 2001 Monty
-
-- Added embedded server as a separate RPM
-
-* Fri Apr 13 2001 Monty
-
-- Added mysqld-max to the distribution
-
-* Tue Jan 2 2001 Monty
-
-- Added mysql-test to the bench package
-
-* Fri Aug 18 2000 Tim Smith <tim@mysql.com>
-
-- Added separate libmysql_r directory; now both a threaded
- and non-threaded library is shipped.
-
-* Wed Sep 28 1999 David Axmark <davida@mysql.com>
-
-- Added the support-files/my-example.cnf to the docs directory.
-
-- Removed devel dependency on base since it is about client
- development.
-
-* Wed Sep 8 1999 David Axmark <davida@mysql.com>
-
-- Cleaned up some for 3.23.
-
-* Thu Jul 1 1999 David Axmark <davida@mysql.com>
-
-- Added support for shared libraries in a separate sub
- package. Original fix by David Fox (dsfox@cogsci.ucsd.edu)
-
-- The --enable-assembler switch is now automatically disables on
- platforms there assembler code is unavailable. This should allow
- building this RPM on non i386 systems.
-
-* Mon Feb 22 1999 David Axmark <david@detron.se>
-
-- Removed unportable cc switches from the spec file. The defaults can
- now be overridden with environment variables. This feature is used
- to compile the official RPM with optimal (but compiler version
- specific) switches.
-
-- Removed the repetitive description parts for the sub rpms. Maybe add
- again if RPM gets a multiline macro capability.
-
-- Added support for a pt_BR translation. Translation contributed by
- Jorge Godoy <jorge@bestway.com.br>.
-
-* Wed Nov 4 1998 David Axmark <david@detron.se>
-
-- A lot of changes in all the rpm and install scripts. This may even
- be a working RPM :-)
-
-* Sun Aug 16 1998 David Axmark <david@detron.se>
-
-- A developers changelog for MySQL is available in the source RPM. And
- there is a history of major user visible changed in the Reference
- Manual. Only RPM specific changes will be documented here.
diff --git a/percona/5.0.77-b13/mysqld_safe_syslog.patch b/percona/5.0.77-b13/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.77-b13/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.77-b13/series b/percona/5.0.77-b13/series
deleted file mode 100644
index 39448fd..0000000
--- a/percona/5.0.77-b13/series
+++ /dev/null
@@ -1,16 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-#mirror_binlog.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_show_hashed_memory.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_dict_size_limit.patch
-split_buf_pool_mutex_fixed_optimistic_safe.patch
-innodb_rw_lock.patch
diff --git a/percona/5.0.77-b13/show_patches.patch b/percona/5.0.77-b13/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.77-b13/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.77-b13/split_buf_pool_mutex_fixed_optimistic_safe.patch b/percona/5.0.77-b13/split_buf_pool_mutex_fixed_optimistic_safe.patch
deleted file mode 100644
index 885e893..0000000
--- a/percona/5.0.77-b13/split_buf_pool_mutex_fixed_optimistic_safe.patch
+++ /dev/null
@@ -1,1314 +0,0 @@
-diff -r 2e0c46e78b50 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:33:59 2008 -0800
-@@ -548,6 +548,19 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_create(&(buf_pool->free_mutex));
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_NO_ORDER_CHECK);
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_NO_ORDER_CHECK);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -723,6 +736,10 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -859,12 +876,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->LRU_mutex));
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
- }
-
-@@ -880,7 +897,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -888,7 +905,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -899,7 +916,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -909,7 +926,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- }
-
- /*************************************************************************
-@@ -950,11 +967,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -971,7 +988,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -979,7 +996,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -998,7 +1015,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1008,7 +1025,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1050,7 +1067,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1058,7 +1075,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1079,7 +1096,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1087,7 +1104,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1166,26 +1183,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ // mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1204,7 +1228,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ // mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1216,7 +1240,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1233,7 +1257,9 @@
- LRU list and we must put it to awe_LRU_free_mapped list once
- mapped to a frame */
-
-+ mutex_enter_fast(&(buf_pool->mutex));
- buf_awe_map_page_to_frame(block, TRUE);
-+ mutex_exit(&buf_pool->mutex);
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -1241,7 +1267,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1791,7 +1817,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1806,7 +1833,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1821,10 +1849,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1873,7 +1905,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1884,7 +1917,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1907,6 +1941,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1918,7 +1953,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1932,7 +1967,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1968,6 +2003,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2050,9 +2086,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2061,9 +2094,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2094,6 +2130,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2102,10 +2140,25 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-+
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
-@@ -2131,6 +2184,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2138,9 +2194,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2168,11 +2221,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2191,10 +2244,22 @@
- ulint n_flush = 0;
- ulint n_free = 0;
- ulint n_page = 0;
-+ ulint n_single_flush_tmp = 0;
-+ ulint n_lru_flush_tmp = 0;
-+ ulint n_list_flush_tmp = 0;
-
- ut_ad(buf_pool);
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+
- mutex_enter(&(buf_pool->mutex));
-+ n_single_flush_tmp = buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE];
-+ n_list_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LIST];
-+ n_lru_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LRU];
-+ mutex_exit(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2262,11 +2327,14 @@
- }
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
-- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+ ut_a(n_single_flush_tmp == n_single_flush);
-+ ut_a(n_list_flush_tmp == n_list_flush);
-+ ut_a(n_lru_flush_tmp == n_lru_flush);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2298,7 +2366,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2351,7 +2421,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2386,8 +2458,6 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2403,7 +2473,6 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2431,7 +2500,9 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2439,7 +2510,9 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ratio);
- }
-@@ -2459,6 +2532,9 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -2532,6 +2608,9 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
- }
-
-@@ -2562,8 +2641,6 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2584,8 +2661,6 @@
-
- mutex_exit(&block->mutex);
- }
--
-- mutex_exit(&(buf_pool->mutex));
-
- return(TRUE);
- }
-@@ -2625,11 +2700,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Dec 22 00:33:59 2008 -0800
-@@ -117,12 +117,14 @@
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* I permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -536,18 +538,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +748,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +782,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +793,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -849,7 +853,14 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+
- for (;;) {
- /* If we have flushed enough, leave the loop */
- if (page_count >= min_n) {
-@@ -895,7 +906,10 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- old_page_count = page_count;
-
-@@ -908,7 +922,10 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -930,6 +947,13 @@
- break;
- }
- }
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex));
-
- (buf_pool->init_flush)[flush_type] = FALSE;
-
-@@ -989,10 +1013,14 @@
- buf_block_t* block;
- ulint n_replaceable;
- ulint distance = 0;
--
-- mutex_enter(&(buf_pool->mutex));
-+
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-+ //mutex_enter(&(buf_pool->free_mutex));
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-+
-+ //mutex_exit(&(buf_pool->free_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
-@@ -1014,7 +1042,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1033,8 +1061,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1044,7 +1073,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1094,11 +1123,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0lru.c Mon Dec 22 00:33:59 2008 -0800
-@@ -79,7 +79,10 @@
- ibool all_freed;
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -117,7 +120,10 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -147,7 +153,10 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -170,14 +179,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -186,7 +195,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -210,13 +219,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -231,9 +242,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -246,14 +265,25 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
- freed = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -264,13 +294,21 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-+ mutex_exit(&(buf_pool->mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- return(FALSE);
- }
- }
-+ if (!freed) {
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -322,7 +360,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -330,7 +369,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -353,7 +393,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex)); /* LRU info:optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -409,7 +449,7 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ block = UT_LIST_GET_LAST(buf_pool->free);
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-@@ -437,7 +477,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -449,7 +489,7 @@
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -486,7 +526,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -958,7 +998,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1001,7 +1041,10 @@
-
- if (buf_pool->LRU_old) {
- ut_a(buf_pool->LRU_old_len == old_len);
-- }
-+ }
-+
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
-@@ -1013,7 +1056,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1029,7 +1072,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1073,5 +1116,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0rea.c Mon Dec 22 00:33:59 2008 -0800
-@@ -236,10 +236,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -250,8 +252,9 @@
- recent_blocks++;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -347,7 +350,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -450,6 +453,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -463,6 +467,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -479,12 +484,13 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -492,10 +498,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -511,7 +518,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -587,7 +594,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -655,7 +662,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -727,7 +734,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r 2e0c46e78b50 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Dec 22 00:33:59 2008 -0800
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r 2e0c46e78b50 innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -112,7 +112,7 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -122,7 +122,7 @@
- lsn = block->oldest_modification;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -392,18 +392,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +425,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +433,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -632,9 +632,9 @@
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->flush_list_mutex);
- buf_flush_note_modification(block, mtr);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->flush_list_mutex);
- }
-
- mutex_enter(&block->mutex);
-diff -r 2e0c46e78b50 innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.h Mon Dec 22 00:33:59 2008 -0800
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r 2e0c46e78b50 innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -84,7 +84,7 @@
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
-@@ -102,5 +102,5 @@
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-diff -r 2e0c46e78b50 innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/log/log0recv.c Mon Dec 22 00:33:59 2008 -0800
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r 2e0c46e78b50 patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info Mon Dec 22 00:33:59 2008 -0800
-@@ -0,0 +1,6 @@
-+File=split_buf_pool_mutex_fixed_optimistic_safe.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.77-b13/userstatv2.patch b/percona/5.0.77-b13/userstatv2.patch
deleted file mode 100644
index a5efe3e..0000000
--- a/percona/5.0.77-b13/userstatv2.patch
+++ /dev/null
@@ -1,4441 +0,0 @@
-diff -r 23e5576aa59a BUILD/Makefile.in
---- a/BUILD/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/BUILD/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a Docs/Makefile.in
---- a/Docs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/Docs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a Makefile.in
---- a/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a SSL/Makefile.in
---- a/SSL/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/SSL/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a aclocal.m4
---- a/aclocal.m4 Tue Feb 17 22:33:00 2009 -0800
-+++ b/aclocal.m4 Tue Feb 17 22:33:23 2009 -0800
-@@ -4412,6 +4412,9 @@
- # Is the compiler the GNU C compiler?
- with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-+gcc_ver=\`gcc -dumpversion\`
-+
- # An ERE matcher.
- EGREP=$lt_EGREP
-
-@@ -4545,11 +4548,11 @@
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
--predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-+predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place after the objects being linked to create a
- # shared library.
--postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-+postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
-@@ -4561,7 +4564,7 @@
-
- # The library search path used internally by the compiler when linking
- # a shared library.
--compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-+compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Method to check whether dependent libraries are shared objects.
- deplibs_check_method=$lt_deplibs_check_method
-@@ -4641,7 +4644,7 @@
- link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
- # Compile-time system search path for libraries
--sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Run-time system search path for libraries
- sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-diff -r 23e5576aa59a client/Makefile.in
---- a/client/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/client/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/libedit/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -175,6 +175,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/readline/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a configure
---- a/configure Tue Feb 17 22:33:00 2009 -0800
-+++ b/configure Tue Feb 17 22:33:23 2009 -0800
-@@ -39583,7 +39583,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -42956,7 +43040,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 23e5576aa59a configure.in
---- a/configure.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/configure.in Tue Feb 17 22:33:23 2009 -0800
-@@ -2098,7 +2098,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2713,7 +2724,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 23e5576aa59a dbug/Makefile.in
---- a/dbug/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/dbug/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/Makefile.in
---- a/extra/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/testsuite/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a heap/Makefile.in
---- a/heap/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/heap/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a include/Makefile.in
---- a/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a include/mysql_com.h
---- a/include/mysql_com.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/include/mysql_com.h Tue Feb 17 22:33:23 2009 -0800
-@@ -106,6 +106,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 23e5576aa59a libmysql/Makefile.in
---- a/libmysql/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysql/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysql_r/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysqld/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysqld/examples/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a man/Makefile.in
---- a/man/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/man/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a myisam/Makefile.in
---- a/myisam/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/myisam/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/myisammrg/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/ndb/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/information_schema.result Tue Feb 17 22:33:23 2009 -0800
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- show global status like "Uptime_%";
- Variable_name Value
-diff -r 23e5576aa59a mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:23 2009 -0800
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 23e5576aa59a mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:23 2009 -0800
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 23e5576aa59a mysys/Makefile.in
---- a/mysys/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysys/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/Makefile.in
---- a/ndb/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/docs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/debugger/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/logger/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/mgmcommon/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/portlib/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/transporter/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/util/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/cw/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/cw/cpcd/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/error/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/vm/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmclient/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmsrv/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/ndbapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/ndbapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/ndbapi/bank/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/run-test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a netware/Makefile.in
---- a/netware/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/netware/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/Makefile.in
---- a/os2/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/include/Makefile.in
---- a/os2/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/include/sys/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Tue Feb 17 22:33:23 2009 -0800
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 23e5576aa59a pstack/Makefile.in
---- a/pstack/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/pstack/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/pstack/aout/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a regex/Makefile.in
---- a/regex/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/regex/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a scripts/Makefile.in
---- a/scripts/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/scripts/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a server-tools/Makefile.in
---- a/server-tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/server-tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/server-tools/instance-manager/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/Makefile.in
---- a/sql/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -3324,6 +3324,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3596,6 +3598,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3643,6 +3647,8 @@
- innodb_srv_conc_enter_innodb(prebuilt->trx);
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-+
-+ if (error == DB_SUCCESS) rows_changed++;
-
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
-@@ -4076,6 +4082,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 23e5576aa59a sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/ha_myisam.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1518,13 +1520,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1535,6 +1541,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1545,6 +1558,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1555,6 +1575,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1565,6 +1592,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1575,6 +1609,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1585,6 +1626,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1595,6 +1643,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1611,6 +1666,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1628,6 +1690,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1642,6 +1705,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 23e5576aa59a sql/handler.cc
---- a/sql/handler.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/handler.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -725,6 +725,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -829,6 +831,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- if (all)
- thd->transaction_rollback_request= FALSE;
-@@ -1212,6 +1215,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1442,6 +1446,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2276,6 +2282,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 23e5576aa59a sql/handler.h
---- a/sql/handler.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/handler.h Tue Feb 17 22:33:23 2009 -0800
-@@ -30,6 +30,10 @@
- #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
- defined(HAVE_NDBCLUSTER_DB)
- #define USING_TRANSACTIONS
-+#endif
-+
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
- #endif
-
- // the following is for checking tables
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 23e5576aa59a sql/lex.h
---- a/sql/lex.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/lex.h Tue Feb 17 22:33:23 2009 -0800
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 23e5576aa59a sql/log.cc
---- a/sql/log.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/log.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -1954,18 +1954,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1981,6 +1987,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1991,6 +1999,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2112,6 +2122,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2158,6 +2169,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2226,6 +2238,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2234,6 +2248,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 23e5576aa59a sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/mysql_priv.h Tue Feb 17 22:33:23 2009 -0800
-@@ -823,7 +823,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1402,6 +1410,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1432,6 +1441,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1479,6 +1489,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 23e5576aa59a sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -415,6 +415,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -451,6 +452,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -551,6 +553,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1192,6 +1198,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1306,6 +1316,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3153,6 +3167,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3424,6 +3442,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3506,6 +3528,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4232,6 +4256,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5050,6 +5075,7 @@
- OPT_PROFILING,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6498,6 +6524,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 23e5576aa59a sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -828,6 +829,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1174,6 +1176,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 23e5576aa59a sql/share/Makefile.in
---- a/sql/share/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/share/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/sql_base.cc
---- a/sql/sql_base.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_base.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 23e5576aa59a sql/sql_class.cc
---- a/sql/sql_class.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_class.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -236,6 +236,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -369,6 +376,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -408,6 +497,9 @@
-
- void THD::change_user(void)
- {
-+ pthread_mutex_lock(&LOCK_status);
-+ add_to_status(&global_status_var, &status_var);
-+ pthread_mutex_unlock(&LOCK_status);
- cleanup();
- cleanup_done= 0;
- init();
-@@ -892,6 +984,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1062,6 +1181,7 @@
- }
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1154,6 +1274,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2088,6 +2209,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2095,6 +2217,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 23e5576aa59a sql/sql_class.h
---- a/sql/sql_class.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_class.h Tue Feb 17 22:33:23 2009 -0800
-@@ -1299,6 +1299,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1488,6 +1490,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1594,6 +1598,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1649,6 +1696,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1878,7 +1930,13 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-+
-+ char *get_client_host_port(THD *client);
-
- public:
- /**
-@@ -1922,6 +1980,11 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-+#define LIST_PROCESS_HOST_LEN 64
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 23e5576aa59a sql/sql_delete.cc
---- a/sql/sql_delete.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_delete.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -869,6 +870,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 23e5576aa59a sql/sql_insert.cc
---- a/sql/sql_insert.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_insert.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -989,6 +989,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3036,6 +3037,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 23e5576aa59a sql/sql_lex.h
---- a/sql/sql_lex.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_lex.h Tue Feb 17 22:33:23 2009 -0800
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 23e5576aa59a sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -145,6 +151,17 @@
- #ifndef EMBEDDED_LIBRARY
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-+
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- net->vio && net->error && net->report_error)
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4428,6 +4883,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4735,6 +5199,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5571,6 +6036,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5606,6 +6072,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5638,11 +6105,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5676,6 +6147,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5708,6 +6180,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5739,6 +6212,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5792,8 +6271,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5810,9 +6289,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6321,6 +6803,30 @@
- */
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
-@@ -6400,6 +6906,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7411,8 +7954,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 23e5576aa59a sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_prepare.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -80,6 +80,9 @@
- #else
- #include <mysql_com.h>
- #endif
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-
- /* A result class used to send cursor rows using the binary protocol. */
-
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #ifdef ENABLED_PROFILING
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2502,6 +2716,43 @@
- stmt->state= Query_arena::PREPARED;
-
- send_ok(thd);
-+
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-
- DBUG_VOID_RETURN;
- }
-diff -r 23e5576aa59a sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -530,6 +530,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1872,6 +1873,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4482,6 +4777,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4491,6 +4857,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4499,6 +4867,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4524,10 +4894,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 23e5576aa59a sql/sql_update.cc
---- a/sql/sql_update.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_update.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 23e5576aa59a sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_yacc.yy Tue Feb 17 22:33:23 2009 -0800
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8244,6 +8249,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8448,9 +8485,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9439,6 +9481,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9491,6 +9534,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9600,6 +9644,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9616,6 +9661,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9636,6 +9682,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 23e5576aa59a sql/structs.h
---- a/sql/structs.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/structs.h Tue Feb 17 22:33:23 2009 -0800
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[USERNAME_LENGTH + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[USERNAME_LENGTH + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 23e5576aa59a sql/table.h
---- a/sql/table.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/table.h Tue Feb 17 22:33:23 2009 -0800
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 23e5576aa59a strings/Makefile.in
---- a/strings/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/strings/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/MacOSX/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/Makefile.in
---- a/support-files/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/RHEL4-SElinux/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a tests/Makefile.in
---- a/tests/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/tests/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a tools/Makefile.in
---- a/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a vio/Makefile.in
---- a/vio/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/vio/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a win/Makefile.in
---- a/win/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/win/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a zlib/Makefile.in
---- a/zlib/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/zlib/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.77-b16/innodb_check_fragmentation.patch b/percona/5.0.77-b16/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.77-b16/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.77-b16/innodb_dict_size_limit.patch b/percona/5.0.77-b16/innodb_dict_size_limit.patch
deleted file mode 100644
index 8ef4e36..0000000
--- a/percona/5.0.77-b16/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,477 +0,0 @@
-diff -ru mysql-5.0.75_base/innobase/dict/dict0boot.c mysql-5.0.75/innobase/dict/dict0boot.c
---- mysql-5.0.75_base/innobase/dict/dict0boot.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0boot.c 2009-01-23 19:28:25.000000000 +0900
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0crea.c mysql-5.0.75/innobase/dict/dict0crea.c
---- mysql-5.0.75_base/innobase/dict/dict0crea.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0crea.c 2009-01-23 19:41:38.000000000 +0900
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1266,6 +1269,11 @@
-
- trx->op_info = "";
-
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0dict.c mysql-5.0.75/innobase/dict/dict0dict.c
---- mysql-5.0.75_base/innobase/dict/dict0dict.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0dict.c 2009-01-26 16:03:29.000000000 +0900
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -787,6 +791,8 @@
- table->n_mysql_handles_opened++;
- }
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-
-- ut_error;
-+ //ut_error;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1341,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-diff -ru mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c
---- mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c 2009-01-23 11:44:18.000000000 +0900
-+++ mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c 2009-01-23 19:22:54.000000000 +0900
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.h mysql-5.0.75/innobase/include/dict0dict.h
---- mysql-5.0.75_base/innobase/include/dict0dict.h 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.h 2009-01-23 21:46:22.000000000 +0900
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.ic mysql-5.0.75/innobase/include/dict0dict.ic
---- mysql-5.0.75_base/innobase/include/dict0dict.ic 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.ic 2009-01-23 18:35:55.000000000 +0900
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -ru mysql-5.0.75_base/innobase/include/srv0srv.h mysql-5.0.75/innobase/include/srv0srv.h
---- mysql-5.0.75_base/innobase/include/srv0srv.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/include/srv0srv.h 2009-01-27 10:47:26.000000000 +0900
-@@ -146,6 +146,8 @@
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-
-+extern ulint srv_dict_size_limit;
-+
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
- extern ulong srv_io_pattern_trace_running;
-@@ -545,6 +547,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -ru mysql-5.0.75_base/innobase/srv/srv0srv.c mysql-5.0.75/innobase/srv/srv0srv.c
---- mysql-5.0.75_base/innobase/srv/srv0srv.c 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/srv/srv0srv.c 2009-01-27 10:52:19.000000000 +0900
-@@ -345,6 +345,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-
-+ulint srv_dict_size_limit = 0;
-+
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
- ulint srv_io_pattern_trace_running = 0;
-@@ -1936,6 +1938,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -ru mysql-5.0.75_base/sql/ha_innodb.cc mysql-5.0.75/sql/ha_innodb.cc
---- mysql-5.0.75_base/sql/ha_innodb.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.cc 2009-01-27 10:54:08.000000000 +0900
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -ru mysql-5.0.75_base/sql/ha_innodb.h mysql-5.0.75/sql/ha_innodb.h
---- mysql-5.0.75_base/sql/ha_innodb.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.h 2009-01-26 15:49:37.000000000 +0900
-@@ -242,6 +242,7 @@
- extern ulong srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -ru mysql-5.0.75_base/sql/mysqld.cc mysql-5.0.75/sql/mysqld.cc
---- mysql-5.0.75_base/sql/mysqld.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/mysqld.cc 2009-01-26 15:29:45.000000000 +0900
-@@ -5053,6 +5053,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_RPL_MIRROR_BINLOG,
- OPT_SYNC_MIRROR_BINLOG,
-@@ -5406,6 +5407,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -ru mysql-5.0.75_base/sql/set_var.cc mysql-5.0.75/sql/set_var.cc
---- mysql-5.0.75_base/sql/set_var.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/set_var.cc 2009-01-26 15:46:45.000000000 +0900
-@@ -522,6 +522,8 @@
- &innodb_read_ahead_typelib, fix_innodb_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -905,6 +907,7 @@
- &sys_innodb_flush_neighbor_pages,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1056,6 +1059,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
-diff -ruN mysql-5.0.75_base/mysql-test/r/innodb_dict_size_limit.result mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result 2009-01-27 11:43:46.000000000 +0900
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -ruN mysql-5.0.75_base/mysql-test/t/innodb_dict_size_limit.test mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test 2009-01-27 11:43:36.000000000 +0900
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -ruN mysql-5.0.75_base/patch_info/innodb_dict_size_limit.info mysql-5.0.75/patch_info/innodb_dict_size_limit.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/patch_info/innodb_dict_size_limit.info 2009-01-26 15:46:45.000000000 +0900
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
diff --git a/percona/5.0.77-b16/innodb_extra_rseg.patch b/percona/5.0.77-b16/innodb_extra_rseg.patch
deleted file mode 100644
index 1c8f429..0000000
--- a/percona/5.0.77-b16/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 13:37:45.000000000 +0900
-@@ -147,6 +147,8 @@
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-
-+extern ulint srv_extra_rsegments;
-+
- extern ulint srv_dict_size_limit;
-
- extern volatile ibool srv_io_pattern;
-diff -ruN a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/include/trx0sys.h 2009-05-06 14:52:00.000000000 +0900
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 13:38:23.000000000 +0900
-@@ -347,6 +347,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-+
- ulint srv_dict_size_limit = 0;
-
- volatile ibool srv_io_pattern = FALSE;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 14:54:43.000000000 +0900
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -ruN a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/trx/trx0sys.c 2009-05-06 14:54:02.000000000 +0900
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -ruN a/patch_info/innodb_extra_rseg.info b/patch_info/innodb_extra_rseg.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_extra_rseg.info 2009-05-06 14:49:48.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:27:49.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1507,6 +1508,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 13:51:35.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 14:12:05.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_RPL_MIRROR_BINLOG,
-@@ -5454,6 +5455,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 14:13:24.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
---- a/sql/sql_show.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/sql_show.cc 2009-05-06 15:29:47.000000000 +0900
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4160,6 +4162,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4978,6 +5019,16 @@
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
- #endif
-
- ST_FIELD_INFO variables_fields_info[]=
-@@ -5157,6 +5208,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.77-b16/innodb_fsync_source.patch b/percona/5.0.77-b16/innodb_fsync_source.patch
deleted file mode 100644
index 637a7d6..0000000
--- a/percona/5.0.77-b16/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r 61031ebb48ce innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Nov 03 05:07:56 2008 -0800
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r 61031ebb48ce innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/fil/fil0fil.c Mon Nov 03 05:07:56 2008 -0800
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4166,8 +4187,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4176,7 +4198,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4281,7 +4303,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4322,7 +4345,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r 61031ebb48ce innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/fil0fil.h Mon Nov 03 05:07:56 2008 -0800
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -621,14 +628,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -636,7 +655,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r 61031ebb48ce innobase/include/log0log.h
---- a/innobase/include/log0log.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/log0log.h Mon Nov 03 05:07:56 2008 -0800
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
-@@ -744,6 +767,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r 61031ebb48ce innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:07:56 2008 -0800
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1551,7 +1567,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1921,11 +1937,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1938,7 +1954,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2566,7 +2583,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2647,7 +2664,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3184,8 +3202,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3218,7 +3236,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3331,15 +3349,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r 61031ebb48ce innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:07:56 2008 -0800
-@@ -1638,6 +1638,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r 61031ebb48ce innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0sys.c Mon Nov 03 05:07:56 2008 -0800
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r 61031ebb48ce innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0trx.c Mon Nov 03 05:07:56 2008 -0800
-@@ -916,19 +916,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1659,18 +1661,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1906,19 +1911,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r 61031ebb48ce patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Mon Nov 03 05:07:56 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.77-b16/innodb_io_patches.patch b/percona/5.0.77-b16/innodb_io_patches.patch
deleted file mode 100644
index ba5ff74..0000000
--- a/percona/5.0.77-b16/innodb_io_patches.patch
+++ /dev/null
@@ -1,704 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-01-30 06:42:14.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-05-06 10:06:28.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-05-06 10:04:12.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-05-06 10:06:28.000000000 +0900
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +189,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +400,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-01-30 06:42:16.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-05-06 10:06:28.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-05-06 10:04:12.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-05-06 10:06:28.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 10:04:12.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 10:19:25.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern ulint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2009-01-30 06:42:21.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-05-06 10:06:28.000000000 +0900
-@@ -3326,6 +3326,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-05-06 10:04:12.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-05-06 10:06:28.000000000 +0900
-@@ -2877,8 +2877,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2888,6 +2890,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2898,8 +2902,8 @@
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-@@ -3180,6 +3184,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3198,6 +3209,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3205,6 +3226,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 10:04:12.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 10:20:45.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -324,6 +326,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2223,6 +2243,8 @@
- ibool skip_sleep = FALSE;
- ulint i;
-
-+ dulint oldest_lsn;
-+
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
-@@ -2311,9 +2333,9 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-@@ -2326,7 +2348,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2335,6 +2357,49 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ } else if (srv_adaptive_checkpoint) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2361,10 +2426,10 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2374,7 +2439,7 @@
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2416,14 +2481,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2512,7 +2577,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2529,7 +2594,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-01-30 06:42:23.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 10:06:28.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ srv_n_read_io_threads, srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS * 8);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-05-06 10:06:28.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 10:04:19.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 10:52:16.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1403,6 +1404,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7317,6 +7320,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 10:04:12.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 10:22:01.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,14 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern ulong srv_adaptive_checkpoint;
- }
-
- bool innobase_init(void);
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 10:04:19.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 10:33:23.000000000 +0900
-@@ -5080,6 +5080,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED
- };
-@@ -5388,6 +5398,45 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. 0:disable 1:enable",
-+ (gptr*) &srv_adaptive_checkpoint, (gptr*) &srv_adaptive_checkpoint,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7607,6 +7656,22 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 10:04:19.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 10:40:03.000000000 +0900
-@@ -486,6 +486,39 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -850,6 +883,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -985,6 +1025,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -1443,6 +1493,13 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-05-06 10:04:12.000000000 +0900
-+++ b/sql/set_var.h 2009-05-06 10:06:28.000000000 +0900
-@@ -31,6 +31,10 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1152,9 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.77-b16/innodb_io_pattern.patch b/percona/5.0.77-b16/innodb_io_pattern.patch
deleted file mode 100644
index 26c9b69..0000000
--- a/percona/5.0.77-b16/innodb_io_pattern.patch
+++ /dev/null
@@ -1,688 +0,0 @@
-diff -r 5060df9888d7 include/mysql_com.h
---- a/include/mysql_com.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/include/mysql_com.h Tue Feb 17 22:33:58 2009 -0800
-@@ -121,6 +121,9 @@
- #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-+
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-diff -r 5060df9888d7 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/buf/buf0buf.c Tue Feb 17 22:33:58 2009 -0800
-@@ -653,6 +653,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1966,6 +1969,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2067,6 +2073,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2082,6 +2108,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2656,3 +2702,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r 5060df9888d7 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0buf.h Tue Feb 17 22:33:58 2009 -0800
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r 5060df9888d7 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0types.h Tue Feb 17 22:33:58 2009 -0800
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r 5060df9888d7 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:58 2009 -0800
-@@ -145,6 +145,11 @@
- extern ulint srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r 5060df9888d7 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:58 2009 -0800
-@@ -344,6 +344,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r 5060df9888d7 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema.result Tue Feb 17 22:33:58 2009 -0800
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r 5060df9888d7 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:58 2009 -0800
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r 5060df9888d7 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:58 2009 -0800
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r 5060df9888d7 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Tue Feb 17 22:33:58 2009 -0800
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r 5060df9888d7 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -1569,6 +1569,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6535,6 +6537,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r 5060df9888d7 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:58 2009 -0800
-@@ -244,6 +244,9 @@
- extern ulong srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- }
-
- bool innobase_init(void);
-@@ -270,6 +273,9 @@
- bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-+
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-
- void innobase_release_temporary_latches(THD *thd);
-
-diff -r 5060df9888d7 sql/lex.h
---- a/sql/lex.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/lex.h Tue Feb 17 22:33:58 2009 -0800
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r 5060df9888d7 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -5026,6 +5026,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5445,6 +5448,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 5060df9888d7 sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -528,6 +528,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -901,6 +907,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1047,6 +1056,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
-@@ -3160,6 +3172,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r 5060df9888d7 sql/set_var.h
---- a/sql/set_var.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.h Tue Feb 17 22:33:58 2009 -0800
-@@ -989,6 +989,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r 5060df9888d7 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -8009,6 +8009,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 5060df9888d7 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -32,6 +32,17 @@
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
- #endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
-@@ -4088,6 +4099,67 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4894,6 +4966,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5069,6 +5154,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 5060df9888d7 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_yacc.yy Tue Feb 17 22:33:58 2009 -0800
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8541,6 +8542,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9594,6 +9596,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.77-b16/innodb_locks_held.patch b/percona/5.0.77-b16/innodb_locks_held.patch
deleted file mode 100644
index a4ae8ab..0000000
--- a/percona/5.0.77-b16/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r 7d3d7786b927 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:47 2009 -0800
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r 7d3d7786b927 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/lock/lock0lock.c Tue Feb 17 22:33:47 2009 -0800
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r 7d3d7786b927 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:33:33 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:47 2009 -0800
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1703,24 +1705,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1813,6 +1797,25 @@
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-+
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
-diff -r 7d3d7786b927 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/libmysqld/set_var.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -821,6 +821,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -936,6 +938,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r 7d3d7786b927 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Tue Feb 17 22:33:47 2009 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r 7d3d7786b927 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:47 2009 -0800
-@@ -242,6 +242,8 @@
- extern ulong srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
- }
-
- bool innobase_init(void);
-diff -r 7d3d7786b927 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -5012,6 +5012,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5356,6 +5358,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r 7d3d7786b927 sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:33 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:47 2009 -0800
-@@ -522,6 +522,12 @@
- &innodb_read_ahead_typelib, fix_innodb_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -893,6 +899,8 @@
- &sys_innodb_flush_neighbor_pages,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1008,6 +1016,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.77-b16/innodb_rw_lock.patch b/percona/5.0.77-b16/innodb_rw_lock.patch
deleted file mode 100644
index e45fccd..0000000
--- a/percona/5.0.77-b16/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.77-b16/innodb_show_bp.patch b/percona/5.0.77-b16/innodb_show_bp.patch
deleted file mode 100644
index a56ae9a..0000000
--- a/percona/5.0.77-b16/innodb_show_bp.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,13 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.77-b16/innodb_show_hashed_memory.patch b/percona/5.0.77-b16/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.77-b16/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.77-b16/innodb_thread_concurrency_timer_based.patch b/percona/5.0.77-b16/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 5e26818..0000000
--- a/percona/5.0.77-b16/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.77-b16/microsec_process.patch b/percona/5.0.77-b16/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.77-b16/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.77-b16/microslow_innodb.patch b/percona/5.0.77-b16/microslow_innodb.patch
deleted file mode 100644
index bc47291..0000000
--- a/percona/5.0.77-b16/microslow_innodb.patch
+++ /dev/null
@@ -1,2484 +0,0 @@
-diff -r 04958490fc6d include/my_getopt.h
---- a/include/my_getopt.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/include/my_getopt.h Tue Feb 17 22:33:00 2009 -0800
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 04958490fc6d include/my_time.h
---- a/include/my_time.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/include/my_time.h Tue Feb 17 22:33:00 2009 -0800
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 04958490fc6d innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/buf/buf0buf.c Tue Feb 17 22:33:00 2009 -0800
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1089,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1141,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1157,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1189,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1302,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1275,6 +1321,12 @@
-
- break;
- }
-+ }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
- }
- }
-
-@@ -1296,12 +1348,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1383,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,13 +1498,18 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-@@ -1470,6 +1533,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1558,6 +1622,11 @@
- || (ibuf_count_get(block->space, block->offset) == 0));
- #endif
- buf_pool->n_page_gets++;
-+
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-
- return(TRUE);
- }
-diff -r 04958490fc6d innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/buf/buf0rea.c Tue Feb 17 22:33:00 2009 -0800
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 04958490fc6d innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/fil/fil0fil.c Tue Feb 17 22:33:00 2009 -0800
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 04958490fc6d innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/buf0rea.h Tue Feb 17 22:33:00 2009 -0800
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 04958490fc6d innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/fil0fil.h Tue Feb 17 22:33:00 2009 -0800
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 04958490fc6d innobase/include/os0file.h
---- a/innobase/include/os0file.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/os0file.h Tue Feb 17 22:33:00 2009 -0800
-@@ -10,6 +10,8 @@
- #define os0file_h
-
- #include "univ.i"
-+
-+#include "trx0types.h"
-
- #ifndef __WIN__
- #include <dirent.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 04958490fc6d innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:00 2009 -0800
-@@ -26,6 +26,8 @@
- at a time */
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-+
-+extern ibool srv_slow_log;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-diff -r 04958490fc6d innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/include/trx0trx.h Tue Feb 17 22:33:00 2009 -0800
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 04958490fc6d innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/lock/lock0lock.c Tue Feb 17 22:33:00 2009 -0800
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 04958490fc6d innobase/os/os0file.c
---- a/innobase/os/os0file.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/os/os0file.c Tue Feb 17 22:33:00 2009 -0800
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1904,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1918,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1947,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1967,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1980,6 +2003,13 @@
- os_mutex_enter(os_file_count_mutex);
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-+
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- return(ret);
- }
-@@ -2103,7 +2133,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2143,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2208,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3168,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3422,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3462,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3496,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 04958490fc6d innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:00 2009 -0800
-@@ -47,6 +47,8 @@
- #include "dict0boot.h"
- #include "srv0start.h"
- #include "row0mysql.h"
-+
-+ibool srv_slow_log = 0;
-
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
-@@ -996,6 +998,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1054,6 +1060,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1109,11 +1116,22 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-+
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-
- os_fast_mutex_lock(&srv_conc_mutex);
-
-diff -r 04958490fc6d innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/innobase/trx/trx0trx.c Tue Feb 17 22:33:00 2009 -0800
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 04958490fc6d mysys/my_getopt.c
---- a/mysys/my_getopt.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/mysys/my_getopt.c Tue Feb 17 22:33:00 2009 -0800
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1061,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 04958490fc6d patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Tue Feb 17 22:33:00 2009 -0800
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 04958490fc6d scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Tue Feb 17 22:32:27 2009 -0800
-+++ b/scripts/mysqldumpslow.sh Tue Feb 17 22:33:00 2009 -0800
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 04958490fc6d sql-common/my_time.c
---- a/sql-common/my_time.c Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql-common/my_time.c Tue Feb 17 22:33:00 2009 -0800
-@@ -1252,3 +1252,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 04958490fc6d sql/filesort.cc
---- a/sql/filesort.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/filesort.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 04958490fc6d sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -805,9 +806,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1309,6 +1335,8 @@
- }
-
- /* -------------- Log files ---------------------------*/
-+
-+ srv_slow_log = (ibool) opt_slow_log;
-
- /* The default dir for log files is the datadir of MySQL */
-
-@@ -4681,6 +4709,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4946,6 +4980,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5033,6 +5073,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5097,6 +5143,12 @@
-
- if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) {
- trx->check_foreigns = FALSE;
-+ }
-+
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
- }
-
- name_len1 = strlen(from);
-@@ -6106,6 +6158,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6229,7 +6282,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 04958490fc6d sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:00 2009 -0800
-@@ -266,6 +266,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 04958490fc6d sql/log.cc
---- a/sql/log.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/log.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2284,11 +2284,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2298,7 +2299,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2328,22 +2330,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 04958490fc6d sql/log_event.cc
---- a/sql/log_event.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/log_event.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2039,6 +2039,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 04958490fc6d sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/mysql_priv.h Tue Feb 17 22:33:00 2009 -0800
-@@ -494,6 +494,78 @@
- #define WEEK_FIRST_WEEKDAY 4
-
- #define STRING_BUFFER_USUAL_SIZE 80
-+
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-
- enum enum_parsing_place
- {
-@@ -1351,6 +1423,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1362,7 +1435,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 04958490fc6d sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -175,7 +175,6 @@
- static void getvolumename();
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
--
-
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
-@@ -409,10 +408,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -507,6 +509,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -584,7 +587,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3693,6 +3696,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4943,7 +4948,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5034,11 +5039,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5428,8 +5440,17 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
-@@ -5795,6 +5816,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6097,11 +6121,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6878,7 +6922,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7339,6 +7387,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7671,10 +7748,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 04958490fc6d sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -694,6 +714,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -717,6 +741,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -770,6 +795,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -986,8 +1013,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1014,6 +1044,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1101,6 +1132,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1141,6 +1174,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1769,6 +1803,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1924,6 +1969,19 @@
- value= *(longlong*) value_ptr(thd, var_type, base);
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
-+ }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
- }
- case SHOW_HA_ROWS:
- {
-@@ -2757,6 +2815,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3526,6 +3608,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 04958490fc6d sql/set_var.h
---- a/sql/set_var.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/set_var.h Tue Feb 17 22:33:00 2009 -0800
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -377,7 +383,6 @@
- SHOW_TYPE show_type() { return SHOW_HA_ROWS; }
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
--
-
- class sys_var_thd_ulonglong :public sys_var_thd
- {
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -477,6 +495,66 @@
- ulong *length);
- };
-
-+
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-
- class sys_var_thd_storage_engine :public sys_var_thd
- {
-@@ -1087,3 +1165,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 04958490fc6d sql/slave.cc
---- a/sql/slave.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/slave.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -2925,6 +2925,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 04958490fc6d sql/sql_cache.cc
---- a/sql/sql_cache.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_cache.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1341,6 +1341,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1348,6 +1349,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 04958490fc6d sql/sql_class.cc
---- a/sql/sql_class.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_class.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -188,7 +188,7 @@
- lock_id(&main_lock_id),
- user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2224,6 +2224,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2240,7 +2246,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2293,6 +2305,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 04958490fc6d sql/sql_class.h
---- a/sql/sql_class.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_class.h Tue Feb 17 22:33:00 2009 -0800
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1128,6 +1133,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1184,6 +1195,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1292,10 +1308,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1685,11 +1715,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 04958490fc6d sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,27 +2363,55 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-+ ulonglong start_of_query_timer= thd->start_timer;
- thd->end_time(); // Set start time
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time ||
-- (thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END)
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2664,6 +2702,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6084,6 +6124,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 04958490fc6d sql/sql_select.cc
---- a/sql/sql_select.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_select.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -6224,8 +6224,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6240,8 +6243,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9305,6 +9311,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10165,6 +10172,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 04958490fc6d sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:00 2009 -0800
-@@ -1544,6 +1544,12 @@
- value= ((char *) status_var + (ulonglong) value);
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
-+ break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
- break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
-diff -r 04958490fc6d sql/structs.h
---- a/sql/structs.h Tue Feb 17 22:32:27 2009 -0800
-+++ b/sql/structs.h Tue Feb 17 22:33:00 2009 -0800
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.77-b16/mirror_binlog.patch b/percona/5.0.77-b16/mirror_binlog.patch
deleted file mode 100644
index 4dae799..0000000
--- a/percona/5.0.77-b16/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5036,6 +5037,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED
- };
-
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.77-b16/mysql-percona.rhel5.spec b/percona/5.0.77-b16/mysql-percona.rhel5.spec
deleted file mode 100644
index f13d322..0000000
--- a/percona/5.0.77-b16/mysql-percona.rhel5.spec
+++ /dev/null
@@ -1,1417 +0,0 @@
-%define mysql_vendor Percona Inc
-%{!?redhat_version:%define redhat_version 5}
-%define distribution rhel%{redhat_version}
-%define release 0.%{distribution}
-%define patchset b16
-
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'perconahighperf 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'percona 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-
-# Meta information
-# norootforbuild
-
-# use "rpmbuild --with yassl" or "rpm --define '_with_yassl 1'" (for RPM 3.x)
-# to build with yaSSL support (off by default)
-%{?_with_yassl:%define YASSL_BUILD 1}
-%{!?_with_yassl:%define YASSL_BUILD 0}
-
-# FIXME disabled until we move out the version strings from spec file
-## use "rpmbuild --with cluster" or "rpm --define '_with_cluster 1'" (for RPM 3.x)
-## to build with cluster support (off by default)
-##%{?_with_cluster:%define CLUSTER_BUILD 1}
-##%{!?_with_cluster:%define CLUSTER_BUILD 0}
-
-#
-# Product definitions - one of these has to be defined via the RPM build
-# options, e.g. "--define 'enterprise 1'"
-#
-%{!?enterprise:%define enterprise 0}
-%{!?enterprise_gpl:%define enterprise_gpl 0}
-%{!?classic:%define classic 0}
-%{!?cluster:%define cluster 0}
-%{!?cluster_gpl:%define cluster_gpl 0}
-%{!?community:%define community 0}
-%{!?percona:%define percona 0}
-%{!?perconahighperf:%define perconahighperf 0}
-%{!?mysqlversion:%define mysqlversion 5.0.67}
-#%define mysql_version 5.0.67
-
-# On SuSE 9 no separate "debuginfo" package is built. To enable basic
-# debugging on that platform, we don't strip binaries on SuSE 9. We
-# disable the strip of binaries by redefining the RPM macro
-# "__os_install_post" leaving out the script calls that normally does
-# this. We do this in all cases, as on platforms where "debuginfo" is
-# created, a script "find-debuginfo.sh" will be called that will do
-# the strip anyway, part of separating the executable and debug
-# information into separate files put into separate packages.
-#
-# Some references (shows more advanced conditional usage):
-# http://www.redhat.com/archives/rpm-list/2001-November/msg00257.html
-# http://www.redhat.com/archives/rpm-list/2003-February/msg00275.html
-# http://www.redhat.com/archives/rhl-devel-list/2004-January/msg01546.html
-# http://lists.opensuse.org/archive/opensuse-commit/2006-May/1171.html
-
-%define __os_install_post /usr/lib/rpm/brp-compress
-
-
-%if %{percona}
-%define comment MySQL Percona Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-%{patchset}
-%endif
-
-%if %{perconahighperf}
-%define comment MySQL Percona High Performance Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-highperf-%{patchset}
-%endif
-
-%if %{community}
-%define comment MySQL Community Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -community
-%endif
-
-%if %{enterprise}
-%define comment MySQL Enterprise Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise
-%endif
-
-%if %{enterprise_gpl}
-%define comment MySQL Enterprise Server
-%define commercial 0
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise-gpl
-%endif
-
-%if %{classic}
-%define comment MySQL Classic Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 0
-%define server_suffix -classic
-%endif
-
-
-%if %{COMMUNITY_BUILD}
-%define cluster_package_prefix -cluster
-%else
-%define cluster_package_prefix -
-%endif
-
-%define mysqld_user mysql
-%define mysqld_group mysql
-%define mysqldatadir /var/lib/mysql
-
-# We don't package all files installed into the build root by intention -
-# See BUG#998 for details.
-%define _unpackaged_files_terminate_build 0
-
-%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com
-Source0: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-%{version}.tar.gz
-
-Patch1: show_patches.patch
-Patch2: microslow_innodb.patch
-Patch3: userstatv2.patch
-Patch4: microsec_process.patch
-Patch5: innodb_io_patches.patch
-Patch6: mirror_binlog.patch
-Patch7: mysqld_safe_syslog.patch
-Patch8: innodb_locks_held.patch
-Patch9: innodb_show_bp.patch
-Patch10: innodb_show_hashed_memory.patch
-Patch11: innodb_check_fragmentation.patch
-Patch12: innodb_io_pattern.patch
-Patch13: innodb_fsync_source.patch
-Patch14: innodb_dict_size_limit.patch
-Patch15: innodb_extra_rseg.patch
-Patch16: innodb_thread_concurrency_timer_based.patch
-Patch100: split_buf_pool_mutex_fixed_optimistic_safe.patch
-Patch101: innodb_rw_lock.patch
-
-
-Name: MySQL%{server_suffix}
-Summary: MySQL: a very fast and reliable SQL database server
-Group: Applications/Databases
-Version: %{mysqlversion}
-Release: %{release}
-Distribution: Red Hat Enterprise Linux %{redhat_version}
-License: GPL
-Source: mysql-%{mysqlversion}.tar.gz
-URL: http://www.mysql.com/
-Packager: Percona Build Team <info@percona.com>
-Vendor: %{mysql_vendor}
-Provides: msqlormysql MySQL-server mysql
-BuildRequires: gperf perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time
-
-# Think about what you use here since the first step is to
-# run a rm -rf
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-
-# From the manual
-%description
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-%package -n MySQL-server%{server_suffix}
-Summary: @COMMENT@ for Red Hat Enterprise Linux %{redhat_version}
-Group: Applications/Databases
-Requires: chkconfig coreutils shadow-utils grep procps
-Provides: msqlormysql mysql-server mysql MySQL MySQL-server
-Obsoletes: MySQL mysql mysql-server MySQL-server
-
-%description -n MySQL-server%{server_suffix}
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-This package includes the MySQL server binary
-%if %{INNODB_BUILD}
-(configured including InnoDB)
-%endif
-as well as related utilities to run and administer a MySQL server.
-
-If you want to access and work with the database, you have to install
-package "MySQL-client%{server_suffix}" as well!
-
-%package -n MySQL-client%{server_suffix}
-Summary: MySQL - Client
-Group: Applications/Databases
-Obsoletes: mysql-client MySQL-client
-Provides: mysql-client MySQL-client
-
-%description -n MySQL-client%{server_suffix}
-This package contains the standard MySQL clients and administration tools.
-
-%{see_base}
-
-%package -n MySQL-test%{server_suffix}
-Requires: mysql-client perl
-Summary: MySQL - Test suite
-Group: Applications/Databases
-Provides: mysql-test MySQL-test
-Obsoletes: mysql-test MySQL-test
-AutoReqProv: no
-
-%description -n MySQL-test%{server_suffix}
-This package contains the MySQL regression test suite.
-
-%{see_base}
-
-%package -n MySQL-devel%{server_suffix}
-Summary: MySQL - Development header files and libraries
-Group: Applications/Databases
-Provides: mysql-devel MySQL-devel
-Obsoletes: mysql-devel MySQL-devel
-
-%description -n MySQL-devel%{server_suffix}
-This package contains the development header files and libraries
-necessary to develop MySQL client applications.
-
-%{see_base}
-
-%package -n MySQL-shared%{server_suffix}
-Summary: MySQL - Shared libraries
-Group: Applications/Databases
-Provides: mysql-shared MySQL-shared
-# Obsoletes below to correct old missing Provides:/Obsoletes
-Obsoletes: mysql-shared MySQL-shared-standard MySQL-shared-pro
-Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl
-Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared
-
-%description -n MySQL-shared%{server_suffix}
-This package contains the shared libraries (*.so*) which certain
-languages and applications need to dynamically load and use MySQL.
-
-%prep
-%setup -n mysql-%{mysqlversion}
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-#%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
-%patch14 -p1
-%patch15 -p1
-%patch16 -p1
-%if %{perconahighperf}
-%patch100 -p1
-%patch101 -p1
-%endif
-
-%build
-
-pushd ..
-tar cfz mysql-%{mysqlversion}%{server_suffix}-src.tar.gz mysql-%{mysqlversion}
-mv mysql-%{mysqlversion}%{server_suffix}-src.tar.gz %{_topdir}
-popd
-
-BuildMySQL() {
-# Evaluate current setting of $DEBUG
-if [ $DEBUG -gt 0 ] ; then
- OPT_COMMENT='--with-comment="%{comment} - Debug (%{license})"'
- OPT_DEBUG='--with-debug'
-else
- OPT_COMMENT='--with-comment="%{comment} (%{license})"'
- OPT_DEBUG=''
-fi
-if [ $BINARYPKG -ne 1 ] ; then
- OPT_PATH='--exec-prefix=%{_exec_prefix} \
- --libexecdir=%{_sbindir} \
- --libdir=%{_libdir} \
- --sysconfdir=%{_sysconfdir} \
- --datadir=%{_datadir} \
- --localstatedir=%{mysqldatadir} \
- --infodir=%{_infodir} \
- --includedir=%{_includedir} \
- --mandir=%{_mandir}'
-else
- OPT_PATH='--prefix=/usr/local/mysql-%{mysqlversion}%{server_suffix}'
-fi
-
-# The --enable-assembler simply does nothing on systems that does not
-# support assembler speedups.
-sh -c "CFLAGS=\"${CFLAGS:-$RPM_OPT_FLAGS}\" \
- CXXFLAGS=\"${CXXFLAGS:-$RPM_OPT_FLAGS}\" \
- LDFLAGS=\"$LDFLAGS\" \
- ./configure \
- $* \
- --enable-assembler \
- --enable-local-infile \
- --with-mysqld-user=%{mysqld_user} \
- --with-unix-socket-path=/var/lib/mysql/mysql.sock \
- --with-pic \
- --prefix=/ \
- --with-extra-charsets=complex \
-%if %{YASSL_BUILD}
- --with-yassl \
-%endif
- $OPT_PATH \
- --enable-thread-safe-client \
-%if %{?comment:1}0
- $OPT_COMMENT \
-%endif
- $OPT_DEBUG \
- --with-readline \
- ; make -j8"
-}
-# end of function definition "BuildMySQL"
-
-
-BuildServer() {
-BuildMySQL "--disable-shared \
-%if %{?server_suffix:1}0
- --with-server-suffix='%{server_suffix}' \
-%endif
- --without-embedded-server \
-%if %{INNODB_BUILD}
- --with-innodb \
-%else
- --without-innodb \
-%endif
- --with-csv-storage-engine \
- --with-archive-storage-engine \
- --with-blackhole-storage-engine \
- --with-federated-storage-engine \
- --without-bench \
- --with-zlib-dir=bundled \
- --with-big-tables"
-
-if [ -n "$MYSQL_CONFLOG_DEST" ] ; then
- cp -fp config.log "$MYSQL_CONFLOG_DEST"
-fi
-
-if [ -f sql/.libs/mysqld ] ; then
- nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym
-else
- nm --numeric-sort sql/mysqld > sql/mysqld.sym
-fi
-}
-# end of function definition "BuildServer"
-
-
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Clean up the BuildRoot first
-[ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR;
-mkdir -p $RBR%{_libdir}/mysql $RBR%{_sbindir}
-
-# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and
-# including exceptions into the code
-if [ -z "$CXX" -a -z "$CC" ] ; then
- export CC="ccache gcc" CXX="ccache gcc"
-fi
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-
-
-if [ "%{redhat_version}" = "5" ] ; then
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-fi
-
-if [ "%{redhat_version}" != "5" ] ; then
-export CC="gcc4" CXX="gcc4"
-export CFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-export CXXFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-fi
-
-
-# Create the shared libs seperately to avoid a dependency for the client utilities
-DEBUG=0
-BINARYPKG=0
-BuildMySQL "--enable-shared --without-server"
-
-# Install shared libraries
-cp -av libmysql/.libs/*.so* $RBR/%{_libdir}
-cp -av libmysql_r/.libs/*.so* $RBR/%{_libdir}
-
-# Include libgcc.a in the devel subpackage (BUG 4921)
-if expr "$CC" : "gcc.*" > /dev/null && \
- expr "$CC" : ".* gcc.*" > /dev/null ; then
- libgcc=`$CC $CFLAGS --print-libgcc-file`
- if [ -f $libgcc ] ; then
- install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
- fi
-fi
-
-# Now create a debug server
-DEBUG=1
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt-debug
-fi
-
-# Get the debug server and its .sym file from the build tree
-if [ -f sql/.libs/mysqld ] ; then
- cp sql/.libs/mysqld $RBR%{_sbindir}/mysqld-debug
-else
- cp sql/mysqld $RBR%{_sbindir}/mysqld-debug
-fi
-
-cp sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld-debug.sym
-
-# Now, the binary package
-DEBUG=0
-BINARYPKG=1
-make clean distclean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-rm -fr /tmp/mysql-%{mysqlversion}%{server_suffix}
-make DESTDIR=/tmp/mysql-%{mysqlversion}%{server_suffix} install
-pushd /tmp/mysql-%{mysqlversion}%{server_suffix}/usr/local
-tar cfz mysql-%{mysqlversion}%{server_suffix}.tar.gz mysql-%{mysqlversion}%{server_suffix}
-mv mysql-%{mysqlversion}%{server_suffix}.tar.gz %{_topdir}
-popd
-
-# Now, the default server
-DEBUG=0
-BINARYPKG=0
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-
-
-%install
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Ensure that needed directories exists
-install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
-install -d $RBR%{mysqldatadir}/mysql
-install -d $RBR%{_datadir}/mysql-test
-install -d $RBR%{_datadir}/mysql/SELinux/RHEL4
-install -d $RBR%{_includedir}
-install -d $RBR%{_libdir}
-install -d $RBR%{_mandir}
-install -d $RBR%{_sbindir}
-
-make DESTDIR=$RBR benchdir_root=%{_datadir} install
-
-# install symbol files ( for stack trace resolution)
-install -m644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym
-
-# Install logrotate and autostart
-install -m644 $MBD/support-files/mysql-log-rotate \
- $RBR%{_sysconfdir}/logrotate.d/mysql
-install -m755 $MBD/support-files/mysql.server \
- $RBR%{_sysconfdir}/init.d/mysql
-
-# Create a symlink "rcmysql", pointing to the init.script. SuSE users
-# will appreciate that, as all services usually offer this.
-ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql
-
-# Create symbolic compatibility link safe_mysqld -> mysqld_safe
-# (safe_mysqld will be gone in MySQL 4.1)
-ln -sf ./mysqld_safe $RBR%{_bindir}/safe_mysqld
-
-# Touch the place where the my.cnf config file and mysqlmanager.passwd
-# (MySQL Instance Manager password file) might be located
-# Just to make sure it's in the file list and marked as a config file
-touch $RBR%{_sysconfdir}/my.cnf
-touch $RBR%{_sysconfdir}/mysqlmanager.passwd
-
-# Install SELinux files in datadir
-install -m600 $MBD/support-files/RHEL4-SElinux/mysql.{fc,te} \
- $RBR%{_datadir}/mysql/SELinux/RHEL4
-
-
-%pre -n MySQL-server%{server_suffix}
-# Check if we can safely upgrade. An upgrade is only safe if it's from one
-# of our RPMs in the same version family.
-
-installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
-if [ $? -eq 0 -a -n "$installed" ]; then
- vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
- version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
- myvendor='%{mysql_vendor}'
- myversion='%{mysqlversion}'
-
- old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
- new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
-
- [ -z "$vendor" ] && vendor='<unknown>'
- [ -z "$old_family" ] && old_family="<unrecognized version $version>"
- [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"
-
- error_text=
- if [ "$vendor" != "$myvendor" ]; then
- error_text="$error_text
-The current MySQL server package is provided by a different
-vendor ($vendor) than $myvendor. Some files may be installed
-to different locations, including log files and the service
-startup script in %{_sysconfdir}/init.d/.
-"
- fi
-
- if [ "$old_family" != "$new_family" ]; then
- error_text="$error_text
-Upgrading directly from MySQL $old_family to MySQL $new_family may not
-be safe in all cases. A manual dump and restore using mysqldump is
-recommended. It is important to review the MySQL manual's Upgrading
-section for version-specific incompatibilities.
-"
- fi
-
- if [ -n "$error_text" ]; then
- cat <<HERE >&2
-
-******************************************************************
-A MySQL server package ($installed) is installed.
-$error_text
-A manual upgrade is required.
-
-- Ensure that you have a complete, working backup of your data and my.cnf
- files
-- Shut down the MySQL server cleanly
-- Remove the existing MySQL packages. Usually this command will
- list the packages you should remove:
- rpm -qa | grep -i '^mysql-'
-
- You may choose to use 'rpm --nodeps -ev <package-name>' to remove
- the package which contains the mysqlclient shared library. The
- library will be reinstalled by the MySQL-shared-compat package.
-- Install the new MySQL packages supplied by $myvendor
-- Ensure that the MySQL server is started
-- Run the 'mysql_upgrade' program
-
-This is a brief description of the upgrade process. Important details
-can be found in the MySQL manual, in the Upgrading section.
-******************************************************************
-HERE
- exit 1
- fi
-fi
-
-# Shut down a previously installed server first
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
- echo "Giving mysqld 5 seconds to exit nicely"
- sleep 5
-fi
-
-%post -n MySQL-server%{server_suffix}
-mysql_datadir=%{mysqldatadir}
-
-# Create data directory
-mkdir -p $mysql_datadir/{mysql,test}
-
-# Make MySQL start/shutdown automatically when the machine does it.
-if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --add mysql
-fi
-
-
-
-# Create a MySQL user and group. Do not report any problems if it already
-# exists.
-groupadd -r %{mysqld_group} 2> /dev/null || true
-useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
-usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-
-# Change permissions so that the user that will run the MySQL daemon
-# owns all database files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Initiate databases
-%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
-
-# Upgrade databases if needed would go here - but it cannot be automated yet
-
-# Change permissions again to fix any new files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Fix permissions for the permission database so that only the user
-# can read them.
-chmod -R og-rw $mysql_datadir/mysql
-
-# install SELinux files - but don't override existing ones
-SETARGETDIR=/etc/selinux/targeted/src/policy
-SEDOMPROG=$SETARGETDIR/domains/program
-SECONPROG=$SETARGETDIR/file_contexts/program
-if [ -f /etc/redhat-release ] \
- && grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \
- || grep -q "CentOS release 4" /etc/redhat-release ; then
- echo
- echo
- echo 'Notes regarding SELinux on this platform:'
- echo '========================================='
- echo
- echo 'The default policy might cause server startup to fail because it is '
- echo 'not allowed to access critical files. In this case, please update '
- echo 'your installation. '
- echo
- echo 'The default policy might also cause inavailability of SSL related '
- echo 'features because the server is not allowed to access /dev/random '
- echo 'and /dev/urandom. If this is a problem, please do the following: '
- echo
- echo ' 1) install selinux-policy-targeted-sources from your OS vendor'
- echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':'
- echo ' allow mysqld_t random_device_t:chr_file read;'
- echo ' allow mysqld_t urandom_device_t:chr_file read;'
- echo ' 3) cd to '$SETARGETDIR' and issue the following command:'
- echo ' make load'
- echo
- echo
-fi
-
-if [ -x sbin/restorecon ] ; then
- sbin/restorecon -R var/lib/mysql
-fi
-
-# Restart in the same way that mysqld will be started normally.
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql start
- echo "Giving mysqld 2 seconds to start"
- sleep 2
-fi
-
-# Allow safe_mysqld to start mysqld and print a message before we exit
-sleep 2
-
-
-%preun -n MySQL-server%{server_suffix}
-if [ $1 = 0 ] ; then
- # Stop MySQL before uninstalling it
- if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null
- # Don't start it automatically anymore
- if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --del mysql
- fi
- fi
-fi
-
-# We do not remove the mysql user since it may still own a lot of
-# database files.
-
-# Clean up the BuildRoot
-%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
-
-%files -n MySQL-server%{server_suffix}
-%defattr(-,root,root,0755)
-
-%if %{commercial}
-%doc LICENSE.mysql
-%else
-%doc COPYING README
-%endif
-%doc support-files/my-*.cnf
-
-%doc %attr(644, root, root) %{_infodir}/mysql.info*
-
-%if %{INNODB_BUILD}
-%doc %attr(644, root, man) %{_mandir}/man1/innochecksum.1*
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/my_print_defaults.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisam_ftdump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamchk.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisampack.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_convert_table_format.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_explain_log.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_extensions.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqld.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
-%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
-%doc %attr(644, root, man) %{_mandir}/man1/replace.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
-%doc %attr(644, root, man) %{_mandir}/man1/safe_mysqld.1*
-
-%ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/mysqlmanager.passwd
-
-%if %{INNODB_BUILD}
-%attr(755, root, root) %{_bindir}/innochecksum
-%endif
-%attr(755, root, root) %{_bindir}/my_print_defaults
-%attr(755, root, root) %{_bindir}/myisam_ftdump
-%attr(755, root, root) %{_bindir}/myisamchk
-%attr(755, root, root) %{_bindir}/myisamlog
-%attr(755, root, root) %{_bindir}/myisampack
-%attr(755, root, root) %{_bindir}/mysql_convert_table_format
-%attr(755, root, root) %{_bindir}/mysql_explain_log
-%attr(755, root, root) %{_bindir}/mysql_fix_extensions
-%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
-%attr(755, root, root) %{_bindir}/mysql_install_db
-%attr(755, root, root) %{_bindir}/mysql_secure_installation
-%attr(755, root, root) %{_bindir}/mysql_setpermission
-%attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
-%attr(755, root, root) %{_bindir}/mysql_upgrade
-%attr(755, root, root) %{_bindir}/mysql_zap
-%attr(755, root, root) %{_bindir}/mysqlbug
-%attr(755, root, root) %{_bindir}/mysqld_multi
-%attr(755, root, root) %{_bindir}/mysqld_safe
-%attr(755, root, root) %{_bindir}/mysqldumpslow
-%attr(755, root, root) %{_bindir}/mysqlhotcopy
-%attr(755, root, root) %{_bindir}/mysqltest
-%attr(755, root, root) %{_bindir}/perror
-%attr(755, root, root) %{_bindir}/replace
-%attr(755, root, root) %{_bindir}/resolve_stack_dump
-%attr(755, root, root) %{_bindir}/resolveip
-%attr(755, root, root) %{_bindir}/safe_mysqld
-
-%attr(755, root, root) %{_sbindir}/mysqld
-%attr(755, root, root) %{_sbindir}/mysqld-debug
-%attr(755, root, root) %{_sbindir}/mysqlmanager
-%attr(755, root, root) %{_sbindir}/rcmysql
-%attr(644, root, root) %{_libdir}/mysql/mysqld.sym
-%attr(644, root, root) %{_libdir}/mysql/mysqld-debug.sym
-
-%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
-%attr(755, root, root) %{_sysconfdir}/init.d/mysql
-
-%attr(755, root, root) %{_datadir}/mysql/
-
-%files -n MySQL-client%{server_suffix}
-%defattr(-, root, root, 0755)
-%attr(755, root, root) %{_bindir}/msql2mysql
-%attr(755, root, root) %{_bindir}/mysql
-%attr(755, root, root) %{_bindir}/mysql_find_rows
-%attr(755, root, root) %{_bindir}/mysql_tableinfo
-%attr(755, root, root) %{_bindir}/mysql_upgrade_shell
-%attr(755, root, root) %{_bindir}/mysql_waitpid
-%attr(755, root, root) %{_bindir}/mysqlaccess
-%attr(755, root, root) %{_bindir}/mysqladmin
-%attr(755, root, root) %{_bindir}/mysqlbinlog
-%attr(755, root, root) %{_bindir}/mysqlcheck
-%attr(755, root, root) %{_bindir}/mysqldump
-%attr(755, root, root) %{_bindir}/mysqlimport
-%attr(755, root, root) %{_bindir}/mysqlshow
-
-%doc %attr(644, root, man) %{_mandir}/man1/msql2mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tableinfo.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_waitpid.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlaccess.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqladmin.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlbinlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlcheck.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1*
-
-%post -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%postun -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%files -n MySQL-devel%{server_suffix}
-%defattr(-, root, root, 0755)
-%if %{commercial}
-%else
-%doc EXCEPTIONS-CLIENT
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/comp_err.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1*
-%attr(755, root, root) %{_bindir}/comp_err
-%attr(755, root, root) %{_bindir}/mysql_config
-%dir %attr(755, root, root) %{_libdir}/mysql
-%{_includedir}/mysql
-%{_libdir}/mysql/libdbug.a
-%{_libdir}/mysql/libheap.a
-%{_libdir}/mysql/libmy*.a
-%{_libdir}/mysql/libmy*.la
-%{_libdir}/mysql/libvio.a
-%{_libdir}/mysql/libz*
-
-%files -n MySQL-shared%{server_suffix}
-%defattr(-, root, root, 0755)
-# Shared libraries (omit for architectures that don't support them)
-%{_libdir}/*.so*
-
-
-%files -n MySQL-test%{server_suffix}
-%defattr(-, root, root, 0755)
-%{_datadir}/mysql-test
-%attr(755, root, root) %{_bindir}/mysql_client_test
-%attr(755, root, root) %{_bindir}/mysqltestmanager
-%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen
-%attr(755, root, root) %{_bindir}/mysqltestmanagerc
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
-
-# The spec file changelog only includes changes made to the spec file
-# itself - note that they must be ordered by date (important when
-# merging BK trees)
-%changelog
-* Mon Jul 07 2008 Jonathan Perkin <jperkin@sun.com>
-
-- Add 'classic' product.
-
-* Wed Jun 11 2008 Kent Boortz <kent@mysql.com>
-
-- Removed the Example storage engine, it is not to be in products
-
-* Mon Feb 18 2008 Timothy Smith <tim@mysql.com>
-
-- Require a manual upgrade if the alread-installed mysql-server is
- from another vendor, or is of a different major version.
-
-* Fri Dec 14 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the "%doc" directive for all man pages and other documentation;
- also, some re-ordering to reduce differences between spec files.
-
-* Wed Oct 31 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Explicitly handle InnoDB using its own variable and "--with"/"--without"
- options, because the "configure" default is "yes".
-
-* Tue Jul 17 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the man page for "mysql-stress-test.pl" to the "test" RPM
- (consistency in fixing bug#21023, the script is handled by "Makefile.am")
-
-* Wed Jul 11 2007 Daniel Fischer <df@mysql.com>
-
-- Change the way broken SELinux policies on RHEL4 and CentOS 4
- are handled to be more likely to actually work
-
-* Thu Jun 05 2007 kent Boortz <kent@mysql.com>
-
-- Enabled the CSV engine in all builds
-
-* Thu May 3 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Spring cleanup
-
-* Thu Apr 19 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- If sbin/restorecon exists then run it
-
-* Wed Apr 18 2007 Kent Boortz <kent@mysql.com>
-
-- Packed unpacked files
-
- /usr/sbin/ndb_cpcd
- /usr/bin/mysql_upgrade_shell
- /usr/bin/innochecksum
- /usr/share/man/man1/ndb_cpcd.1.gz
- /usr/share/man/man1/innochecksum.1.gz
- /usr/share/man/man1/mysql_fix_extensions.1.gz
- /usr/share/man/man1/mysql_secure_installation.1.gz
- /usr/share/man/man1/mysql_tableinfo.1.gz
- /usr/share/man/man1/mysql_waitpid.1.gz
-
-- Commands currently not installed but that has man pages
-
- /usr/share/man/man1/make_win_bin_dist.1.gz
- /usr/share/man/man1/make_win_src_distribution.1.gz
- /usr/share/man/man1/mysql-stress-test.pl.1.gz
- /usr/share/man/man1/ndb_print_backup_file.1.gz
- /usr/share/man/man1/ndb_print_schema_file.1.gz
- /usr/share/man/man1/ndb_print_sys_file.1.gz
-
-* Thu Mar 22 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add "comment" options to the test runs, for better log analysis.
-
-* Wed Mar 21 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add even more man pages.
-
-* Fri Mar 16 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Build the server twice, once as "mysqld-debug" and once as "mysqld";
- test them both, and include them in the resulting file.
-- Consequences of the fix for bug#20166:
- Remove "mysql_create_system_tables",
- new "mysql_fix_privilege_tables.sql" is included implicitly.
-
-* Wed Mar 14 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options some more and change naming of community
- cluster RPMs to explicitly say 'cluster'.
-
-* Mon Mar 12 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options and other settings for 5.0 community builds.
-
-* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add several man pages which are now created.
-
-* Mon Jan 29 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Make sure SELinux works correctly. Files from Colin Charles.
-
-* Fri Jan 05 2007 Kent Boortz <kent@mysql.com>
-
-- Add CFLAGS to gcc call with --print-libgcc-file, to make sure the
- correct "libgcc.a" path is returned for the 32/64 bit architecture.
-
-* Tue Dec 19 2006 Joerg Bruehe <joerg@mysql.com>
-
-- The man page for "mysqld" is now in section 8.
-
-* Thu Dec 14 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Include the new man pages for "my_print_defaults" and "mysql_tzinfo_to_sql"
- in the server RPM.
-- The "mysqlmanager" man page was relocated to section 8, reflect that.
-
-* Fri Nov 17 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Really fix obsoletes/provides for community -> this
-- Make it possible to not run test by setting
- MYSQL_RPMBUILD_TEST to "no"
-
-* Wed Nov 15 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Switch from "make test*" to explicit calls of the test suite,
- so that "report features" can be used.
-
-* Wed Nov 15 2006 Kent Boortz <kent@mysql.com>
-
-- Added "--with cluster" and "--define cluster{_gpl}"
-
-* Tue Oct 24 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Shared need to Provide/Obsolete mysql-shared
-
-* Mon Oct 23 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Run sbin/restorecon after db init (Bug#12676)
-
-* Thu Jul 06 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Correct a typing error in my previous change.
-
-* Tue Jul 04 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Use the Perl script to run the tests, because it will automatically check
- whether the server is configured with SSL.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Revert all previous attempts to call "mysql_upgrade" during RPM upgrade,
- there are some more aspects which need to be solved before this is possible.
- For now, just ensure the binary "mysql_upgrade" is delivered and installed.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Move "mysqldumpslow" from the client RPM to the server RPM (bug#20216).
-
-* Wed Jun 21 2006 Joerg Bruehe <joerg@mysql.com>
-
-- To run "mysql_upgrade", we need a running server;
- start it in isolation and skip password checks.
-
-* Sat May 23 2006 Kent Boortz <kent@mysql.com>
-
-- Always compile for PIC, position independent code.
-
-* Fri Apr 28 2006 Kent Boortz <kent@mysql.com>
-
-- Install and run "mysql_upgrade"
-
-* Sat Apr 01 2006 Kent Boortz <kent@mysql.com>
-
-- Allow to override $LDFLAGS
-
-* Fri Jan 06 2006 Lenz Grimmer <lenz@mysql.com>
-
-- added a MySQL-test subpackage (BUG#16070)
-
-* Tue Dec 27 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Some minor alignment with the 4.1 version
-
-* Wed Dec 14 2005 Rodrigo Novo <rodrigo@mysql.com>
-
-- Cosmetic changes: source code location & rpm packager
-- Protect "nm -D" against libtool weirdness
-- Add libz.a & libz.la to the list of files for subpackage -devel
-- moved --with-zlib-dir=bundled out of BuildMySQL, as it doesn't makes
- sense for the shared package
-
-* Tue Nov 22 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Extend the file existence check for "init.d/mysql" on un-install
- to also guard the call to "insserv"/"chkconfig".
-
-* Wed Nov 16 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_client_test to the "client" subpackage (BUG#14546)
-
-* Tue Nov 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- changed default definitions to build a standard GPL release when not
- defining anything else
-- install the shared libs more elegantly by using "make install"
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Made yaSSL support an option (off by default)
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Enabled yaSSL support
-
-* Thu Oct 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added a usermod call to assign a potential existing mysql user to the
- correct user group (BUG#12823)
-- added a separate macro "mysqld_group" to be able to define the
- user group of the mysql user seperately, if desired.
-
-* Fri Oct 1 2005 Kent Boortz <kent@mysql.com>
-
-- Copy the config.log file to location outside
- the build tree
-
-* Fri Sep 30 2005 Lenz Grimmer <lenz@mysql.com>
-
-- don't use install-strip to install the binaries (strip segfaults on
- icc-compiled binaries on IA64)
-
-* Thu Sep 22 2005 Lenz Grimmer <lenz@mysql.com>
-
-- allow overriding the CFLAGS (needed for Intel icc compiles)
-- replace the CPPFLAGS=-DBIG_TABLES with "--with-big-tables" configure option
-
-* Fri Aug 19 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Protect against failing tests.
-
-* Thu Aug 04 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the creation of the mysql user group account in the postinstall
- section (BUG 12348)
-
-* Fri Jul 29 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed external RPM Requirements to better suit the target distribution
- (BUG 12233)
-
-* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- create a "mysql" user group and assign the mysql user account to that group
- in the server postinstall section. (BUG 10984)
-
-* Wed Jun 01 2005 Lenz Grimmer <lenz@mysql.com>
-
-- use "mysqldatadir" variable instead of hard-coding the path multiple times
-- use the "mysqld_user" variable on all occasions a user name is referenced
-- removed (incomplete) Brazilian translations
-- removed redundant release tags from the subpackage descriptions
-
-* Fri May 27 2005 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file list (removed libnisam.a and libmerge.a from the devel subpackage)
-- force running the test suite
-
-* Wed Apr 20 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Enabled the "blackhole" storage engine for the Max RPM
-
-* Wed Apr 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- removed the MySQL manual files (html/ps/texi) - they have been removed
- from the MySQL sources and are now available seperately.
-
-* Mon Apr 4 2005 Petr Chardin <petr@mysql.com>
-
-- old mysqlmanager, mysqlmanagerc and mysqlmanager-pwger renamed into
- mysqltestmanager, mysqltestmanager and mysqltestmanager-pwgen respectively
-
-* Fri Mar 18 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Disabled RAID in the Max binaries once and for all (it has finally been
- removed from the source tree)
-
-* Sun Feb 20 2005 Petr Chardin <petr@mysql.com>
-
-- Install MySQL Instance Manager together with mysqld, touch mysqlmanager
- password file
-
-* Mon Feb 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the compilation comments and moved them into the separate build sections
- for Max and Standard
-
-* Mon Feb 7 2005 Tomas Ulin <tomas@mysql.com>
-
-- enabled the "Ndbcluster" storage engine for the max binary
-- added extra make install in ndb subdir after Max build to get ndb binaries
-- added packages for ndbcluster storage engine
-
-* Fri Jan 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- replaced obsoleted "BuildPrereq" with "BuildRequires" instead
-
-* Thu Jan 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Federated" storage engine for the max binary
-
-* Tue Jan 04 2005 Petr Chardin <petr@mysql.com>
-
-- ISAM and merge storage engines were purged. As well as appropriate
- tools and manpages (isamchk and isamlog)
-
-* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Archive" storage engine for the max binary
-- enabled the "CSV" storage engine for the max binary
-- enabled the "Example" storage engine for the max binary
-
-* Thu Aug 26 2004 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860)
-
-* Fri Aug 20 2004 Lenz Grimmer <lenz@mysql.com>
-
-- do not link statically on IA64/AMD64 as these systems do not have
- a patched glibc installed
-
-* Tue Aug 10 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added libmygcc.a to the devel subpackage (required to link applications
- against the the embedded server libmysqld.a) (BUG 4921)
-
-* Mon Aug 09 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added EXCEPTIONS-CLIENT to the "devel" package
-
-* Thu Jul 29 2004 Lenz Grimmer <lenz@mysql.com>
-
-- disabled OpenSSL in the Max binaries again (the RPM packages were the
- only exception to this anyway) (BUG 1043)
-
-* Wed Jun 30 2004 Lenz Grimmer <lenz@mysql.com>
-
-- fixed server postinstall (mysql_install_db was called with the wrong
- parameter)
-
-* Thu Jun 24 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_tzinfo_to_sql to the server subpackage
-- run "make clean" instead of "make distclean"
-
-* Mon Apr 05 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added ncurses-devel to the build prerequisites (BUG 3377)
-
-* Thu Feb 12 2004 Lenz Grimmer <lenz@mysql.com>
-
-- when using gcc, _always_ use CXX=gcc
-- replaced Copyright with License field (Copyright is obsolete)
-
-* Tue Feb 03 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added myisam_ftdump to the Server package
-
-* Tue Jan 13 2004 Lenz Grimmer <lenz@mysql.com>
-
-- link the mysql client against libreadline instead of libedit (BUG 2289)
-
-* Mon Dec 22 2003 Lenz Grimmer <lenz@mysql.com>
-
-- marked /etc/logrotate.d/mysql as a config file (BUG 2156)
-
-* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file permissions (BUG 1672)
-
-* Thu Dec 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- made testing for gcc3 a bit more robust
-
-* Fri Dec 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_create_system_tables to the server subpackage
-
-* Fri Nov 21 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed dependency on MySQL-client from the MySQL-devel subpackage
- as it is not really required. (BUG 1610)
-
-* Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 1162 (removed macro names from the changelog)
-- Really fixed BUG 998 (disable the checking for installed but
- unpackaged files)
-
-* Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 959 (libmysqld not being compiled properly)
-- Fixed BUG 998 (RPM build errors): added missing files to the
- distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
- mysql_fix_privilege_tables.1), removed "-n" from install section.
-
-* Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed the GIF Icon (file was not included in the sources anyway)
-- removed unused variable shared_lib_version
-- do not run automake before building the standard binary
- (should not be necessary)
-- add server suffix '-standard' to standard binary (to be in line
- with the binary tarball distributions)
-- Use more RPM macros (_exec_prefix, _sbindir, _libdir, _sysconfdir,
- _datadir, _includedir) throughout the spec file.
-- allow overriding CC and CXX (required when building with other compilers)
-
-* Fri May 16 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-enabled RAID again
-
-* Wed Apr 30 2003 Lenz Grimmer <lenz@mysql.com>
-
-- disabled MyISAM RAID (--with-raid) - it throws an assertion which
- needs to be investigated first.
-
-* Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_secure_installation to server subpackage
- (BUG 141)
-
-* Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-added missing pre- and post(un)install scripts to server subpackage
-- added config file /etc/my.cnf to the file list (just for completeness)
-- make sure to create the datadir with 755 permissions
-
-* Mon Jan 27 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed unused CC and CXX variables
-- CFLAGS and CXXFLAGS should honor RPM_OPT_FLAGS
-
-* Fri Jan 24 2003 Lenz Grimmer <lenz@mysql.com>
-
-- renamed package "MySQL" to "MySQL-server"
-- fixed Copyright tag
-- added mysql_waitpid to client subpackage (required for mysql-test-run)
-
-* Wed Nov 27 2002 Lenz Grimmer <lenz@mysql.com>
-
-- moved init script from /etc/rc.d/init.d to /etc/init.d (the majority of
- Linux distributions now support this scheme as proposed by the LSB either
- directly or via a compatibility symlink)
-- Use new "restart" init script action instead of starting and stopping
- separately
-- Be more flexible in activating the automatic bootup - use insserv (on
- older SuSE versions) or chkconfig (Red Hat, newer SuSE versions and
- others) to create the respective symlinks
-
-* Wed Sep 25 2002 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL >= 4.0 to avoid version mismatches
- (mixing 3.23 and 4.0 packages)
-
-* Fri Aug 09 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Turn off OpenSSL in MySQL-Max for now until it works properly again
-- enable RAID for the Max binary instead
-- added compatibility link: safe_mysqld -> mysqld_safe to ease the
- transition from 3.23
-
-* Thu Jul 18 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Reworked the build steps a little bit: the Max binary is supposed
- to include OpenSSL, which cannot be linked statically, thus trying
- to statically link against a special glibc is futile anyway
-- because of this, it is not required to make yet another build run
- just to compile the shared libs (saves a lot of time)
-- updated package description of the Max subpackage
-- clean up the BuildRoot directory afterwards
-
-* Mon Jul 15 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Updated Packager information
-- Fixed the build options: the regular package is supposed to
- include InnoDB and linked statically, while the Max package
- should include BDB and SSL support
-
-* Fri May 03 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Use more RPM macros (e.g. infodir, mandir) to make the spec
- file more portable
-- reorganized the installation of documentation files: let RPM
- take care of this
-- reorganized the file list: actually install man pages along
- with the binaries of the respective subpackage
-- do not include libmysqld.a in the devel subpackage as well, if we
- have a special "embedded" subpackage
-- reworked the package descriptions
-
-* Mon Oct 8 2001 Monty
-
-- Added embedded server as a separate RPM
-
-* Fri Apr 13 2001 Monty
-
-- Added mysqld-max to the distribution
-
-* Tue Jan 2 2001 Monty
-
-- Added mysql-test to the bench package
-
-* Fri Aug 18 2000 Tim Smith <tim@mysql.com>
-
-- Added separate libmysql_r directory; now both a threaded
- and non-threaded library is shipped.
-
-* Wed Sep 28 1999 David Axmark <davida@mysql.com>
-
-- Added the support-files/my-example.cnf to the docs directory.
-
-- Removed devel dependency on base since it is about client
- development.
-
-* Wed Sep 8 1999 David Axmark <davida@mysql.com>
-
-- Cleaned up some for 3.23.
-
-* Thu Jul 1 1999 David Axmark <davida@mysql.com>
-
-- Added support for shared libraries in a separate sub
- package. Original fix by David Fox (dsfox@cogsci.ucsd.edu)
-
-- The --enable-assembler switch is now automatically disables on
- platforms there assembler code is unavailable. This should allow
- building this RPM on non i386 systems.
-
-* Mon Feb 22 1999 David Axmark <david@detron.se>
-
-- Removed unportable cc switches from the spec file. The defaults can
- now be overridden with environment variables. This feature is used
- to compile the official RPM with optimal (but compiler version
- specific) switches.
-
-- Removed the repetitive description parts for the sub rpms. Maybe add
- again if RPM gets a multiline macro capability.
-
-- Added support for a pt_BR translation. Translation contributed by
- Jorge Godoy <jorge@bestway.com.br>.
-
-* Wed Nov 4 1998 David Axmark <david@detron.se>
-
-- A lot of changes in all the rpm and install scripts. This may even
- be a working RPM :-)
-
-* Sun Aug 16 1998 David Axmark <david@detron.se>
-
-- A developers changelog for MySQL is available in the source RPM. And
- there is a history of major user visible changed in the Reference
- Manual. Only RPM specific changes will be documented here.
diff --git a/percona/5.0.77-b16/mysqld_safe_syslog.patch b/percona/5.0.77-b16/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.77-b16/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.77-b16/series b/percona/5.0.77-b16/series
deleted file mode 100644
index 68c21f8..0000000
--- a/percona/5.0.77-b16/series
+++ /dev/null
@@ -1,18 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-#mirror_binlog.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_show_hashed_memory.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-split_buf_pool_mutex_fixed_optimistic_safe.patch
-innodb_rw_lock.patch
diff --git a/percona/5.0.77-b16/show_patches.patch b/percona/5.0.77-b16/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.77-b16/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.77-b16/split_buf_pool_mutex_fixed_optimistic_safe.patch b/percona/5.0.77-b16/split_buf_pool_mutex_fixed_optimistic_safe.patch
deleted file mode 100644
index 885e893..0000000
--- a/percona/5.0.77-b16/split_buf_pool_mutex_fixed_optimistic_safe.patch
+++ /dev/null
@@ -1,1314 +0,0 @@
-diff -r 2e0c46e78b50 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:33:59 2008 -0800
-@@ -548,6 +548,19 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_create(&(buf_pool->free_mutex));
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_NO_ORDER_CHECK);
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_NO_ORDER_CHECK);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -723,6 +736,10 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -859,12 +876,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->LRU_mutex));
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
- }
-
-@@ -880,7 +897,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -888,7 +905,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -899,7 +916,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -909,7 +926,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- }
-
- /*************************************************************************
-@@ -950,11 +967,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -971,7 +988,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -979,7 +996,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -998,7 +1015,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1008,7 +1025,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1050,7 +1067,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1058,7 +1075,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1079,7 +1096,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1087,7 +1104,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1166,26 +1183,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ // mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1204,7 +1228,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ // mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1216,7 +1240,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1233,7 +1257,9 @@
- LRU list and we must put it to awe_LRU_free_mapped list once
- mapped to a frame */
-
-+ mutex_enter_fast(&(buf_pool->mutex));
- buf_awe_map_page_to_frame(block, TRUE);
-+ mutex_exit(&buf_pool->mutex);
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -1241,7 +1267,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1791,7 +1817,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1806,7 +1833,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1821,10 +1849,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1873,7 +1905,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1884,7 +1917,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1907,6 +1941,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1918,7 +1953,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1932,7 +1967,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1968,6 +2003,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2050,9 +2086,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2061,9 +2094,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2094,6 +2130,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2102,10 +2140,25 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-+
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
-@@ -2131,6 +2184,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2138,9 +2194,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2168,11 +2221,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2191,10 +2244,22 @@
- ulint n_flush = 0;
- ulint n_free = 0;
- ulint n_page = 0;
-+ ulint n_single_flush_tmp = 0;
-+ ulint n_lru_flush_tmp = 0;
-+ ulint n_list_flush_tmp = 0;
-
- ut_ad(buf_pool);
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+
- mutex_enter(&(buf_pool->mutex));
-+ n_single_flush_tmp = buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE];
-+ n_list_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LIST];
-+ n_lru_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LRU];
-+ mutex_exit(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2262,11 +2327,14 @@
- }
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
-- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+ ut_a(n_single_flush_tmp == n_single_flush);
-+ ut_a(n_list_flush_tmp == n_list_flush);
-+ ut_a(n_lru_flush_tmp == n_lru_flush);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2298,7 +2366,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2351,7 +2421,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2386,8 +2458,6 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2403,7 +2473,6 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2431,7 +2500,9 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2439,7 +2510,9 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ratio);
- }
-@@ -2459,6 +2532,9 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -2532,6 +2608,9 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
- }
-
-@@ -2562,8 +2641,6 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2584,8 +2661,6 @@
-
- mutex_exit(&block->mutex);
- }
--
-- mutex_exit(&(buf_pool->mutex));
-
- return(TRUE);
- }
-@@ -2625,11 +2700,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Dec 22 00:33:59 2008 -0800
-@@ -117,12 +117,14 @@
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* I permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -536,18 +538,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +748,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +782,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +793,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -849,7 +853,14 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+
- for (;;) {
- /* If we have flushed enough, leave the loop */
- if (page_count >= min_n) {
-@@ -895,7 +906,10 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- old_page_count = page_count;
-
-@@ -908,7 +922,10 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -930,6 +947,13 @@
- break;
- }
- }
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex));
-
- (buf_pool->init_flush)[flush_type] = FALSE;
-
-@@ -989,10 +1013,14 @@
- buf_block_t* block;
- ulint n_replaceable;
- ulint distance = 0;
--
-- mutex_enter(&(buf_pool->mutex));
-+
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-+ //mutex_enter(&(buf_pool->free_mutex));
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-+
-+ //mutex_exit(&(buf_pool->free_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
-@@ -1014,7 +1042,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1033,8 +1061,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1044,7 +1073,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1094,11 +1123,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0lru.c Mon Dec 22 00:33:59 2008 -0800
-@@ -79,7 +79,10 @@
- ibool all_freed;
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -117,7 +120,10 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -147,7 +153,10 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -170,14 +179,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -186,7 +195,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -210,13 +219,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -231,9 +242,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -246,14 +265,25 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
- freed = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -264,13 +294,21 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-+ mutex_exit(&(buf_pool->mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- return(FALSE);
- }
- }
-+ if (!freed) {
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -322,7 +360,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -330,7 +369,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -353,7 +393,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex)); /* LRU info:optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -409,7 +449,7 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ block = UT_LIST_GET_LAST(buf_pool->free);
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-@@ -437,7 +477,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -449,7 +489,7 @@
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -486,7 +526,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -958,7 +998,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1001,7 +1041,10 @@
-
- if (buf_pool->LRU_old) {
- ut_a(buf_pool->LRU_old_len == old_len);
-- }
-+ }
-+
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
-@@ -1013,7 +1056,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1029,7 +1072,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1073,5 +1116,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r 2e0c46e78b50 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/buf/buf0rea.c Mon Dec 22 00:33:59 2008 -0800
-@@ -236,10 +236,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -250,8 +252,9 @@
- recent_blocks++;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -347,7 +350,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -450,6 +453,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -463,6 +467,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -479,12 +484,13 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -492,10 +498,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -511,7 +518,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -587,7 +594,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -655,7 +662,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -727,7 +734,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r 2e0c46e78b50 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Dec 22 00:33:59 2008 -0800
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r 2e0c46e78b50 innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0buf.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -112,7 +112,7 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -122,7 +122,7 @@
- lsn = block->oldest_modification;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -392,18 +392,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +425,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +433,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -632,9 +632,9 @@
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->flush_list_mutex);
- buf_flush_note_modification(block, mtr);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->flush_list_mutex);
- }
-
- mutex_enter(&block->mutex);
-diff -r 2e0c46e78b50 innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.h Mon Dec 22 00:33:59 2008 -0800
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r 2e0c46e78b50 innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/include/buf0flu.ic Mon Dec 22 00:33:59 2008 -0800
-@@ -84,7 +84,7 @@
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
-@@ -102,5 +102,5 @@
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-diff -r 2e0c46e78b50 innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Mon Dec 22 00:33:53 2008 -0800
-+++ b/innobase/log/log0recv.c Mon Dec 22 00:33:59 2008 -0800
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r 2e0c46e78b50 patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info Mon Dec 22 00:33:59 2008 -0800
-@@ -0,0 +1,6 @@
-+File=split_buf_pool_mutex_fixed_optimistic_safe.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.77-b16/userstatv2.patch b/percona/5.0.77-b16/userstatv2.patch
deleted file mode 100644
index a5efe3e..0000000
--- a/percona/5.0.77-b16/userstatv2.patch
+++ /dev/null
@@ -1,4441 +0,0 @@
-diff -r 23e5576aa59a BUILD/Makefile.in
---- a/BUILD/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/BUILD/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a Docs/Makefile.in
---- a/Docs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/Docs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a Makefile.in
---- a/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a SSL/Makefile.in
---- a/SSL/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/SSL/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a aclocal.m4
---- a/aclocal.m4 Tue Feb 17 22:33:00 2009 -0800
-+++ b/aclocal.m4 Tue Feb 17 22:33:23 2009 -0800
-@@ -4412,6 +4412,9 @@
- # Is the compiler the GNU C compiler?
- with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-+gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-+gcc_ver=\`gcc -dumpversion\`
-+
- # An ERE matcher.
- EGREP=$lt_EGREP
-
-@@ -4545,11 +4548,11 @@
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
--predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-+predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place after the objects being linked to create a
- # shared library.
--postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-+postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Dependencies to place before the objects being linked to create a
- # shared library.
-@@ -4561,7 +4564,7 @@
-
- # The library search path used internally by the compiler when linking
- # a shared library.
--compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-+compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Method to check whether dependent libraries are shared objects.
- deplibs_check_method=$lt_deplibs_check_method
-@@ -4641,7 +4644,7 @@
- link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
- # Compile-time system search path for libraries
--sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-+sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
- # Run-time system search path for libraries
- sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-diff -r 23e5576aa59a client/Makefile.in
---- a/client/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/client/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/libedit/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -175,6 +175,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/cmd-line-utils/readline/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a configure
---- a/configure Tue Feb 17 22:33:00 2009 -0800
-+++ b/configure Tue Feb 17 22:33:23 2009 -0800
-@@ -39583,7 +39583,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -42956,7 +43040,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 23e5576aa59a configure.in
---- a/configure.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/configure.in Tue Feb 17 22:33:23 2009 -0800
-@@ -2098,7 +2098,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2713,7 +2724,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 23e5576aa59a dbug/Makefile.in
---- a/dbug/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/dbug/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/Makefile.in
---- a/extra/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/taocrypt/test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/extra/yassl/testsuite/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a heap/Makefile.in
---- a/heap/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/heap/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a include/Makefile.in
---- a/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a include/mysql_com.h
---- a/include/mysql_com.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/include/mysql_com.h Tue Feb 17 22:33:23 2009 -0800
-@@ -106,6 +106,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 23e5576aa59a libmysql/Makefile.in
---- a/libmysql/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysql/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysql_r/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysqld/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/libmysqld/examples/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a man/Makefile.in
---- a/man/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/man/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a myisam/Makefile.in
---- a/myisam/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/myisam/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/myisammrg/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/ndb/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/information_schema.result Tue Feb 17 22:33:23 2009 -0800
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- show global status like "Uptime_%";
- Variable_name Value
-diff -r 23e5576aa59a mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:23 2009 -0800
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 23e5576aa59a mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:23 2009 -0800
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 23e5576aa59a mysys/Makefile.in
---- a/mysys/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/mysys/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/Makefile.in
---- a/ndb/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/docs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/debugger/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/logger/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/mgmcommon/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/portlib/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/transporter/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/common/util/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/cw/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/cw/cpcd/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/error/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/kernel/vm/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmclient/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/mgmsrv/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/src/ndbapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/ndbapi/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/ndbapi/bank/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/run-test/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/src/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/test/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/ndb/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a netware/Makefile.in
---- a/netware/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/netware/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/Makefile.in
---- a/os2/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/include/Makefile.in
---- a/os2/include/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/include/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/os2/include/sys/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Tue Feb 17 22:33:23 2009 -0800
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 23e5576aa59a pstack/Makefile.in
---- a/pstack/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/pstack/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/pstack/aout/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a regex/Makefile.in
---- a/regex/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/regex/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a scripts/Makefile.in
---- a/scripts/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/scripts/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a server-tools/Makefile.in
---- a/server-tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/server-tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/server-tools/instance-manager/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/Makefile.in
---- a/sql/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -3324,6 +3324,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3596,6 +3598,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3643,6 +3647,8 @@
- innodb_srv_conc_enter_innodb(prebuilt->trx);
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-+
-+ if (error == DB_SUCCESS) rows_changed++;
-
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
-@@ -4076,6 +4082,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 23e5576aa59a sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/ha_myisam.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1518,13 +1520,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1535,6 +1541,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1545,6 +1558,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1555,6 +1575,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1565,6 +1592,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1575,6 +1609,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1585,6 +1626,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1595,6 +1643,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1611,6 +1666,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1628,6 +1690,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1642,6 +1705,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 23e5576aa59a sql/handler.cc
---- a/sql/handler.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/handler.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -725,6 +725,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -829,6 +831,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- if (all)
- thd->transaction_rollback_request= FALSE;
-@@ -1212,6 +1215,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1442,6 +1446,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2276,6 +2282,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 23e5576aa59a sql/handler.h
---- a/sql/handler.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/handler.h Tue Feb 17 22:33:23 2009 -0800
-@@ -30,6 +30,10 @@
- #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
- defined(HAVE_NDBCLUSTER_DB)
- #define USING_TRANSACTIONS
-+#endif
-+
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
- #endif
-
- // the following is for checking tables
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 23e5576aa59a sql/lex.h
---- a/sql/lex.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/lex.h Tue Feb 17 22:33:23 2009 -0800
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 23e5576aa59a sql/log.cc
---- a/sql/log.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/log.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -1954,18 +1954,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1981,6 +1987,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1991,6 +1999,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2112,6 +2122,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2158,6 +2169,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2226,6 +2238,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2234,6 +2248,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 23e5576aa59a sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/mysql_priv.h Tue Feb 17 22:33:23 2009 -0800
-@@ -823,7 +823,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1402,6 +1410,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1432,6 +1441,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1479,6 +1489,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 23e5576aa59a sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -415,6 +415,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -451,6 +452,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -551,6 +553,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1192,6 +1198,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1306,6 +1316,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3153,6 +3167,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3424,6 +3442,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3506,6 +3528,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4232,6 +4256,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5050,6 +5075,7 @@
- OPT_PROFILING,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6498,6 +6524,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 23e5576aa59a sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -828,6 +829,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1174,6 +1176,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 23e5576aa59a sql/share/Makefile.in
---- a/sql/share/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/share/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a sql/sql_base.cc
---- a/sql/sql_base.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_base.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 23e5576aa59a sql/sql_class.cc
---- a/sql/sql_class.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_class.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -236,6 +236,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -369,6 +376,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -408,6 +497,9 @@
-
- void THD::change_user(void)
- {
-+ pthread_mutex_lock(&LOCK_status);
-+ add_to_status(&global_status_var, &status_var);
-+ pthread_mutex_unlock(&LOCK_status);
- cleanup();
- cleanup_done= 0;
- init();
-@@ -892,6 +984,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1062,6 +1181,7 @@
- }
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1154,6 +1274,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2088,6 +2209,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2095,6 +2217,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 23e5576aa59a sql/sql_class.h
---- a/sql/sql_class.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_class.h Tue Feb 17 22:33:23 2009 -0800
-@@ -1299,6 +1299,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1488,6 +1490,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1594,6 +1598,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1649,6 +1696,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1878,7 +1930,13 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-+
-+ char *get_client_host_port(THD *client);
-
- public:
- /**
-@@ -1922,6 +1980,11 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-+#define LIST_PROCESS_HOST_LEN 64
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 23e5576aa59a sql/sql_delete.cc
---- a/sql/sql_delete.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_delete.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -869,6 +870,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 23e5576aa59a sql/sql_insert.cc
---- a/sql/sql_insert.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_insert.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -989,6 +989,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3036,6 +3037,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 23e5576aa59a sql/sql_lex.h
---- a/sql/sql_lex.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_lex.h Tue Feb 17 22:33:23 2009 -0800
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 23e5576aa59a sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -145,6 +151,17 @@
- #ifndef EMBEDDED_LIBRARY
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-+
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- net->vio && net->error && net->report_error)
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4428,6 +4883,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4735,6 +5199,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5571,6 +6036,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5606,6 +6072,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5638,11 +6105,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5676,6 +6147,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5708,6 +6180,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5739,6 +6212,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5792,8 +6271,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5810,9 +6289,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6321,6 +6803,30 @@
- */
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
-@@ -6400,6 +6906,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7411,8 +7954,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 23e5576aa59a sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_prepare.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -80,6 +80,9 @@
- #else
- #include <mysql_com.h>
- #endif
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-
- /* A result class used to send cursor rows using the binary protocol. */
-
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #ifdef ENABLED_PROFILING
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2502,6 +2716,43 @@
- stmt->state= Query_arena::PREPARED;
-
- send_ok(thd);
-+
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-
- DBUG_VOID_RETURN;
- }
-diff -r 23e5576aa59a sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -530,6 +530,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1872,6 +1873,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4482,6 +4777,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4491,6 +4857,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4499,6 +4867,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4524,10 +4894,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 23e5576aa59a sql/sql_update.cc
---- a/sql/sql_update.cc Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_update.cc Tue Feb 17 22:33:23 2009 -0800
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 23e5576aa59a sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/sql_yacc.yy Tue Feb 17 22:33:23 2009 -0800
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8244,6 +8249,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8448,9 +8485,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9439,6 +9481,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9491,6 +9534,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9600,6 +9644,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9616,6 +9661,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9636,6 +9682,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 23e5576aa59a sql/structs.h
---- a/sql/structs.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/structs.h Tue Feb 17 22:33:23 2009 -0800
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[USERNAME_LENGTH + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[USERNAME_LENGTH + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 23e5576aa59a sql/table.h
---- a/sql/table.h Tue Feb 17 22:33:00 2009 -0800
-+++ b/sql/table.h Tue Feb 17 22:33:23 2009 -0800
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 23e5576aa59a strings/Makefile.in
---- a/strings/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/strings/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/MacOSX/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/Makefile.in
---- a/support-files/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/support-files/RHEL4-SElinux/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a tests/Makefile.in
---- a/tests/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/tests/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a tools/Makefile.in
---- a/tools/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/tools/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a vio/Makefile.in
---- a/vio/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/vio/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a win/Makefile.in
---- a/win/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/win/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 23e5576aa59a zlib/Makefile.in
---- a/zlib/Makefile.in Tue Feb 17 22:33:00 2009 -0800
-+++ b/zlib/Makefile.in Tue Feb 17 22:33:23 2009 -0800
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.83-b17-20090706/innodb_check_fragmentation.patch b/percona/5.0.83-b17-20090706/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.83-b17-20090706/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.83-b17-20090706/innodb_dict_size_limit.patch b/percona/5.0.83-b17-20090706/innodb_dict_size_limit.patch
deleted file mode 100644
index 8ef4e36..0000000
--- a/percona/5.0.83-b17-20090706/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,477 +0,0 @@
-diff -ru mysql-5.0.75_base/innobase/dict/dict0boot.c mysql-5.0.75/innobase/dict/dict0boot.c
---- mysql-5.0.75_base/innobase/dict/dict0boot.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0boot.c 2009-01-23 19:28:25.000000000 +0900
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0crea.c mysql-5.0.75/innobase/dict/dict0crea.c
---- mysql-5.0.75_base/innobase/dict/dict0crea.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0crea.c 2009-01-23 19:41:38.000000000 +0900
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1266,6 +1269,11 @@
-
- trx->op_info = "";
-
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-diff -ru mysql-5.0.75_base/innobase/dict/dict0dict.c mysql-5.0.75/innobase/dict/dict0dict.c
---- mysql-5.0.75_base/innobase/dict/dict0dict.c 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/dict/dict0dict.c 2009-01-26 16:03:29.000000000 +0900
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -787,6 +791,8 @@
- table->n_mysql_handles_opened++;
- }
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-
-- ut_error;
-+ //ut_error;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1341,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-diff -ru mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c
---- mysql-5.0.75_base/innobase/ibuf/ibuf0ibuf.c 2009-01-23 11:44:18.000000000 +0900
-+++ mysql-5.0.75/innobase/ibuf/ibuf0ibuf.c 2009-01-23 19:22:54.000000000 +0900
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.h mysql-5.0.75/innobase/include/dict0dict.h
---- mysql-5.0.75_base/innobase/include/dict0dict.h 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.h 2009-01-23 21:46:22.000000000 +0900
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -ru mysql-5.0.75_base/innobase/include/dict0dict.ic mysql-5.0.75/innobase/include/dict0dict.ic
---- mysql-5.0.75_base/innobase/include/dict0dict.ic 2008-12-19 02:19:35.000000000 +0900
-+++ mysql-5.0.75/innobase/include/dict0dict.ic 2009-01-23 18:35:55.000000000 +0900
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -ru mysql-5.0.75_base/innobase/include/srv0srv.h mysql-5.0.75/innobase/include/srv0srv.h
---- mysql-5.0.75_base/innobase/include/srv0srv.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/include/srv0srv.h 2009-01-27 10:47:26.000000000 +0900
-@@ -146,6 +146,8 @@
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-
-+extern ulint srv_dict_size_limit;
-+
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
- extern ulong srv_io_pattern_trace_running;
-@@ -545,6 +547,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -ru mysql-5.0.75_base/innobase/srv/srv0srv.c mysql-5.0.75/innobase/srv/srv0srv.c
---- mysql-5.0.75_base/innobase/srv/srv0srv.c 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/innobase/srv/srv0srv.c 2009-01-27 10:52:19.000000000 +0900
-@@ -345,6 +345,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-
-+ulint srv_dict_size_limit = 0;
-+
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
- ulint srv_io_pattern_trace_running = 0;
-@@ -1936,6 +1938,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -ru mysql-5.0.75_base/sql/ha_innodb.cc mysql-5.0.75/sql/ha_innodb.cc
---- mysql-5.0.75_base/sql/ha_innodb.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.cc 2009-01-27 10:54:08.000000000 +0900
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -ru mysql-5.0.75_base/sql/ha_innodb.h mysql-5.0.75/sql/ha_innodb.h
---- mysql-5.0.75_base/sql/ha_innodb.h 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/ha_innodb.h 2009-01-26 15:49:37.000000000 +0900
-@@ -242,6 +242,7 @@
- extern ulong srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -ru mysql-5.0.75_base/sql/mysqld.cc mysql-5.0.75/sql/mysqld.cc
---- mysql-5.0.75_base/sql/mysqld.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/mysqld.cc 2009-01-26 15:29:45.000000000 +0900
-@@ -5053,6 +5053,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_RPL_MIRROR_BINLOG,
- OPT_SYNC_MIRROR_BINLOG,
-@@ -5406,6 +5407,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -ru mysql-5.0.75_base/sql/set_var.cc mysql-5.0.75/sql/set_var.cc
---- mysql-5.0.75_base/sql/set_var.cc 2009-01-23 11:44:19.000000000 +0900
-+++ mysql-5.0.75/sql/set_var.cc 2009-01-26 15:46:45.000000000 +0900
-@@ -522,6 +522,8 @@
- &innodb_read_ahead_typelib, fix_innodb_read_ahead);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -905,6 +907,7 @@
- &sys_innodb_flush_neighbor_pages,
- &sys_innodb_read_ahead,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1056,6 +1059,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
-diff -ruN mysql-5.0.75_base/mysql-test/r/innodb_dict_size_limit.result mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/r/innodb_dict_size_limit.result 2009-01-27 11:43:46.000000000 +0900
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -ruN mysql-5.0.75_base/mysql-test/t/innodb_dict_size_limit.test mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/mysql-test/t/innodb_dict_size_limit.test 2009-01-27 11:43:36.000000000 +0900
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -ruN mysql-5.0.75_base/patch_info/innodb_dict_size_limit.info mysql-5.0.75/patch_info/innodb_dict_size_limit.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.75/patch_info/innodb_dict_size_limit.info 2009-01-26 15:46:45.000000000 +0900
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
diff --git a/percona/5.0.83-b17-20090706/innodb_extra_rseg.patch b/percona/5.0.83-b17-20090706/innodb_extra_rseg.patch
deleted file mode 100644
index 1c8f429..0000000
--- a/percona/5.0.83-b17-20090706/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 13:37:45.000000000 +0900
-@@ -147,6 +147,8 @@
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-
-+extern ulint srv_extra_rsegments;
-+
- extern ulint srv_dict_size_limit;
-
- extern volatile ibool srv_io_pattern;
-diff -ruN a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/include/trx0sys.h 2009-05-06 14:52:00.000000000 +0900
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 13:38:23.000000000 +0900
-@@ -347,6 +347,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-+
- ulint srv_dict_size_limit = 0;
-
- volatile ibool srv_io_pattern = FALSE;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 14:54:43.000000000 +0900
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -ruN a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c 2009-05-06 15:35:46.000000000 +0900
-+++ b/innobase/trx/trx0sys.c 2009-05-06 14:54:02.000000000 +0900
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -ruN a/patch_info/innodb_extra_rseg.info b/patch_info/innodb_extra_rseg.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_extra_rseg.info 2009-05-06 14:49:48.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:27:49.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1507,6 +1508,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 13:51:35.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 14:12:05.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_RPL_MIRROR_BINLOG,
-@@ -5454,6 +5455,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 14:13:24.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
---- a/sql/sql_show.cc 2009-05-06 15:35:46.000000000 +0900
-+++ b/sql/sql_show.cc 2009-05-06 15:29:47.000000000 +0900
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4160,6 +4162,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4978,6 +5019,16 @@
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
- #endif
-
- ST_FIELD_INFO variables_fields_info[]=
-@@ -5157,6 +5208,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.83-b17-20090706/innodb_extra_status.patch b/percona/5.0.83-b17-20090706/innodb_extra_status.patch
deleted file mode 100644
index adc1642..0000000
--- a/percona/5.0.83-b17-20090706/innodb_extra_status.patch
+++ /dev/null
@@ -1,747 +0,0 @@
-diff -r b059d02ec814 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -2353,6 +2353,7 @@
- "AWE: Database pages and free buffers mapped in frames %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
-+ if (file) {
- fprintf(file,
- "Buffer pool size %lu\n"
- "Free buffers %lu\n"
-@@ -2371,11 +2372,13 @@
- + buf_pool->init_flush[BUF_FLUSH_LIST],
- (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
-
-+ } // if (file)
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time,
- buf_pool->last_printout_time);
- buf_pool->last_printout_time = current_time;
-
-+ if (file) {
- fprintf(file,
- "Pages read %lu, created %lu, written %lu\n"
- "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
-@@ -2405,6 +2408,7 @@
- } else {
- fputs("No buffer pool page gets since the last printout\n",
- file);
-+ }
- }
-
- buf_pool->n_page_gets_old = buf_pool->n_page_gets;
-diff -r b059d02ec814 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -3519,9 +3519,15 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ inno_ibuf_size = 0;
-+ inno_ibuf_inserts = 0;
-+ inno_ibuf_merged_recs = 0;
-+ inno_ibuf_merges = 0;
-+
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
-+ if (file) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
-@@ -3542,6 +3548,12 @@
- }
- }
- #endif
-+ } // if (file)
-+ inno_ibuf_size += (ulong) data->size;
-+ inno_ibuf_inserts += (ulong) data->n_inserts;
-+ inno_ibuf_merged_recs += (ulong) data->n_merged_recs;
-+ inno_ibuf_merges += (ulong) data->n_merges;
-+
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
-diff -r b059d02ec814 innobase/include/lock0lock.h
---- a/innobase/include/lock0lock.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/lock0lock.h Mon Nov 03 05:09:34 2008 -0800
-@@ -24,6 +24,10 @@
- #endif /* UNIV_DEBUG */
- /* Buffer for storing information about the most recent deadlock error */
- extern FILE* lock_latest_err_file;
-+
-+/* number of deadlocks happened so far */
-+extern ulint innodb_deadlocks;
-+
-
- /*************************************************************************
- Gets the size of a lock struct. */
-diff -r b059d02ec814 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:09:34 2008 -0800
-@@ -261,6 +261,12 @@
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+extern ibool srv_long_lock_wait;
-+
-+/* variable to count the number long semaphore waits noticed */
-+extern ulint srv_long_lock_waits;
-+
- /* Number of IO operations read/write done for all threads */
- extern ulint os_aio_read_requests;
- extern ulint os_aio_write_requests;
-@@ -278,6 +284,26 @@
- extern ulint inno_pending_ibuf_aio_reads;
- extern ulint inno_pending_log_ios;
- extern ulint inno_pending_sync_ios;
-+
-+/* all 24 innodb status variables, exported to status */
-+extern ulint inno_transaction_count;
-+extern ulint inno_transaction_purge_count;
-+extern ulint inno_transaction_purge_lag;
-+extern ulint inno_num_active_transactions;
-+extern ulint inno_summed_transaction_age;
-+extern ulint inno_longest_transaction_age;
-+extern ulint inno_lock_wait_timeouts;
-+extern ulint inno_num_lock_waiters;
-+extern ulint inno_summed_lock_wait_time;
-+extern ulint inno_longest_lock_wait;
-+extern ulint inno_os_reads;
-+extern ulint inno_os_writes;
-+extern ulint inno_os_fsyncs;
-+extern ulint inno_ibuf_size;
-+extern ulint inno_ibuf_inserts;
-+extern ulint inno_ibuf_merged_recs;
-+extern ulint inno_ibuf_merges;
-+extern ulint inno_log_ios_done;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-@@ -552,6 +578,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_size;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-@@ -587,6 +614,43 @@
- ulint innodb_rows_inserted;
- ulint innodb_rows_updated;
- ulint innodb_rows_deleted;
-+ ibool innodb_long_lock_wait;
-+ ulint innodb_long_lock_waits;
-+
-+ ulint innodb_os_aio_read_requests;
-+ ulint innodb_os_aio_write_requests;
-+ ulint innodb_os_aio_pages_read;
-+ ulint innodb_os_aio_pages_written;
-+ ib_longlong innodb_os_aio_read_time;
-+ ib_longlong innodb_os_aio_write_time;
-+ ib_longlong innodb_os_aio_read_time_avg;
-+ ib_longlong innodb_os_aio_write_time_avg;
-+ ulint innodb_deadlocks;
-+
-+ // the following 24 variables are exported to "show status"
-+ ulint inno_transaction_count;
-+ ulint inno_transaction_purge_count;
-+ ulint inno_transaction_purge_lag;
-+ ulint inno_num_active_transactions;
-+ ulint inno_summed_transaction_age;
-+ ulint inno_longest_transaction_age;
-+ ulint inno_lock_wait_timeouts;
-+ ulint inno_num_lock_waiters;
-+ ulint inno_summed_lock_wait_time;
-+ ulint inno_longest_lock_wait;
-+ ulint inno_pending_normal_aio_reads;
-+ ulint inno_pending_normal_aio_writes;
-+ ulint inno_pending_ibuf_aio_reads;
-+ ulint inno_pending_log_ios;
-+ ulint inno_pending_sync_ios;
-+ ulint inno_os_reads;
-+ ulint inno_os_writes;
-+ ulint inno_os_fsyncs;
-+ ulint inno_ibuf_size;
-+ ulint inno_ibuf_inserts;
-+ ulint inno_ibuf_merged_recs;
-+ ulint inno_ibuf_merges;
-+ ulint inno_log_ios_done;
- };
-
- /* The server system struct */
-diff -r b059d02ec814 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Nov 03 05:09:34 2008 -0800
-@@ -360,6 +360,9 @@
- ibool lock_deadlock_found = FALSE;
- FILE* lock_latest_err_file;
-
-+/* number of deadlocks happened so far */
-+ulint innodb_deadlocks = 0;
-+
- /* Flags for recursive deadlock search */
- #define LOCK_VICTIM_IS_START 1
- #define LOCK_VICTIM_IS_OTHER 2
-@@ -3304,6 +3307,7 @@
-
- FILE* ef = lock_latest_err_file;
-
-+ innodb_deadlocks++;
- rewind(ef);
- ut_print_timestamp(ef);
-
-@@ -4238,6 +4242,7 @@
- innobase_mysql_prepare_print_arbitrary_thd();
- lock_mutex_enter_kernel();
-
-+ if (file) {
- if (lock_deadlock_found) {
- fputs(
- "------------------------\n"
-@@ -4269,6 +4274,12 @@
- fprintf(file,
- "Total number of lock structs in row lock hash table %lu\n",
- (ulong) lock_get_n_rec_locks());
-+ } // if (file)
-+ inno_transaction_purge_count =
-+ (ulong) ut_dulint_get_low(purge_sys->purge_trx_no);
-+ inno_transaction_count =
-+ (ulong) ut_dulint_get_low(trx_sys->max_trx_id);
-+ inno_transaction_purge_lag = (ulong) trx_sys->rseg_history_len;
- }
-
- /*************************************************************************
-@@ -4289,7 +4300,17 @@
- ulint i;
- mtr_t mtr;
- trx_t* trx;
--
-+ time_t current_time = time(NULL);
-+
-+ /* init all counters to be updated */
-+ inno_num_lock_waiters = 0;
-+ inno_summed_lock_wait_time = 0;
-+ inno_longest_lock_wait = 0;
-+ inno_num_active_transactions = 0;
-+ inno_summed_transaction_age = 0;
-+ inno_longest_transaction_age = 0;
-+
-+ if (file) {
- fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
-
- /* First print info on non-active transactions */
-@@ -4304,6 +4325,7 @@
-
- trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
- }
-+ } // if (file)
-
- loop:
- trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
-@@ -4330,6 +4352,7 @@
- }
-
- if (nth_lock == 0) {
-+ if (file) {
- fputs("---", file);
- trx_print(file, trx, 600);
-
-@@ -4341,11 +4364,27 @@
- (ulong) ut_dulint_get_high(trx->read_view->up_limit_id),
- (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
- }
-+ } // if (file)
-+
-+ if (trx->conc_state == TRX_ACTIVE) {
-+ ulong trx_age = (ulong)difftime(time(NULL), trx->start_time);
-+ inno_num_active_transactions++;
-+ inno_summed_transaction_age += trx_age;
-+ if (inno_longest_transaction_age > trx_age)
-+ inno_longest_transaction_age = trx_age;
-+ }
-
- if (trx->que_state == TRX_QUE_LOCK_WAIT) {
-+ ulong wait_time = (ulong)difftime(current_time,
-+ trx->wait_started);
-+ inno_num_lock_waiters++;
-+ inno_summed_lock_wait_time += wait_time;
-+ if (inno_longest_lock_wait < wait_time)
-+ inno_longest_lock_wait = wait_time;
-+ if (file) {
- fprintf(file,
- "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
-- (ulong)difftime(time(NULL), trx->wait_started));
-+ wait_time);
-
- if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(file, trx->wait_lock);
-@@ -4354,10 +4393,16 @@
- }
-
- fputs("------------------\n", file);
-- }
-- }
--
-- if (!srv_print_innodb_lock_monitor) {
-+ } // if (file)
-+ }
-+ }
-+
-+ /* don't print locks per transaction if either
-+ 1) srv_print_innodb_lock_monitor is NOT set,
-+ ie no magic table innodb_lock_monitor is created, or
-+ 2) file == NULL, ie, at counter updating stage from "show status"
-+ */
-+ if (!srv_print_innodb_lock_monitor || !file) {
- nth_trx++;
- goto loop;
- }
-diff -r b059d02ec814 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:09:34 2008 -0800
-@@ -267,6 +267,35 @@
- ulint inno_pending_log_ios = 0;
- ulint inno_pending_sync_ios = 0;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+ibool srv_long_lock_wait = FALSE;
-+
-+/* variable to count the number long semaphore waits noticed */
-+ulint srv_long_lock_waits = 0;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+extern long innobase_min_status_update_time_interval;
-+
-+/* all 24 innodb status variables, exported to status */
-+ulint inno_transaction_count = 0;
-+ulint inno_transaction_purge_count = 0;
-+ulint inno_transaction_purge_lag = 0;
-+ulint inno_num_active_transactions = 0;
-+ulint inno_summed_transaction_age = 0;
-+ulint inno_longest_transaction_age = 0;
-+ulint inno_lock_wait_timeouts = 0; /* Counts number of lock wait timeouts. */
-+ulint inno_num_lock_waiters = 0;
-+ulint inno_summed_lock_wait_time = 0;
-+ulint inno_longest_lock_wait = 0;
-+ulint inno_os_reads = 0;
-+ulint inno_os_writes = 0;
-+ulint inno_os_fsyncs = 0;
-+ulint inno_ibuf_size = 0;
-+ulint inno_ibuf_inserts = 0;
-+ulint inno_ibuf_merged_recs = 0;
-+ulint inno_ibuf_merges = 0;
-+ulint inno_log_ios_done = 0;
-+
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-
-@@ -419,6 +448,10 @@
- const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
-
- time_t srv_last_monitor_time;
-+
-+/* last time innodb status were updated thru show status */
-+time_t srv_last_innodb_status_time = 0;
-+
-
- mutex_t srv_innodb_monitor_mutex;
-
-@@ -677,6 +710,24 @@
-
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-+
-+/*************************************************************************
-+Prints counters for work done by srv_master_thread. */
-+
-+static
-+void
-+srv_print_extra(
-+/*===================*/
-+ FILE *file) /* in: output stream */
-+{
-+ fprintf(file, "srv_master_thread loops: %lu 1_second, %lu sleeps, "
-+ "%lu 10_second, %lu background, %lu flush\n",
-+ srv_main_1_second_loops, srv_main_sleeps,
-+ srv_main_10_second_loops, srv_main_background_loops,
-+ srv_main_flush_loops);
-+ fprintf(file, "srv_master_thread log flush: %lu sync, %lu async\n",
-+ srv_sync_flush, srv_async_flush);
-+}
-
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-@@ -1685,12 +1736,13 @@
- fputs("----------\n"
- "BACKGROUND THREAD\n"
- "----------\n", file);
-+ srv_print_extra(file);
- fil_print(file);
--
-
- fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
-+ fprintf(file, "Lock wait timeouts %lu\n", inno_lock_wait_timeouts);
- sync_print(file);
-
- /* Conceptually, srv_innodb_monitor_mutex has a very high latching
-@@ -1709,24 +1761,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1815,6 +1849,27 @@
- (srv_n_rows_read - srv_n_rows_read_old)
- / time_elapsed);
-
-+ /* Print open transaction details */
-+ lock_print_info_summary(file);
-+
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- srv_n_rows_inserted_old = srv_n_rows_inserted;
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
-@@ -1833,7 +1888,8 @@
- void
- srv_export_innodb_status(void)
- {
--
-+ long time_elapsed;
-+ time_t current_time;
- mutex_enter(&srv_innodb_monitor_mutex);
- export_vars.innodb_data_pending_reads= os_n_pending_reads;
- export_vars.innodb_data_pending_writes= os_n_pending_writes;
-@@ -1844,6 +1900,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_size= dict_sys->size;
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-@@ -1854,10 +1911,12 @@
- export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
- export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
- export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
-- export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
-+ /* This function uses too much CPU for large buffer caches. */
-+ export_vars.innodb_buffer_pool_pages_latched= 1; /* buf_get_latched_pages_number(); */
- export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
- export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
- UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
-+
- export_vars.innodb_page_size= UNIV_PAGE_SIZE;
- export_vars.innodb_log_waits= srv_log_waits;
- export_vars.innodb_os_log_written= srv_os_log_written;
-@@ -1885,6 +1944,103 @@
- export_vars.innodb_rows_inserted= srv_n_rows_inserted;
- export_vars.innodb_rows_updated= srv_n_rows_updated;
- export_vars.innodb_rows_deleted= srv_n_rows_deleted;
-+ export_vars.innodb_long_lock_wait = srv_long_lock_wait;
-+ export_vars.innodb_long_lock_waits = srv_long_lock_waits;
-+
-+ export_vars.innodb_os_aio_read_requests = os_aio_read_requests;
-+ export_vars.innodb_os_aio_write_requests = os_aio_write_requests;
-+
-+ export_vars.innodb_os_aio_pages_read = os_aio_pages_read;
-+ export_vars.innodb_os_aio_pages_written = os_aio_pages_written;
-+
-+ export_vars.innodb_os_aio_read_time = os_aio_read_time;
-+ export_vars.innodb_os_aio_write_time = os_aio_write_time;
-+
-+ if (os_aio_read_requests > 0 ) {
-+ export_vars.innodb_os_aio_read_time_avg
-+ = os_aio_read_time / os_aio_read_requests;
-+ } else {
-+ export_vars.innodb_os_aio_read_time_avg = 0;
-+ }
-+ if (os_aio_write_requests > 0 ) {
-+ export_vars.innodb_os_aio_write_time_avg
-+ = os_aio_write_time / os_aio_write_requests;
-+ } else {
-+ export_vars.innodb_os_aio_write_time_avg = 0;
-+ }
-+
-+ export_vars.innodb_deadlocks = innodb_deadlocks;
-+
-+ // simulate srv_printf_innodb_monitor, invoked by innodb_show_status
-+ // 0. direct printout inno_lock_wait_timeouts, declared in srv0srv.c
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_lock_wait_timeouts = inno_lock_wait_timeouts;
-+
-+ // *_print functions are allowed to be called once every
-+ // some seconds to prevent too frequent invocation.
-+ // the number is innobase_min_status_update_time_interval
-+ current_time = time(NULL);
-+ time_elapsed = difftime(current_time, srv_last_innodb_status_time);
-+ if (time_elapsed >= innobase_min_status_update_time_interval) {
-+ os_aio_print(NULL);
-+ ibuf_print(NULL);
-+ buf_print_io(NULL);
-+ lock_print_info_summary(NULL);
-+ lock_print_info_all_transactions(NULL);
-+
-+ srv_last_innodb_status_time = current_time;
-+ }
-+
-+ // 1. os_aio_print
-+ // the following were filled by calling os_aio_print
-+ // total # of variable(s) updated: 8
-+
-+ export_vars.inno_pending_normal_aio_reads =
-+ inno_pending_normal_aio_reads;
-+ export_vars.inno_pending_normal_aio_writes =
-+ inno_pending_normal_aio_writes;
-+ export_vars.inno_pending_ibuf_aio_reads = inno_pending_ibuf_aio_reads;
-+ export_vars.inno_pending_log_ios = inno_pending_log_ios;
-+ export_vars.inno_pending_sync_ios = inno_pending_sync_ios;
-+ export_vars.inno_os_reads = os_n_file_reads;
-+ export_vars.inno_os_writes = os_n_file_writes;
-+ export_vars.inno_os_fsyncs = os_n_fsyncs;
-+
-+ // 2. ibuf_print()
-+ // total # of variable(s) updated: 4
-+
-+ export_vars.inno_ibuf_size = inno_ibuf_size;
-+ export_vars.inno_ibuf_inserts = inno_ibuf_inserts;
-+ export_vars.inno_ibuf_merged_recs = inno_ibuf_merged_recs;
-+ export_vars.inno_ibuf_merges = inno_ibuf_merges;
-+
-+ // 3. log_print
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_log_ios_done = (ulong) log_sys->n_log_ios;
-+
-+ // 5. lock_print_info_summary
-+ // it enters the mutexes
-+ // 1) innobase_mysql_prepare_print_arbitrary_thd()
-+ // 2) lock_mutex_enter_kernel()
-+ // total # of variable(s) updated: 3
-+
-+ export_vars.inno_transaction_count = inno_transaction_count;
-+ export_vars.inno_transaction_purge_count =
-+ inno_transaction_purge_count;
-+ export_vars.inno_transaction_purge_lag = inno_transaction_purge_lag;
-+
-+ // 6. lock_print_info_all_transactions(NULL)
-+ // it exits two mutexes entered from lock_print_info_summary(NULL)
-+ // total # of variable(s) updated: 6
-+
-+ export_vars.inno_num_active_transactions = inno_num_active_transactions;
-+ export_vars.inno_summed_transaction_age = inno_summed_transaction_age;
-+ export_vars.inno_longest_transaction_age = inno_longest_transaction_age;
-+
-+ export_vars.inno_num_lock_waiters = inno_num_lock_waiters;
-+ export_vars.inno_summed_lock_wait_time = inno_summed_lock_wait_time;
-+ export_vars.inno_longest_lock_wait = inno_longest_lock_wait;
-+
- mutex_exit(&srv_innodb_monitor_mutex);
-
- }
-@@ -2026,6 +2182,7 @@
- if (thr_get_trx(slot->thr)->wait_lock) {
- lock_cancel_waiting_and_release(
- thr_get_trx(slot->thr)->wait_lock);
-+ ++inno_lock_wait_timeouts;
- }
- }
- }
-diff -r b059d02ec814 patch_info/innodb_extra_status.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_status.info Mon Nov 03 05:09:34 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_extra_status.patch
-+Name=Adds additional information of InnoDB counters into SHOW STATUS
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-03
-+VT: Initial porting
-diff -r b059d02ec814 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -299,12 +299,36 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_size",
-+ (char*) &export_vars.innodb_dict_size, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
- {"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
-+ {"long_lock_wait",
-+ (char*) &export_vars.innodb_long_lock_wait, SHOW_BOOL},
-+ {"long_lock_waits",
-+ (char*) &export_vars.innodb_long_lock_waits, SHOW_LONG},
-+
-+ {"os_read_requests",
-+ (char*) &export_vars.innodb_os_aio_read_requests, SHOW_LONG},
-+ {"os_write_requests",
-+ (char*) &export_vars.innodb_os_aio_write_requests, SHOW_LONG},
-+ {"os_pages_read",
-+ (char*) &export_vars.innodb_os_aio_pages_read, SHOW_LONG},
-+ {"os_pages_written",
-+ (char*) &export_vars.innodb_os_aio_pages_written, SHOW_LONG},
-+ {"os_read_time",
-+ (char*) &export_vars.innodb_os_aio_read_time, SHOW_LONGLONG},
-+ {"os_write_time",
-+ (char*) &export_vars.innodb_os_aio_write_time, SHOW_LONGLONG},
-+ {"time_per_read",
-+ (char*) &export_vars.innodb_os_aio_read_time_avg, SHOW_LONGLONG},
-+ {"time_per_write",
-+ (char*) &export_vars.innodb_os_aio_write_time_avg, SHOW_LONGLONG},
-+
- {"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
- {"os_log_pending_fsyncs",
-@@ -339,6 +363,56 @@
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
- {"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
-+ {"deadlocks",
-+ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
-+
-+ /* 24 innodb status variables exported to status */
-+ {"transaction_count",
-+ (char*) &export_vars.inno_transaction_count, SHOW_LONG},
-+ {"transaction_purge_count",
-+ (char*) &export_vars.inno_transaction_purge_count, SHOW_LONG},
-+ {"transaction_purge_lag",
-+ (char*) &export_vars.inno_transaction_purge_lag, SHOW_LONG},
-+ {"active_transactions",
-+ (char*) &export_vars.inno_num_active_transactions, SHOW_LONG},
-+ {"summed_transaction_age",
-+ (char*) &export_vars.inno_summed_transaction_age, SHOW_LONG},
-+ {"longest_transaction_age",
-+ (char*) &export_vars.inno_longest_transaction_age, SHOW_LONG},
-+ {"lock_wait_timeouts",
-+ (char*) &export_vars.inno_lock_wait_timeouts, SHOW_LONG},
-+ {"lock_waiters",
-+ (char*) &export_vars.inno_num_lock_waiters, SHOW_LONG},
-+ {"summed_lock_wait_time",
-+ (char*) &export_vars.inno_summed_lock_wait_time, SHOW_LONG},
-+ {"longest_lock_wait",
-+ (char*) &export_vars.inno_longest_lock_wait, SHOW_LONG},
-+ {"pending_normal_aio_reads",
-+ (char*) &export_vars.inno_pending_normal_aio_reads, SHOW_LONG},
-+ {"pending_normal_aio_writes",
-+ (char*) &export_vars.inno_pending_normal_aio_writes, SHOW_LONG},
-+ {"pending_ibuf_aio_reads",
-+ (char*) &export_vars.inno_pending_ibuf_aio_reads, SHOW_LONG},
-+ {"pending_log_ios",
-+ (char*) &export_vars.inno_pending_log_ios, SHOW_LONG},
-+ {"pending_sync_ios",
-+ (char*) &export_vars.inno_pending_sync_ios, SHOW_LONG},
-+ {"os_reads",
-+ (char*) &export_vars.inno_os_reads, SHOW_LONG},
-+ {"os_writes",
-+ (char*) &export_vars.inno_os_writes, SHOW_LONG},
-+ {"os_fsyncs",
-+ (char*) &export_vars.inno_os_fsyncs, SHOW_LONG},
-+ {"ibuf_inserts",
-+ (char*) &export_vars.inno_ibuf_size, SHOW_LONG},
-+ {"ibuf_size",
-+ (char*) &export_vars.inno_ibuf_inserts, SHOW_LONG},
-+ {"ibuf_merged_recs",
-+ (char*) &export_vars.inno_ibuf_merged_recs, SHOW_LONG},
-+ {"ibuf_merges",
-+ (char*) &export_vars.inno_ibuf_merges, SHOW_LONG},
-+ {"log_ios_done",
-+ (char*) &export_vars.inno_log_ios_done, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}};
-
- /* General functions */
-diff -r b059d02ec814 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:09:34 2008 -0800
-@@ -198,6 +198,7 @@
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
- extern long innobase_max_merged_io;
-+extern long innobase_min_status_update_time_interval;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-diff -r b059d02ec814 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -4950,6 +4950,7 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -6031,6 +6032,14 @@
- (gptr*) &srv_thread_sleep_delay,
- (gptr*) &srv_thread_sleep_delay,
- 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
-+ {"innodb_status_update_interval",
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
-+ "Minimum time interval in seconds before InnoDB status counters "
-+ "are updated during SHOW STATUS. "
-+ "InnoDB counters are always updated during SHOW INNODB STATUS.",
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ 0, GET_LONG, REQUIRED_ARG, 30, 0, 3600, 0, 1, 0},
- #endif /* HAVE_INNOBASE_DB */
- {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
- "The number of seconds the server waits for activity on an interactive connection before closing it.",
-diff -r b059d02ec814 sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -948,6 +948,8 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
- {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
-+ {"innodb_status_update_interval",
-+ (char*) &innobase_min_status_update_time_interval, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090706/innodb_fsync_source.patch b/percona/5.0.83-b17-20090706/innodb_fsync_source.patch
deleted file mode 100644
index 637a7d6..0000000
--- a/percona/5.0.83-b17-20090706/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r 61031ebb48ce innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/buf/buf0flu.c Mon Nov 03 05:07:56 2008 -0800
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r 61031ebb48ce innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/fil/fil0fil.c Mon Nov 03 05:07:56 2008 -0800
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4166,8 +4187,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4176,7 +4198,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4281,7 +4303,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4322,7 +4345,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r 61031ebb48ce innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/fil0fil.h Mon Nov 03 05:07:56 2008 -0800
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -621,14 +628,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -636,7 +655,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r 61031ebb48ce innobase/include/log0log.h
---- a/innobase/include/log0log.h Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/include/log0log.h Mon Nov 03 05:07:56 2008 -0800
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
-@@ -744,6 +767,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r 61031ebb48ce innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:07:56 2008 -0800
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1551,7 +1567,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1921,11 +1937,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1938,7 +1954,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2566,7 +2583,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2647,7 +2664,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3184,8 +3202,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3218,7 +3236,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3331,15 +3349,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r 61031ebb48ce innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:07:56 2008 -0800
-@@ -1638,6 +1638,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r 61031ebb48ce innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0sys.c Mon Nov 03 05:07:56 2008 -0800
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r 61031ebb48ce innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Nov 03 05:07:46 2008 -0800
-+++ b/innobase/trx/trx0trx.c Mon Nov 03 05:07:56 2008 -0800
-@@ -916,19 +916,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1659,18 +1661,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1906,19 +1911,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r 61031ebb48ce patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Mon Nov 03 05:07:56 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.83-b17-20090706/innodb_io_patches.patch b/percona/5.0.83-b17-20090706/innodb_io_patches.patch
deleted file mode 100644
index 8247a32..0000000
--- a/percona/5.0.83-b17-20090706/innodb_io_patches.patch
+++ /dev/null
@@ -1,705 +0,0 @@
-diff -r ed298a6e5e10 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/buf/buf0flu.c Mon Jun 01 00:36:16 2009 -0700
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -r ed298a6e5e10 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/buf/buf0rea.c Mon Jun 01 00:36:16 2009 -0700
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +190,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +401,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -r ed298a6e5e10 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Jun 01 00:36:16 2009 -0700
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -r ed298a6e5e10 innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/include/os0file.h Mon Jun 01 00:36:16 2009 -0700
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -r ed298a6e5e10 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:16 2009 -0700
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern ulint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r ed298a6e5e10 innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/log/log0log.c Mon Jun 01 00:36:16 2009 -0700
-@@ -3326,6 +3326,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -r ed298a6e5e10 innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/os/os0file.c Mon Jun 01 00:36:16 2009 -0700
-@@ -2878,8 +2878,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2889,6 +2891,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2899,8 +2903,8 @@
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-@@ -3181,6 +3185,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3199,6 +3210,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3206,6 +3227,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-diff -r ed298a6e5e10 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:16 2009 -0700
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -330,6 +332,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2229,6 +2249,8 @@
- ibool skip_sleep = FALSE;
- ulint i;
-
-+ dulint oldest_lsn;
-+
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
-@@ -2317,9 +2339,9 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-@@ -2332,7 +2354,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2341,6 +2363,49 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ } else if (srv_adaptive_checkpoint) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2367,10 +2432,10 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2380,7 +2445,7 @@
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-@@ -2422,14 +2487,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2518,7 +2583,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2535,7 +2600,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-diff -r ed298a6e5e10 innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Mon Jun 01 00:36:10 2009 -0700
-+++ b/innobase/srv/srv0start.c Mon Jun 01 00:36:16 2009 -0700
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ srv_n_read_io_threads, srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS * 8);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -r ed298a6e5e10 patch_info/innodb_io_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_patches.info Mon Jun 01 00:36:16 2009 -0700
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -r ed298a6e5e10 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Jun 01 00:36:10 2009 -0700
-+++ b/sql/ha_innodb.cc Mon Jun 01 00:36:16 2009 -0700
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1417,6 +1418,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7330,6 +7333,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -r ed298a6e5e10 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:10 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:16 2009 -0700
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,15 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern ulong srv_adaptive_checkpoint;
-+
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
- running with the fix disabled because MySQL 5.1 is frozen for such
-diff -r ed298a6e5e10 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:10 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:16 2009 -0700
-@@ -5086,6 +5086,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5403,6 +5413,45 @@
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. 0:disable 1:enable",
-+ (gptr*) &srv_adaptive_checkpoint, (gptr*) &srv_adaptive_checkpoint,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7644,6 +7693,22 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -r ed298a6e5e10 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:10 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:16 2009 -0700
-@@ -489,6 +489,39 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -860,6 +893,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -997,6 +1037,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -1459,6 +1509,13 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -r ed298a6e5e10 sql/set_var.h
---- a/sql/set_var.h Mon Jun 01 00:36:10 2009 -0700
-+++ b/sql/set_var.h Mon Jun 01 00:36:16 2009 -0700
-@@ -31,6 +31,10 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1152,9 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.83-b17-20090706/innodb_io_pattern.patch b/percona/5.0.83-b17-20090706/innodb_io_pattern.patch
deleted file mode 100644
index 305f63d..0000000
--- a/percona/5.0.83-b17-20090706/innodb_io_pattern.patch
+++ /dev/null
@@ -1,688 +0,0 @@
-diff -r 5060df9888d7 include/mysql_com.h
---- a/include/mysql_com.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/include/mysql_com.h Tue Feb 17 22:33:58 2009 -0800
-@@ -121,6 +121,9 @@
- #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-+
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-diff -r 5060df9888d7 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/buf/buf0buf.c Tue Feb 17 22:33:58 2009 -0800
-@@ -653,6 +653,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1966,6 +1969,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2067,6 +2073,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2082,6 +2108,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2656,3 +2702,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r 5060df9888d7 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0buf.h Tue Feb 17 22:33:58 2009 -0800
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r 5060df9888d7 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/buf0types.h Tue Feb 17 22:33:58 2009 -0800
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r 5060df9888d7 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/include/srv0srv.h Tue Feb 17 22:33:58 2009 -0800
-@@ -145,6 +145,11 @@
- extern ulint srv_flush_neighbor_pages;
- extern uint srv_read_ahead;
- extern ulint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r 5060df9888d7 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Feb 17 22:33:54 2009 -0800
-+++ b/innobase/srv/srv0srv.c Tue Feb 17 22:33:58 2009 -0800
-@@ -344,6 +344,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r 5060df9888d7 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema.result Tue Feb 17 22:33:58 2009 -0800
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r 5060df9888d7 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/information_schema_db.result Tue Feb 17 22:33:58 2009 -0800
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r 5060df9888d7 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:54 2009 -0800
-+++ b/mysql-test/r/mysqlshow.result Tue Feb 17 22:33:58 2009 -0800
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r 5060df9888d7 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Tue Feb 17 22:33:58 2009 -0800
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r 5060df9888d7 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -1569,6 +1569,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6535,6 +6537,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r 5060df9888d7 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/ha_innodb.h Tue Feb 17 22:33:58 2009 -0800
-@@ -245,6 +245,9 @@
- extern ulong srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-@@ -270,6 +273,9 @@
- bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-+
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-
- void innobase_release_temporary_latches(THD *thd);
-
-diff -r 5060df9888d7 sql/lex.h
---- a/sql/lex.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/lex.h Tue Feb 17 22:33:58 2009 -0800
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r 5060df9888d7 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/mysqld.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -5026,6 +5026,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5445,6 +5448,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 5060df9888d7 sql/set_var.cc
---- a/sql/set_var.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -528,6 +528,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -901,6 +907,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1072,6 +1072,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -3160,6 +3172,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r 5060df9888d7 sql/set_var.h
---- a/sql/set_var.h Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/set_var.h Tue Feb 17 22:33:58 2009 -0800
-@@ -989,6 +989,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r 5060df9888d7 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_parse.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -8009,6 +8009,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 5060df9888d7 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_show.cc Tue Feb 17 22:33:58 2009 -0800
-@@ -32,6 +32,17 @@
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
- #endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
-@@ -4088,6 +4099,67 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4894,6 +4966,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5069,6 +5154,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 5060df9888d7 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Tue Feb 17 22:33:54 2009 -0800
-+++ b/sql/sql_yacc.yy Tue Feb 17 22:33:58 2009 -0800
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8541,6 +8542,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9594,6 +9596,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.83-b17-20090706/innodb_io_tune.patch b/percona/5.0.83-b17-20090706/innodb_io_tune.patch
deleted file mode 100644
index 3953e1d..0000000
--- a/percona/5.0.83-b17-20090706/innodb_io_tune.patch
+++ /dev/null
@@ -1,1823 +0,0 @@
-diff -r 322370200e6a innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/os0file.h Mon Nov 03 05:08:52 2008 -0800
-@@ -532,21 +532,16 @@
- FALSE otherwise */
- const char* path); /* in: path name */
- /****************************************************************************
--Initializes the asynchronous io system. Creates separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
-+Initializes the asynchronous io system. */
-
--void
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ /* out: number of AIO handler threads */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per IO array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -r 322370200e6a innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-@@ -87,6 +87,14 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-+
-+/* Number of IO operations per second the server can do */
-+extern ulint srv_io_capacity;
-+
-+/* Flush dirty pages when below max dirty percent */
-+extern ibool srv_extra_dirty_writes;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -252,6 +260,24 @@
-
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-+
-+/* Number of IO operations read/write done for all threads */
-+extern ulint os_aio_read_requests;
-+extern ulint os_aio_write_requests;
-+
-+/* Number of pages read/written done for all threads */
-+extern ulint os_aio_pages_read;
-+extern ulint os_aio_pages_written;
-+
-+/* time usec used to perform read/write for all threads */
-+extern ib_longlong os_aio_read_time;
-+extern ib_longlong os_aio_write_time;
-+
-+extern ulint inno_pending_normal_aio_reads;
-+extern ulint inno_pending_normal_aio_writes;
-+extern ulint inno_pending_ibuf_aio_reads;
-+extern ulint inno_pending_log_ios;
-+extern ulint inno_pending_sync_ios;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-diff -r 322370200e6a innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:08:52 2008 -0800
-@@ -1537,6 +1537,30 @@
-
- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
- LOG_WRITE_FROM_BACKGROUND_SYNC);
-+}
-+
-+/********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*==========================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
- }
-
- /********************************************************************
-diff -r 322370200e6a innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/os/os0file.c Mon Nov 03 05:08:52 2008 -0800
-@@ -22,6 +22,8 @@
- #include <errno.h>
- #endif /* UNIV_HOTBACKUP */
-
-+extern long innobase_max_merged_io;
-+
- #undef HAVE_FDATASYNC
-
- #ifdef POSIX_ASYNC_IO
-@@ -63,6 +65,28 @@
- ibool os_aio_use_native_aio = FALSE;
-
- ibool os_aio_print_debug = FALSE;
-+
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-@@ -72,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -82,11 +108,6 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -116,9 +137,6 @@
- in this array */
- ulint n_slots; /* Total number of slots in the aio array.
- This must be divisible by n_threads. */
-- ulint n_segments;/* Number of segments in the aio array of
-- pending aio requests. A thread can wait
-- separately for any one of the segments. */
- ulint n_reserved;/* Number of reserved slots in the
- aio array outside the ibuf segment */
- os_aio_slot_t* slots; /* Pointer to the slots in the array */
-@@ -134,6 +152,17 @@
-
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-+
-+/* Number of threads for reading and writing. */
-+ulint os_aio_read_threads = 0;
-+ulint os_aio_write_threads = 0;
-+
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
-@@ -143,11 +172,39 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
-+/* Count pages read and written per thread */
-+static ulint os_aio_thread_io_reads[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_io_writes[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO operations done. One request can be for N pages. */
-+static ulint os_aio_thread_io_requests[SRV_MAX_N_IO_THREADS];
-+
-+/* usecs spent blocked on an IO request */
-+static double os_aio_thread_io_wait[SRV_MAX_N_IO_THREADS];
-+/* max usecs spent blocked on an IO request */
-+static double os_aio_thread_max_io_wait[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO global segments. An IO handler thread is created for each
-+global segment, except for the segment associated with os_aio_sync_array.
-+Several segments can be associated with os_aio_{read,write}_array. One
-+segment is created for each of the other arrays. This is also the number
-+of valid entries in srv_io_thread_reads, srv_io_thread_writes,
-+srv_io_thread_op_info, srv_io_thread_function and os_aio_segment_wait_events. */
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
--/* If the following is TRUE, read i/o handler threads try to
--wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+/* Set to TRUE to temporarily block reads from being scheduled while a batch
-+of read requests is added to allow them to be merged by the IO handler thread
-+if they are adjacent. Declared volatile because we don't want this to be
-+read from a register in a loop when another thread may change the value in
-+memory.
-+*/
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -166,6 +223,19 @@
- ulint os_file_n_pending_pwrites = 0;
- ulint os_n_pending_writes = 0;
- ulint os_n_pending_reads = 0;
-+
-+/* TODO -- does InnoDB provide a portable method for this? */
-+static double time_usecs() {
-+#ifdef __WIN__
-+ return 0.0;
-+#else
-+ struct timeval tv;
-+ if (gettimeofday(&tv, NULL))
-+ return 0;
-+ else
-+ return tv.tv_sec * 1000000.0 + tv.tv_usec;
-+#endif
-+}
-
- /***************************************************************************
- Gets the operating system version. Currently works only on Windows. */
-@@ -1351,6 +1421,8 @@
- /* We disable OS caching (O_DIRECT) only on data files */
- if (type != OS_LOG_FILE
- && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
-+
-+ fprintf(stderr, "Using O_DIRECT for file %s\n", name);
-
- os_file_set_nocache(file, name, mode_str);
- }
-@@ -1798,6 +1870,32 @@
- #endif /* __WIN__ */
- }
-
-+#ifndef __WIN__
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fsync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fsync(file);
-+}
-+
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fdatasync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fdatasync(file);
-+}
-+#endif
-+
- /***************************************************************************
- Flushes the write buffers of a given file to the disk. */
-
-@@ -1855,21 +1953,21 @@
- /* If we are not on an operating system that supports this,
- then fall back to a plain fsync. */
-
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- } else {
- ret = fcntl(file, F_FULLFSYNC, NULL);
-
- if (ret) {
- /* If we are not on a file system that supports this,
- then fall back to a plain fsync. */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- }
- }
- #elif HAVE_FDATASYNC
-- ret = fdatasync(file);
-+ ret = os_maybe_fdatasync(file);
- #else
- /* fprintf(stderr, "Flushing to file %p\n", file); */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- #endif
- os_n_fsyncs++;
-
-@@ -2298,6 +2396,9 @@
-
- return(TRUE);
- }
-+ fprintf(stderr,
-+"InnoDB: error: os_file_pread wanted %lu and got %lu.\n",
-+ (ulint) n, (ulint) ret);
- #endif
- #ifdef __WIN__
- error_handling:
-@@ -2784,9 +2885,8 @@
- os_aio_array_create(
- /*================*/
- /* out, own: aio array */
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments) /* in: number of segments in the aio array */
-+ ulint n) /* in: maximum number of pending aio operations
-+ allowed */
- {
- os_aio_array_t* array;
- ulint i;
-@@ -2795,7 +2895,6 @@
- OVERLAPPED* over;
- #endif
- ut_a(n > 0);
-- ut_a(n_segments > 0);
-
- array = ut_malloc(sizeof(os_aio_array_t));
-
-@@ -2806,7 +2905,6 @@
- os_event_set(array->is_empty);
-
- array->n_slots = n;
-- array->n_segments = n_segments;
- array->n_reserved = 0;
- array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
- #ifdef __WIN__
-@@ -2833,70 +2931,75 @@
-
- /****************************************************************************
- Initializes the asynchronous io system. Calls also os_io_init_simple.
--Creates a separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
--
--void
-+Creates an aio array for each of non-ibuf read, non-ibuf write, ibuf IO,
-+log IO, and synchronous IO. The caller must create i/o handler thread for all
-+but the synchronous aio array. Multiple threads can access the same array for
-+the non-ibuf read (prefetch) and write (flush dirty buffer pages) arrays.
-+Return the number of AIO handler threads. */
-+
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
-- ulint n_read_segs;
-- ulint n_write_segs;
-- ulint n_per_seg;
-- ulint i;
-+ ulint i;
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-- ut_ad(n % n_segments == 0);
-- ut_ad(n_segments >= 4);
-+ ut_a(ios_per_array >= OS_AIO_N_PENDING_IOS_PER_THREAD);
-+ ut_a(n_read_threads >= 1 && n_read_threads <= 64);
-+ ut_a(n_write_threads >= 1 && n_write_threads <= 64);
-+ ut_a(n_segments < SRV_MAX_N_IO_THREADS);
-
- os_io_init_simple();
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-- }
--
-- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
--
-- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
--
-- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_thread_io_reads[i] = 0;
-+ os_aio_thread_io_writes[i] = 0;
-+ os_aio_thread_io_requests[i] = 0;
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
-+ os_aio_thread_io_wait[i] = 0;
-+ os_aio_thread_max_io_wait[i] = 0;
-+ }
-+
-+ os_aio_read_threads = n_read_threads;
-+ os_aio_write_threads = n_write_threads;
-+ os_aio_first_write_segment = os_aio_first_read_segment + os_aio_read_threads;
-+
-+ fprintf(stderr,
-+ "InnoDB: ios_per_array %lu read threads %lu write threads %lu\n",
-+ ios_per_array, os_aio_read_threads, os_aio_write_threads);
-+
-+ os_aio_ibuf_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[0] = "insert buffer thread";
-
-- os_aio_log_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_log_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-- n_read_segs);
-- for (i = 2; i < 2 + n_read_segs; i++) {
-+ os_aio_read_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_read_segment; i < os_aio_first_write_segment; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "read thread";
-- }
--
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-- n_write_segs);
-- for (i = 2 + n_read_segs; i < n_segments; i++) {
-+ srv_io_thread_function[i] = "read thread";
-+ }
-+
-+ os_aio_write_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_write_segment; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "write thread";
-- }
--
-- os_aio_sync_array = os_aio_array_create(n_slots_sync, 1);
--
-- os_aio_n_segments = n_segments;
-+ srv_io_thread_function[i] = "write thread";
-+ }
-+
-+ os_aio_sync_array = os_aio_array_create(n_slots_sync);
-+
-+ os_aio_n_segments = 2 + os_aio_read_threads + os_aio_write_threads;
-
- os_aio_validate();
-
-@@ -2924,6 +3027,7 @@
-
- pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
- #endif
-+ return os_aio_n_segments;
- }
-
- #ifdef WIN_ASYNC_IO
-@@ -2981,77 +3085,32 @@
- os_event_wait(os_aio_write_array->is_empty);
- }
-
--/**************************************************************************
--Calculates segment number for a slot. */
--static
--ulint
--os_aio_get_segment_no_from_slot(
--/*============================*/
-- /* out: segment number (which is the number
-- used by, for example, i/o-handler threads) */
-- os_aio_array_t* array, /* in: aio wait array */
-- os_aio_slot_t* slot) /* in: slot in this array */
--{
-- ulint segment;
-- ulint seg_len;
--
-- if (array == os_aio_ibuf_array) {
-- segment = 0;
--
-- } else if (array == os_aio_log_array) {
-- segment = 1;
--
-- } else if (array == os_aio_read_array) {
-- seg_len = os_aio_read_array->n_slots /
-- os_aio_read_array->n_segments;
--
-- segment = 2 + slot->pos / seg_len;
-- } else {
-- ut_a(array == os_aio_write_array);
-- seg_len = os_aio_write_array->n_slots /
-- os_aio_write_array->n_segments;
--
-- segment = os_aio_read_array->n_segments + 2
-- + slot->pos / seg_len;
-- }
--
-- return(segment);
--}
--
--/**************************************************************************
--Calculates local segment number and aio array from global segment number. */
--static
--ulint
--os_aio_get_array_and_local_segment(
-+
-+/**************************************************************************
-+Calculates aio array from global segment number. */
-+static
-+os_aio_array_t*
-+os_aio_get_array(
- /*===============================*/
-- /* out: local segment number within
-- the aio array */
-- os_aio_array_t** array, /* out: aio wait array */
-+ /* out: aio wait array */
- ulint global_segment)/* in: global segment number */
- {
-- ulint segment;
-
- ut_a(global_segment < os_aio_n_segments);
-
- if (global_segment == 0) {
-- *array = os_aio_ibuf_array;
-- segment = 0;
-+ return os_aio_ibuf_array;
-
- } else if (global_segment == 1) {
-- *array = os_aio_log_array;
-- segment = 0;
--
-- } else if (global_segment < os_aio_read_array->n_segments + 2) {
-- *array = os_aio_read_array;
--
-- segment = global_segment - 2;
-- } else {
-- *array = os_aio_write_array;
--
-- segment = global_segment - (os_aio_read_array->n_segments + 2);
-- }
--
-- return(segment);
-+ return os_aio_log_array;
-+
-+ } else if (global_segment < os_aio_first_write_segment) {
-+ return os_aio_read_array;
-+
-+ } else {
-+ return os_aio_write_array;
-+
-+ }
- }
-
- /***********************************************************************
-@@ -3160,7 +3219,7 @@
-
- os_aio_simulated_wake_handler_threads();
- }
--
-+
- os_event_wait(array->not_full);
-
- goto loop;
-@@ -3173,7 +3232,7 @@
- break;
- }
- }
--
-+ ut_a(i < array->n_slots);
- array->n_reserved++;
-
- if (array->n_reserved == 1) {
-@@ -3195,7 +3254,7 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3246,8 +3305,9 @@
- os_mutex_enter(array->mutex);
-
- ut_ad(slot->reserved);
--
-+
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3266,36 +3326,40 @@
- }
-
- /**************************************************************************
--Wakes up a simulated aio i/o-handler thread if it has something to do. */
-+Wake up the simulated aio i/o-handler threads for a given array if there
-+is work to do. */
- static
- void
- os_aio_simulated_wake_handler_thread(
- /*=================================*/
-- ulint global_segment) /* in: the number of the segment in the aio
-- arrays */
--{
-- os_aio_array_t* array;
-- os_aio_slot_t* slot;
-- ulint segment;
-+ os_aio_array_t* array) /* in: aio array for which wakeup is done */
-+{
-+ os_aio_slot_t* slot;
- ulint n;
- ulint i;
-
- ut_ad(!os_aio_use_native_aio);
-
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
--
-- os_mutex_enter(array->mutex);
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- /* Found an i/o request */
--
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-+
-+ os_mutex_enter(array->mutex);
-+
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i );
-+
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
-+ /* Found an i/o request
-+ /* OS_AIO_NOT_ISSUED means the read or write request has
-+ * yet to be done. OS_AIO_DONE means the request has been
-+ * done but it was part of a set of requests merged into
-+ * one read or write call and was not the first block in
-+ * the request, so the handling of the IO completion for
-+ * that block has not been done. */
-+
- break;
- }
- }
-@@ -3303,7 +3367,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3320,13 +3402,14 @@
- /* We do not use simulated aio: do nothing */
-
- return;
-- }
--
-- os_aio_recommend_sleep_for_read_threads = FALSE;
--
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ }
-+
-+ os_aio_recommend_sleep_for_read_threads = FALSE;
-+
-+ os_aio_simulated_wake_handler_thread(os_aio_ibuf_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_log_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_read_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_write_array);
- }
-
- /**************************************************************************
-@@ -3339,18 +3422,13 @@
- os_aio_simulated_put_read_threads_to_sleep(void)
- /*============================================*/
- {
-- os_aio_array_t* array;
- ulint g;
-
-+ /* TODO(mcallaghan): provide similar function for write? */
- os_aio_recommend_sleep_for_read_threads = TRUE;
-
-- for (g = 0; g < os_aio_n_segments; g++) {
-- os_aio_get_array_and_local_segment(&array, g);
--
-- if (array == os_aio_read_array) {
--
-- os_event_reset(os_aio_segment_wait_events[g]);
-- }
-+ for (g = os_aio_first_read_segment; g < os_aio_first_write_segment; g++) {
-+ os_event_reset(os_aio_segment_wait_events[g]);
- }
- }
-
-@@ -3480,8 +3558,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else if (type == OS_FILE_WRITE) {
-@@ -3497,8 +3574,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else {
-@@ -3561,7 +3637,7 @@
- os_aio_windows_handle(
- /*==================*/
- /* out: TRUE if the aio operation succeeded */
-- ulint segment, /* in: the number of the segment in the aio
-+ ulint global_segment, /* in: the number of the segment in the aio
- arrays to wait for; segment 0 is the ibuf
- i/o thread, segment 1 the log i/o thread,
- then follow the non-ibuf read threads, and as
-@@ -3579,7 +3655,6 @@
- void** message2,
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
-- ulint orig_seg = segment;
- os_aio_array_t* array;
- os_aio_slot_t* slot;
- ulint n;
-@@ -3588,33 +3663,30 @@
- BOOL ret;
- DWORD len;
-
-- if (segment == ULINT_UNDEFINED) {
-+ if (global_segment == ULINT_UNDEFINED) {
- array = os_aio_sync_array;
-- segment = 0;
-- } else {
-- segment = os_aio_get_array_and_local_segment(&array, segment);
-+ } else {
-+ array = os_aio_get_array(global_segment);
- }
-
- /* NOTE! We only access constant fields in os_aio_array. Therefore
- we do not have to acquire the protecting mutex yet */
-
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
-+
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
- i = pos;
- } else {
-- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
-- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-- }
--
-- os_mutex_enter(array->mutex);
--
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ srv_set_io_thread_op_info(global_segment, "wait Windows aio");
-+ i = os_event_wait_multiple(n, (array->native_events));
-+ }
-+
-+ os_mutex_enter(array->mutex);
-+
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3787,14 +3859,16 @@
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
- os_aio_array_t* array;
-- ulint segment;
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3802,8 +3876,10 @@
- ibool ret;
- ulint n;
- ulint i;
--
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-+
-+ double start_usecs, stop_usecs, elapsed_usecs;
-+ time_t now;
-+ array = os_aio_get_array(global_segment);
-
- restart:
- /* NOTE! We only access constant fields in os_aio_array. Therefore
-@@ -3812,11 +3888,10 @@
- srv_set_io_thread_op_info(global_segment,
- "looking for i/o requests (a)");
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
-+
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-
- if (array == os_aio_read_array
- && os_aio_recommend_sleep_for_read_threads) {
-@@ -3836,9 +3911,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved && slot->io_already_done) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3846,79 +3921,66 @@
- }
-
- ret = TRUE;
--
-+
- goto slot_io_done;
- }
- }
-
-- n_consecutive = 0;
--
-- /* If there are at least 2 seconds old requests, then pick the oldest
-- one to prevent starvation. If several requests have the same age,
-- then pick the one at the lowest offset. */
--
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
--
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-+
-+ /* Find the oldest request and the request with the smallest offset */
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-+
-+ /* If there are at least 2 seconds old requests, then pick the oldest
-+ one to prevent starvation. If several requests have the same age,
-+ then pick the one at the lowest offset. */
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
-+ }
-+
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
-+ /* Found an i/o request */
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
--
-- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-- lowest_offset = slot->offset;
-- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3926,7 +3988,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3935,7 +3998,8 @@
-
- slot = slot2;
-
-- if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE) {
-+ if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE
-+ && n_consecutive < innobase_max_merged_io) {
-
- goto consecutive_loop;
- } else {
-@@ -3955,6 +4019,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -3962,7 +4028,16 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -3973,6 +4048,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -3998,6 +4076,7 @@
-
- /* Do the i/o with ordinary, synchronous i/o functions: */
- if (slot->type == OS_FILE_WRITE) {
-+ os_aio_thread_io_writes[global_segment] += n_consecutive;
- if (array == os_aio_write_array) {
- if ((total_len % UNIV_PAGE_SIZE != 0)
- || (slot->offset % UNIV_PAGE_SIZE != 0)) {
-@@ -4012,16 +4091,34 @@
- os_file_check_page_trailers(combined_buf, total_len);
- }
-
-+ start_usecs = time_usecs();
- ret = os_file_write(slot->name, slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
--
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
- if (array == os_aio_write_array) {
- os_file_check_page_trailers(combined_buf, total_len);
- }
-- } else {
-+ os_aio_write_requests++;
-+ os_aio_pages_written += n_consecutive;
-+ os_aio_write_time += (ib_longlong)elapsed_usecs;
-+ } else {
-+ start_usecs = time_usecs();
-+ os_aio_thread_io_reads[global_segment] += n_consecutive;
- ret = os_file_read(slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
-- }
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
-+ os_aio_read_requests++;
-+ os_aio_pages_read += n_consecutive;
-+ os_aio_read_time += (ib_longlong)elapsed_usecs;
-+ }
-+ if (elapsed_usecs > os_aio_thread_max_io_wait[global_segment])
-+ os_aio_thread_max_io_wait[global_segment] = elapsed_usecs;
-+ os_aio_thread_io_wait[global_segment] += elapsed_usecs;
-+ os_aio_thread_io_requests[global_segment]++;
-
- ut_a(ret);
- srv_set_io_thread_op_info(global_segment, "file i/o done");
-@@ -4042,16 +4139,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4061,6 +4155,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-@@ -4070,7 +4166,8 @@
- os_mutex_exit(array->mutex);
-
- os_aio_array_free_slot(array, slot);
--
-+ srv_set_io_thread_op_info(global_segment, "exited handler");
-+
- return(ret);
-
- wait_for_io:
-@@ -4115,7 +4212,6 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-@@ -4165,11 +4261,20 @@
- double time_elapsed;
- double avg_bytes_read;
- ulint i;
--
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-- fprintf(file, "I/O thread %lu state: %s (%s)", (ulong) i,
-- srv_io_thread_op_info[i],
-- srv_io_thread_function[i]);
-+ ulint num_issued, num_done, num_claimed;
-+
-+ if (file) {
-+ for (i = 0; i < os_aio_n_segments; i++) {
-+ fprintf(file,
-+ "I/O thread %lu state: %s (%s) reads %lu writes %lu "
-+ "requests %lu io secs %lf io msecs/request %lf max_io_wait %lf",
-+ i, srv_io_thread_op_info[i], srv_io_thread_function[i],
-+ os_aio_thread_io_reads[i], os_aio_thread_io_writes[i],
-+ os_aio_thread_io_requests[i],
-+ os_aio_thread_io_wait[i] / 1000000.0,
-+ os_aio_thread_io_requests[i] ?
-+ os_aio_thread_io_wait[i] / os_aio_thread_io_requests[i] / 1000.0 : 0.0,
-+ os_aio_thread_max_io_wait[i] / 1000.0);
-
- #ifndef __WIN__
- if (os_aio_segment_wait_events[i]->is_set) {
-@@ -4181,6 +4286,7 @@
- }
-
- fputs("Pending normal aio reads:", file);
-+ } // if (file)
-
- array = os_aio_read_array;
- loop:
-@@ -4189,14 +4295,23 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- n_reserved = 0;
-+ num_done = num_issued = num_claimed = 0;
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
- if (slot->reserved) {
-+ if (slot->status == OS_AIO_ISSUED)
-+ num_issued++;
-+ else if (slot->status == OS_AIO_DONE)
-+ num_done++;
-+ else {
-+ ut_ad(slot->status == OS_AIO_CLAIMED);
-+ num_claimed++;
-+ }
-+
- n_reserved++;
- /* fprintf(stderr, "Reserved slot, messages %p %p\n",
- slot->message1, slot->message2); */
-@@ -4206,42 +4321,56 @@
-
- ut_a(array->n_reserved == n_reserved);
-
-- fprintf(file, " %lu", (ulong) n_reserved);
--
-+ if (file) fprintf(file, " %lu", (ulong) n_reserved);
-+
- os_mutex_exit(array->mutex);
-
- if (array == os_aio_read_array) {
-- fputs(", aio writes:", file);
--
-+ inno_pending_normal_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", aio writes:", file);
- array = os_aio_write_array;
-
- goto loop;
- }
-
- if (array == os_aio_write_array) {
-- fputs(",\n ibuf aio reads:", file);
-+ inno_pending_normal_aio_writes = (ulong) n_reserved;
-+ if (file) fputs(",\n ibuf aio reads:", file);
- array = os_aio_ibuf_array;
-
- goto loop;
- }
-
- if (array == os_aio_ibuf_array) {
-- fputs(", log i/o's:", file);
-+ inno_pending_ibuf_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", log i/o's:", file);
- array = os_aio_log_array;
-
- goto loop;
- }
-
- if (array == os_aio_log_array) {
-- fputs(", sync i/o's:", file);
-+ inno_pending_log_ios = (ulong) n_reserved;
-+ if (file) fputs(", sync i/o's:", file);
- array = os_aio_sync_array;
-
- goto loop;
- }
-
-- putc('\n', file);
-+ if (array == os_aio_sync_array) {
-+ inno_pending_sync_ios = (ulong) n_reserved;
-+ }
-+
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time, os_last_printout);
-+
-+ if (file) {
-+ putc('\n', file);
-+ fprintf(file,
-+ "Summary of background IO slot status: %lu issued, "
-+ "%lu done, %lu claimed, sleep set %d\n",
-+ num_issued, num_done, num_claimed,
-+ os_aio_recommend_sleep_for_read_threads);
-
- fprintf(file,
- "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
-@@ -4274,6 +4403,7 @@
- / time_elapsed,
- (os_n_fsyncs - os_n_fsyncs_old)
- / time_elapsed);
-+ } // if (file)
-
- os_n_file_reads_old = os_n_file_reads;
- os_n_file_writes_old = os_n_file_writes;
-diff -r 322370200e6a innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-@@ -164,7 +164,17 @@
- ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
- ulint srv_lock_table_size = ULINT_MAX;
-
-+ulint srv_io_capacity = ULINT_MAX; /* Number of IO operations per
-+ second the server can do */
-+
-+ibool srv_extra_dirty_writes = TRUE; /* Write dirty pages to disk when pct
-+ dirty < max dirty pct */
-+
-+/* Deprecated by srv_n_{read,write}_io_threads */
- ulint srv_n_file_io_threads = ULINT_MAX;
-+/* Number of background IO threads for read and write requests */
-+ulint srv_n_read_io_threads = ULINT_MAX;
-+ulint srv_n_write_io_threads = ULINT_MAX;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -238,6 +248,24 @@
-
- /* variable to count the number of random read-aheads */
- ulint srv_read_ahead_rnd = 0;
-+
-+/* Number of IO operations read/write done for all threads */
-+ulint os_aio_read_requests = 0;
-+ulint os_aio_write_requests = 0;
-+
-+/* Number of pages read/written done for all threads */
-+ulint os_aio_pages_read = 0;
-+ulint os_aio_pages_written = 0;
-+
-+/* time usec used to perform read/write for all threads */
-+ib_longlong os_aio_read_time = 0;
-+ib_longlong os_aio_write_time = 0;
-+
-+ulint inno_pending_normal_aio_reads = 0;
-+ulint inno_pending_normal_aio_writes = 0;
-+ulint inno_pending_ibuf_aio_reads = 0;
-+ulint inno_pending_log_ios = 0;
-+ulint inno_pending_sync_ios = 0;
-
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-@@ -413,6 +441,23 @@
-
- ulint srv_main_thread_process_no = 0;
- ulint srv_main_thread_id = 0;
-+
-+// The following count work done by srv_master_thread.
-+
-+// Iterations by the 'once per second' loop.
-+ulint srv_main_1_second_loops = 0;
-+// Calls to sleep by the 'once per second' loop.
-+ulint srv_main_sleeps = 0;
-+// Iterations by the 'once per 10 seconds' loop.
-+ulint srv_main_10_second_loops = 0;
-+// Iterations of the loop bounded by the 'background_loop' label.
-+ulint srv_main_background_loops = 0;
-+// Iterations of the loop bounded by the 'flush_loop' label.
-+ulint srv_main_flush_loops = 0;
-+// Calls to log_buffer_flush_to_disk.
-+ulint srv_sync_flush = 0;
-+// Calls to log_buffer_flush_maybe_sync.
-+ulint srv_async_flush = 0;
-
- /*
- IMPLEMENTATION OF THE SERVER MAIN PROGRAM
-@@ -2170,7 +2215,12 @@
- }
-
- /*************************************************************************
--The master thread controlling the server. */
-+Returns the number of IO operations that is X percent of the capacity.
-+
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity.
-+*/
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-
- #ifndef __WIN__
- void*
-@@ -2199,11 +2249,15 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
- #endif
-+ fprintf(stderr, "InnoDB master thread running with io_capacity %lu\n",
-+ srv_io_capacity);
-+
- srv_main_thread_process_no = os_proc_get_number();
- srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
-
-@@ -2275,26 +2329,28 @@
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-+ srv_sync_flush++;
-
- srv_main_thread_op_info = "making checkpoint";
- log_free_check();
-
-- /* If there were less than 5 i/os during the
-- one second sleep, we assume that there is free
-- disk i/o capacity available, and it makes sense to
-- do an insert buffer merge. */
-+ /* If i/os during one second sleep were less than 5% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to do an insert buffer merge. */
-
- n_pend_ios = buf_get_n_pending_ios()
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2303,7 +2359,8 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2325,36 +2382,47 @@
-
- /* ---- We perform the following code approximately once per
- 10 seconds when there is database activity */
-+ srv_main_10_second_loops++;
-
- #ifdef MEM_PERIODIC_CHECK
- /* Check magic numbers of every allocated mem block once in 10
- seconds */
- mem_validate_all_blocks();
- #endif
-- /* If there were less than 200 i/os during the 10 second period,
-- we assume that there is free disk i/o capacity available, and it
-- makes sense to flush 100 pages. */
-+ /* If i/os during the 10 second period were less than 200% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to flush srv_io_capacity pages.
-+
-+ Note that this is done regardless of the fraction of dirty
-+ pages relative to the max requested by the user. The one second
-+ loop above requests writes for that case. The writes done here
-+ are not required, and may be disabled. */
-
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (srv_extra_dirty_writes &&
-+ n_pend_ios < PCT_IO(3) && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2378,8 +2446,9 @@
- if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2393,14 +2462,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2434,7 +2503,7 @@
-
- /* The server has been quiet for a while: start running background
- operations */
--
-+ srv_main_background_loops++;
- srv_main_thread_op_info = "doing background drop tables";
-
- n_tables_to_drop = row_drop_tables_for_mysql_in_background();
-@@ -2472,6 +2541,7 @@
-
- log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2487,9 +2557,13 @@
- srv_main_thread_op_info = "doing insert buffer merge";
-
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
-- n_bytes_merged = 0;
-+ n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ /* This should do an amount of IO similar to the number of
-+ * dirty pages that will be flushed in the call to
-+ * buf_flush_batch below. Otherwise, the system favors
-+ * clean pages over cleanup throughput. */
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2503,10 +2577,11 @@
-
- flush_loop:
- srv_main_thread_op_info = "flushing buffer pool pages";
-+ srv_main_flush_loops++;
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2528,7 +2603,17 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ srv_main_thread_op_info = (char*) "flushing log";
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ srv_sync_flush++;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -r 322370200e6a innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0start.c Mon Nov 03 05:08:52 2008 -0800
-@@ -973,6 +973,7 @@
- ulint i;
- ibool srv_file_per_table_original_value = srv_file_per_table;
- mtr_t mtr;
-+ ulint n_threads;
- #ifdef HAVE_DARWIN_THREADS
- # ifdef F_FULLFSYNC
- /* This executable has been compiled on Mac OS X 10.3 or later.
-@@ -1206,24 +1207,32 @@
- }
-
- /* Restrict the maximum number of file i/o threads */
-- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
--
-- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ if ((srv_n_read_io_threads + srv_n_write_io_threads) > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many read(%d) or write(%d) IO threads, max is %d\n",
-+ srv_n_read_io_threads, srv_n_write_io_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- if (!os_aio_use_native_aio) {
-- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /* More than 4 threads are now supported. */
-+ n_threads = os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ } else {
-+ /* Might need more slots here. Alas, I don't do windows. */
-+ n_threads = os_aio_init(SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ }
-
-- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-- } else {
-- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ if (n_threads > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many IO threads(%d), max is %d\n",
-+ n_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- fil_init(srv_max_n_open_files);
-@@ -1259,11 +1268,11 @@
-
- /* Create i/o-handler threads: */
-
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-+ for (i = 0; i < n_threads; i++) {
- n[i] = i;
-
- os_thread_create(io_handler_thread, n + i, thread_ids + i);
-- }
-+ }
-
- #ifdef UNIV_LOG_ARCHIVE
- if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
-diff -r 322370200e6a patch_info/innodb_io_tune.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_tune.info Mon Nov 03 05:08:52 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_io_tune.patch
-+Name=Tune InnoDB IO settings
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
-diff -r 322370200e6a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -147,7 +147,7 @@
- innobase_additional_mem_pool_size, innobase_file_io_threads,
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
--
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -175,6 +175,23 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+
-+/* Max number of IO requests merged to perform large IO in background
-+ IO threads.
-+*/
-+long innobase_max_merged_io = 64;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+long innobase_min_status_update_time_interval = 30;
-+
-+
-+/* Default number of IO per second supported by server. Tunes background
-+ IO rate
-+*/
-+long innobase_io_capacity = 100;
-+
-+/* Write dirty pages when pct dirty is less than max pct dirty */
-+my_bool innobase_extra_dirty_writes = TRUE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1372,7 +1389,11 @@
-
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
-+ srv_io_capacity = (ulint) innobase_io_capacity;
-+ srv_extra_dirty_writes = (ibool) innobase_extra_dirty_writes;
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -r 322370200e6a sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-@@ -197,6 +197,7 @@
-
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
-+extern long innobase_max_merged_io;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -205,10 +206,14 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_force_recovery;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
- extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
- extern char *innobase_unix_file_flush_method;
-+extern long innobase_io_capacity;
-+extern my_bool innobase_extra_dirty_writes;
-+
- /* The following variables have to be my_bool for SHOW VARIABLES to work */
- extern my_bool innobase_log_archive,
- innobase_use_doublewrite,
-diff -r 322370200e6a sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -4932,6 +4932,11 @@
- OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_MAX_MERGED_IO,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_EXTRA_DIRTY_WRITES,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
-@@ -5302,6 +5307,25 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_max_merged_io", OPT_INNODB_MAX_MERGED_IO,
-+ "Max number of IO requests merged to issue large IO from background IO threads.",
-+ (gptr*) &innobase_max_merged_io,
-+ (gptr*) &innobase_max_merged_io, 0, GET_LONG, REQUIRED_ARG, 64, 1, 64, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.", (gptr*) &innobase_read_io_threads,
-+ (gptr*) &innobase_read_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.", (gptr*) &innobase_write_io_threads,
-+ (gptr*) &innobase_write_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &innobase_io_capacity,
-+ (gptr*) &innobase_io_capacity, 0, GET_LONG,
-+ REQUIRED_ARG, 100, 100, 999999999, 0, 1, 0},
-+ {"innodb_extra_dirty_writes", OPT_INNODB_EXTRA_DIRTY_WRITES,
-+ "When set, flush dirty buffer pages when dirty pct is less than max dirty pct. ",
-+ (gptr*) &innobase_extra_dirty_writes, (gptr*) &innobase_extra_dirty_writes,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 322370200e6a sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -919,12 +919,14 @@
- {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
- {"innodb_adaptive_hash_index", (char*) &innobase_adaptive_hash_index, SHOW_MY_BOOL},
- {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
-+ {"innodb_extra_dirty_writes", (char*) &innobase_extra_dirty_writes, SHOW_MY_BOOL},
- {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
-+ {"innodb_io_capacity", (char*) &innobase_io_capacity, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
- {"innodb_locks_unsafe_for_binlog", (char*) &innobase_locks_unsafe_for_binlog, SHOW_MY_BOOL},
- {"innodb_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
-@@ -943,6 +945,9 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
-+ {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090706/innodb_locks_held.patch b/percona/5.0.83-b17-20090706/innodb_locks_held.patch
deleted file mode 100644
index 65ac766..0000000
--- a/percona/5.0.83-b17-20090706/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1711,24 +1713,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1822,6 +1806,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r e9fb5b8bcf78 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -825,6 +825,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -942,6 +944,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r e9fb5b8bcf78 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
-@@ -243,6 +243,8 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern ulong srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-diff -r e9fb5b8bcf78 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -5016,6 +5016,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5364,6 +5366,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r e9fb5b8bcf78 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -527,6 +527,12 @@
- &srv_enable_unsafe_group_commit);
- sys_var_long_ptr sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -906,6 +912,8 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1023,6 +1031,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.83-b17-20090706/innodb_rw_lock.patch b/percona/5.0.83-b17-20090706/innodb_rw_lock.patch
deleted file mode 100644
index e45fccd..0000000
--- a/percona/5.0.83-b17-20090706/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.83-b17-20090706/innodb_show_bp.patch b/percona/5.0.83-b17-20090706/innodb_show_bp.patch
deleted file mode 100644
index a56ae9a..0000000
--- a/percona/5.0.83-b17-20090706/innodb_show_bp.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,13 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.83-b17-20090706/innodb_show_hashed_memory.patch b/percona/5.0.83-b17-20090706/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.83-b17-20090706/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.83-b17-20090706/innodb_show_hashed_memory_standalone.patch b/percona/5.0.83-b17-20090706/innodb_show_hashed_memory_standalone.patch
deleted file mode 100644
index bf8f6b4..0000000
--- a/percona/5.0.83-b17-20090706/innodb_show_hashed_memory_standalone.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,80 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes());
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.83-b17-20090706/innodb_thread_concurrency_timer_based.patch b/percona/5.0.83-b17-20090706/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 5e26818..0000000
--- a/percona/5.0.83-b17-20090706/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090706/microsec_process.patch b/percona/5.0.83-b17-20090706/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.83-b17-20090706/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.83-b17-20090706/microslow_innodb.patch b/percona/5.0.83-b17-20090706/microslow_innodb.patch
deleted file mode 100644
index e28f091..0000000
--- a/percona/5.0.83-b17-20090706/microslow_innodb.patch
+++ /dev/null
@@ -1,2493 +0,0 @@
-diff -r 069dc6d4f269 include/my_getopt.h
---- a/include/my_getopt.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/include/my_getopt.h Mon Jun 01 00:35:30 2009 -0700
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 069dc6d4f269 include/my_time.h
---- a/include/my_time.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/include/my_time.h Mon Jun 01 00:35:30 2009 -0700
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 069dc6d4f269 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/buf/buf0buf.c Mon Jun 01 00:35:30 2009 -0700
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1090,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1142,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1158,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1190,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1303,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1276,6 +1323,12 @@
- break;
- }
- }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
- }
-
- fix_type = MTR_MEMO_BUF_FIX;
-@@ -1296,12 +1349,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1384,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,7 +1499,7 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
-@@ -1448,6 +1507,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-@@ -1470,6 +1534,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1559,6 +1624,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-diff -r 069dc6d4f269 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/buf/buf0rea.c Mon Jun 01 00:35:30 2009 -0700
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 069dc6d4f269 innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/fil/fil0fil.c Mon Jun 01 00:35:30 2009 -0700
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 069dc6d4f269 innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/buf0rea.h Mon Jun 01 00:35:30 2009 -0700
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 069dc6d4f269 innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/fil0fil.h Mon Jun 01 00:35:30 2009 -0700
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 069dc6d4f269 innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/os0file.h Mon Jun 01 00:35:30 2009 -0700
-@@ -11,6 +11,8 @@
-
- #include "univ.i"
-
-+#include "trx0types.h"
-+
- #ifndef __WIN__
- #include <dirent.h>
- #include <sys/stat.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 069dc6d4f269 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:35:30 2009 -0700
-@@ -27,6 +27,8 @@
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-
-+extern ibool srv_slow_log;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-
-diff -r 069dc6d4f269 innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/trx0trx.h Mon Jun 01 00:35:30 2009 -0700
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 069dc6d4f269 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:35:30 2009 -0700
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 069dc6d4f269 innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/os/os0file.c Mon Jun 01 00:35:30 2009 -0700
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1905,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1919,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1948,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1968,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1981,6 +2005,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(ret);
- }
- #endif
-@@ -2103,7 +2134,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2144,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2209,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3169,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3423,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3463,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3497,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 069dc6d4f269 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:35:30 2009 -0700
-@@ -48,6 +48,8 @@
- #include "srv0start.h"
- #include "row0mysql.h"
-
-+ibool srv_slow_log = 0;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
- ibool srv_lower_case_table_names = FALSE;
-@@ -1002,6 +1004,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1060,6 +1066,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1115,12 +1122,23 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_waiting_threads--;
-diff -r 069dc6d4f269 innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/trx/trx0trx.c Mon Jun 01 00:35:30 2009 -0700
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 069dc6d4f269 mysys/my_getopt.c
---- a/mysys/my_getopt.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/mysys/my_getopt.c Mon Jun 01 00:35:30 2009 -0700
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1061,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 069dc6d4f269 patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Mon Jun 01 00:35:30 2009 -0700
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 069dc6d4f269 scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Mon Jun 01 00:35:20 2009 -0700
-+++ b/scripts/mysqldumpslow.sh Mon Jun 01 00:35:30 2009 -0700
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 069dc6d4f269 sql-common/my_time.c
---- a/sql-common/my_time.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql-common/my_time.c Mon Jun 01 00:35:30 2009 -0700
-@@ -1253,3 +1253,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 069dc6d4f269 sql/filesort.cc
---- a/sql/filesort.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/filesort.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 069dc6d4f269 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/ha_innodb.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -819,9 +820,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1324,6 +1350,8 @@
-
- /* -------------- Log files ---------------------------*/
-
-+ srv_slow_log = (ibool) opt_slow_log;
-+
- /* The default dir for log files is the datadir of MySQL */
-
- if (!innobase_log_group_home_dir) {
-@@ -4694,6 +4722,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4959,6 +4993,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5046,6 +5086,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5112,6 +5158,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len1 = strlen(from);
- name_len2 = strlen(to);
-
-@@ -6119,6 +6171,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6242,7 +6295,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 069dc6d4f269 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:35:30 2009 -0700
-@@ -271,6 +271,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 069dc6d4f269 sql/log.cc
---- a/sql/log.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/log.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2289,11 +2289,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2303,7 +2304,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2333,22 +2335,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 069dc6d4f269 sql/log_event.cc
---- a/sql/log_event.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/log_event.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2057,6 +2057,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 069dc6d4f269 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/mysql_priv.h Mon Jun 01 00:35:30 2009 -0700
-@@ -507,6 +507,78 @@
-
- #define STRING_BUFFER_USUAL_SIZE 80
-
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-+
- enum enum_parsing_place
- {
- NO_MATTER,
-@@ -1365,6 +1437,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1376,7 +1449,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 069dc6d4f269 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -176,7 +176,6 @@
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
-
--
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
- #endif
-@@ -411,10 +410,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -509,6 +511,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -588,7 +591,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3697,6 +3700,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4947,7 +4952,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5038,11 +5043,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5441,10 +5453,19 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
- "Path to transaction coordinator log (used for transactions that affect "
- "more than one storage engine, when binary log is disabled)",
-@@ -5808,6 +5829,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6110,11 +6134,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6893,7 +6937,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7364,6 +7412,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7696,10 +7773,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 069dc6d4f269 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -697,6 +717,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -720,6 +744,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -773,6 +798,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -994,8 +1021,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1022,6 +1052,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1109,6 +1140,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1149,6 +1182,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1777,6 +1811,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1933,6 +1978,19 @@
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
- }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
-+ }
- case SHOW_HA_ROWS:
- {
- ha_rows value;
-@@ -2765,6 +2823,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3534,6 +3616,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 069dc6d4f269 sql/set_var.h
---- a/sql/set_var.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/set_var.h Mon Jun 01 00:35:30 2009 -0700
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -378,7 +384,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ulonglong :public sys_var_thd
- {
- public:
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -478,6 +496,66 @@
- };
-
-
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
- class sys_var_thd_storage_engine :public sys_var_thd
- {
- protected:
-@@ -1087,3 +1165,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 069dc6d4f269 sql/slave.cc
---- a/sql/slave.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/slave.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2975,6 +2975,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 069dc6d4f269 sql/sql_cache.cc
---- a/sql/sql_cache.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_cache.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1402,6 +1402,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1409,6 +1410,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 069dc6d4f269 sql/sql_class.cc
---- a/sql/sql_class.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_class.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -190,7 +190,7 @@
- table_map_for_update(0),
- global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2251,6 +2251,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2267,7 +2273,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2320,6 +2332,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 069dc6d4f269 sql/sql_class.h
---- a/sql/sql_class.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_class.h Mon Jun 01 00:35:30 2009 -0700
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1129,6 +1134,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1185,6 +1196,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1293,10 +1309,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1696,11 +1726,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 069dc6d4f269 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_parse.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,28 +2363,58 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-- thd->end_time(); // Set start time
-+ ulonglong start_of_query_timer= thd->start_timer;
-+ thd->end_time(); // Set start timea
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-+
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
-+
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((thd->start_time > thd->time_after_lock &&
-- (ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time) ||
-- (thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END)
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
-+
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2669,6 +2709,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6203,6 +6245,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 069dc6d4f269 sql/sql_select.cc
---- a/sql/sql_select.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_select.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -6262,8 +6262,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6278,8 +6281,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9340,6 +9346,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10200,6 +10207,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 069dc6d4f269 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_show.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1560,6 +1560,12 @@
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
-+ break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
- break;
-diff -r 069dc6d4f269 sql/structs.h
---- a/sql/structs.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/structs.h Mon Jun 01 00:35:30 2009 -0700
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.83-b17-20090706/mirror_binlog.patch b/percona/5.0.83-b17-20090706/mirror_binlog.patch
deleted file mode 100644
index d52e806..0000000
--- a/percona/5.0.83-b17-20090706/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5098,6 +5098,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
- };
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.83-b17-20090706/mysql-test.patch b/percona/5.0.83-b17-20090706/mysql-test.patch
deleted file mode 100644
index 7fce8e0..0000000
--- a/percona/5.0.83-b17-20090706/mysql-test.patch
+++ /dev/null
@@ -1,108 +0,0 @@
---- a/mysql-test/r/information_schema.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/information_schema.result 2009-05-07 19:32:59.000000000 +0000
-@@ -60,6 +60,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- columns_priv
- db
- func
-@@ -743,7 +744,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--109
-+110
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -819,7 +820,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 24
-+information_schema 25
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1228,6 +1229,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1267,6 +1269,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1342,6 +1345,7 @@
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
---- a/mysql-test/r/information_schema_db.result 2009-05-07 19:31:27.000000000 +0000
-+++ b/mysql-test/r/information_schema_db.result 2009-05-07 19:35:01.000000000 +0000
-@@ -29,6 +29,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
---- a/mysql-test/r/mysqlshow.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/mysqlshow.result 2009-05-07 19:36:32.000000000 +0000
-@@ -103,6 +103,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -132,6 +133,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
---- a/mysql-test/r/profiling.result 2009-05-28 19:39:42.000000000 +0000
-+++ b/mysql-test/r/profiling.result 2009-05-28 19:40:14.000000000 +0000
-@@ -6,6 +6,8 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 15
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 0
-@@ -16,12 +18,16 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 100
-+profiling_server OFF
-+profiling_use_getrusage OFF
- set session profiling = ON;
- set session profiling_history_size=30;
- show session variables like 'profil%';
- Variable_name Value
- profiling ON
- profiling_history_size 30
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 1
diff --git a/percona/5.0.83-b17-20090706/mysqld_safe_syslog.patch b/percona/5.0.83-b17-20090706/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.83-b17-20090706/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.83-b17-20090706/profiling_slow.patch b/percona/5.0.83-b17-20090706/profiling_slow.patch
deleted file mode 100644
index 703b8b7..0000000
--- a/percona/5.0.83-b17-20090706/profiling_slow.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-diff -r 92e70e675363 patch_info/profiling_slow.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/profiling_slow.info Mon Jun 01 00:50:00 2009 -0700
-@@ -0,0 +1,9 @@
-+File=profiling_slow.info
-+Name=profiling from SHOW PROFILE to slow.log
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2009-05-18
-+Initial implementation
-diff -r 92e70e675363 sql/log.cc
---- a/sql/log.cc Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/log.cc Mon Jun 01 00:50:00 2009 -0700
-@@ -2402,6 +2402,11 @@
- tmp_errno=errno;
- }
- }
-+
-+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
-+ thd->profiling.print_current(&log_file);
-+#endif
-+
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
- if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
-diff -r 92e70e675363 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:50:00 2009 -0700
-@@ -5052,6 +5052,8 @@
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_PROFILING_SERVER,
-+ OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
-@@ -5675,6 +5677,16 @@
- (gptr*) &global_system_variables.profiling_history_size,
- (gptr*) &max_system_variables.profiling_history_size,
- 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
-+ {"profiling_server", OPT_PROFILING_SERVER,
-+ "Enable profiling of all threads",
-+ (gptr*) &global_system_variables.profiling_server,
-+ (gptr*) &max_system_variables.profiling_server, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
-+ {"profiling_use_getrusage", OPT_PROFILING_USE_GETRUSAGE,
-+ "Enable getrusage function call for profiling",
-+ (gptr*) &global_system_variables.profiling_use_getrusage,
-+ (gptr*) &max_system_variables.profiling_use_getrusage, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
- #endif
- {"relay-log", OPT_RELAY_LOG,
- "The location and name to use for relay logs.",
-diff -r 92e70e675363 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:50:00 2009 -0700
-@@ -592,6 +592,10 @@
- ulonglong(OPTION_PROFILING));
- static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
- &SV::profiling_history_size);
-+static sys_var_thd_bool sys_profiling_server("profiling_server",
-+ &SV::profiling_server);
-+static sys_var_thd_bool sys_profiling_use_getrusage("profiling_use_getrusage",
-+ &SV::profiling_use_getrusage);
- #endif
-
- /* Local state variables */
-@@ -764,6 +768,8 @@
- #ifdef ENABLED_PROFILING
- &sys_profiling,
- &sys_profiling_history_size,
-+ &sys_profiling_server,
-+ &sys_profiling_use_getrusage,
- #endif
- &sys_pseudo_thread_id,
- &sys_query_alloc_block_size,
-@@ -1094,6 +1100,8 @@
- #ifdef ENABLED_PROFILING
- {sys_profiling.name, (char*) &sys_profiling, SHOW_SYS},
- {sys_profiling_history_size.name, (char*) &sys_profiling_history_size, SHOW_SYS},
-+ {sys_profiling_server.name, (char*) &sys_profiling_server, SHOW_SYS},
-+ {sys_profiling_use_getrusage.name, (char*) &sys_profiling_use_getrusage, SHOW_SYS},
- #endif
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
-diff -r 92e70e675363 sql/sql_class.h
---- a/sql/sql_class.h Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/sql_class.h Mon Jun 01 00:50:00 2009 -0700
-@@ -550,6 +550,8 @@
- ulong optimizer_search_depth;
- ulong preload_buff_size;
- ulong profiling_history_size;
-+ my_bool profiling_server;
-+ my_bool profiling_use_getrusage;
- ulong query_cache_type;
- ulong log_slow_rate_limit;
- ulong read_buff_size;
-diff -r 92e70e675363 sql/sql_profile.cc
---- a/sql/sql_profile.cc Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/sql_profile.cc Mon Jun 01 00:50:00 2009 -0700
-@@ -221,9 +221,22 @@
- */
- void PROF_MEASUREMENT::collect()
- {
-+ struct timespec tp;
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
- #ifdef HAVE_GETRUSAGE
-- getrusage(RUSAGE_SELF, &rusage);
-+ if ((profile->get_profiling())->enabled_getrusage())
-+ getrusage(RUSAGE_SELF, &rusage);
-+#endif
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ {
-+ cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
-+ }
-+ else
-+ {
-+ cpu_time_usecs= 0;
-+ }
- #endif
- }
-
-@@ -341,7 +354,7 @@
- finish_current_query();
- }
-
-- enabled= (((thd)->options & OPTION_PROFILING) != 0);
-+ enabled= (((thd)->options & OPTION_PROFILING) != 0) || ( thd->variables.profiling_server );
-
- if (! enabled) DBUG_VOID_RETURN;
-
-@@ -379,7 +392,8 @@
- status_change("ending", NULL, NULL, 0);
-
- if ((enabled) && /* ON at start? */
-- ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
-+ (((thd->options & OPTION_PROFILING) != 0) ||
-+ (thd->variables.profiling_server)) && /* and ON at end? */
- (current->query_source != NULL) &&
- (! current->entries.is_empty()))
- {
-@@ -480,6 +494,88 @@
- DBUG_VOID_RETURN;
- }
-
-+bool PROFILING::enabled_getrusage()
-+{
-+ return thd->variables.profiling_use_getrusage;
-+}
-+
-+/**
-+ Print output for current query to file
-+*/
-+
-+int PROFILING::print_current(IO_CACHE *log_file)
-+{
-+ DBUG_ENTER("PROFILING::print_current");
-+ ulonglong row_number= 0;
-+ char query_time_buff[22+7];
-+ char query_cpu_time_buff[22+7];
-+
-+ QUERY_PROFILE *query;
-+ /* Get current query */
-+ if (current == NULL)
-+ {
-+ DBUG_RETURN(0);
-+ }
-+
-+ query= current;
-+
-+ my_b_printf(log_file, "# PROFILE_VALUES ");
-+
-+ void *entry_iterator;
-+ PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
-+ /* ...and for each query, go through all its state-change steps. */
-+ for (entry_iterator= query->entries.new_iterator();
-+ entry_iterator != NULL;
-+ entry_iterator= query->entries.iterator_next(entry_iterator),
-+ previous=entry, row_number++)
-+ {
-+ entry= query->entries.iterator_value(entry_iterator);
-+
-+ /* Skip the first. We count spans of fence, not fence-posts. */
-+ if (previous == NULL) {first= entry; continue;}
-+
-+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
-+ {
-+ /*
-+ We got here via a SHOW command. That means that we stored
-+ information about the query we wish to show and that isn't
-+ in a WHERE clause at a higher level to filter out rows we
-+ wish to exclude.
-+
-+ Because that functionality isn't available in the server yet,
-+ we must filter here, at the wrong level. Once one can con-
-+ struct where and having conditions at the SQL layer, then this
-+ condition should be ripped out.
-+ */
-+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
-+ {
-+ if (query != last)
-+ continue;
-+ }
-+ else
-+ {
-+ if (thd->lex->profile_query_id != query->profiling_query_id)
-+ continue;
-+ }
-+ }
-+
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
-+
-+ }
-+
-+ my_b_printf(log_file, "\n");
-+ if ((entry != NULL) && (first != NULL))
-+ {
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /**
- Fill the information schema table, "query_profile", as defined in show.cc .
- There are two ways to get to this function: Selecting from the information
-diff -r 92e70e675363 sql/sql_profile.h
---- a/sql/sql_profile.h Mon Jun 01 00:48:56 2009 -0700
-+++ b/sql/sql_profile.h Mon Jun 01 00:50:00 2009 -0700
-@@ -193,6 +193,7 @@
- unsigned int line;
-
- double time_usecs;
-+ double cpu_time_usecs;
- char *allocated_status_memory;
-
- void set_label(const char *status_arg, const char *function_arg,
-@@ -243,6 +244,11 @@
-
- /* Show this profile. This is called by PROFILING. */
- bool show(uint options);
-+
-+public:
-+
-+ inline PROFILING * get_profiling() { return profiling; };
-+
- };
-
-
-@@ -288,9 +294,11 @@
-
- /* SHOW PROFILES */
- bool show_profiles();
-+ bool enabled_getrusage();
-
- /* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
-+ int print_current(IO_CACHE *log_file);
- };
-
- # endif /* HAVE_PROFILING */
diff --git a/percona/5.0.83-b17-20090706/series b/percona/5.0.83-b17-20090706/series
deleted file mode 100644
index 21646a2..0000000
--- a/percona/5.0.83-b17-20090706/series
+++ /dev/null
@@ -1,20 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-profiling_slow.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-#mirror_binlog.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_show_hashed_memory.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-split_buf_pool_mutex_fixed_optimistic_safe.patch
-innodb_rw_lock.patch
-mysql-test.patch
diff --git a/percona/5.0.83-b17-20090706/show_patches.patch b/percona/5.0.83-b17-20090706/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.83-b17-20090706/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.83-b17-20090706/split_buf_pool_mutex_fixed_optimistic_safe.patch b/percona/5.0.83-b17-20090706/split_buf_pool_mutex_fixed_optimistic_safe.patch
deleted file mode 100644
index fe86f60..0000000
--- a/percona/5.0.83-b17-20090706/split_buf_pool_mutex_fixed_optimistic_safe.patch
+++ /dev/null
@@ -1,1316 +0,0 @@
-diff -r fb75578f988a innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0buf.c Mon Jun 01 00:37:25 2009 -0700
-@@ -549,6 +549,19 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_create(&(buf_pool->free_mutex));
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_NO_ORDER_CHECK);
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_NO_ORDER_CHECK);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +737,10 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -860,12 +877,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->LRU_mutex));
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
- }
-
-@@ -881,7 +898,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +906,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +917,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +927,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +968,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +989,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +997,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1016,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1026,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1068,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1076,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1097,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1105,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1184,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ // mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1229,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ // mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1241,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1234,7 +1258,9 @@
- LRU list and we must put it to awe_LRU_free_mapped list once
- mapped to a frame */
-
-+ mutex_enter_fast(&(buf_pool->mutex));
- buf_awe_map_page_to_frame(block, TRUE);
-+ mutex_exit(&buf_pool->mutex);
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -1242,7 +1268,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1792,7 +1818,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1834,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1850,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1906,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1918,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1942,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1954,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1968,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +2004,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2087,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2095,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2131,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,11 +2141,26 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
- if (srv_io_pattern && srv_io_pattern_trace_running) {
-@@ -2132,6 +2185,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2195,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2222,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2192,10 +2245,22 @@
- ulint n_flush = 0;
- ulint n_free = 0;
- ulint n_page = 0;
-+ ulint n_single_flush_tmp = 0;
-+ ulint n_lru_flush_tmp = 0;
-+ ulint n_list_flush_tmp = 0;
-
- ut_ad(buf_pool);
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+
- mutex_enter(&(buf_pool->mutex));
-+ n_single_flush_tmp = buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE];
-+ n_list_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LIST];
-+ n_lru_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LRU];
-+ mutex_exit(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2263,11 +2328,14 @@
- }
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
-- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+ ut_a(n_single_flush_tmp == n_single_flush);
-+ ut_a(n_list_flush_tmp == n_list_flush);
-+ ut_a(n_lru_flush_tmp == n_lru_flush);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2367,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2422,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,8 +2459,6 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2404,7 +2474,6 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2501,9 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2511,9 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ratio);
- }
-@@ -2460,6 +2533,9 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -2533,6 +2609,9 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
- }
-
-@@ -2563,8 +2642,6 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2586,8 +2663,6 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
--
- return(TRUE);
- }
-
-@@ -2626,11 +2701,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r fb75578f988a innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0flu.c Mon Jun 01 00:37:25 2009 -0700
-@@ -117,12 +117,14 @@
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* I permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -536,18 +538,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +748,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +782,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +793,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -849,7 +853,14 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+
- for (;;) {
- /* If we have flushed enough, leave the loop */
- if (page_count >= min_n) {
-@@ -895,7 +906,10 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- old_page_count = page_count;
-
-@@ -915,7 +929,10 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -938,6 +955,13 @@
- }
- }
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex));
-+
- (buf_pool->init_flush)[flush_type] = FALSE;
-
- if ((buf_pool->n_flush[flush_type] == 0)
-@@ -996,11 +1020,15 @@
- buf_block_t* block;
- ulint n_replaceable;
- ulint distance = 0;
--
-- mutex_enter(&(buf_pool->mutex));
-+
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-+ //mutex_enter(&(buf_pool->free_mutex));
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-+ //mutex_exit(&(buf_pool->free_mutex));
-+
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while ((block != NULL)
-@@ -1021,7 +1049,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1040,8 +1068,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1051,7 +1080,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1101,11 +1130,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r fb75578f988a innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0lru.c Mon Jun 01 00:37:25 2009 -0700
-@@ -206,7 +206,10 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +247,10 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +280,10 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +306,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +322,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +346,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +369,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,14 +392,25 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
- freed = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,13 +421,21 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-+ mutex_exit(&(buf_pool->mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- return(FALSE);
- }
- }
-+ if (!freed) {
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +487,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +496,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +520,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex)); /* LRU info:optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,7 +576,7 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ block = UT_LIST_GET_LAST(buf_pool->free);
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-@@ -564,7 +604,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -576,7 +616,7 @@
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +653,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -1085,7 +1125,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1128,7 +1168,10 @@
-
- if (buf_pool->LRU_old) {
- ut_a(buf_pool->LRU_old_len == old_len);
-- }
-+ }
-+
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
-@@ -1140,7 +1183,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1199,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1243,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r fb75578f988a innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0rea.c Mon Jun 01 00:37:25 2009 -0700
-@@ -237,10 +237,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -251,8 +253,9 @@
- recent_blocks++;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -348,7 +351,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -451,6 +454,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -464,6 +468,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -480,12 +485,13 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -493,10 +499,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -512,7 +519,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -588,7 +595,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -656,7 +663,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -728,7 +735,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r fb75578f988a innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0buf.h Mon Jun 01 00:37:25 2009 -0700
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r fb75578f988a innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0buf.ic Mon Jun 01 00:37:25 2009 -0700
-@@ -112,7 +112,7 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -122,7 +122,7 @@
- lsn = block->oldest_modification;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -392,18 +392,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +425,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +433,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -632,9 +632,9 @@
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->flush_list_mutex);
- buf_flush_note_modification(block, mtr);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->flush_list_mutex);
- }
-
- mutex_enter(&block->mutex);
-diff -r fb75578f988a innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0flu.h Mon Jun 01 00:37:25 2009 -0700
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r fb75578f988a innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0flu.ic Mon Jun 01 00:37:25 2009 -0700
-@@ -84,7 +84,7 @@
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
-@@ -102,5 +102,5 @@
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-diff -r fb75578f988a innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/log/log0recv.c Mon Jun 01 00:37:25 2009 -0700
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r fb75578f988a patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info Mon Jun 01 00:37:25 2009 -0700
-@@ -0,0 +1,6 @@
-+File=split_buf_pool_mutex_fixed_optimistic_safe.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.83-b17-20090706/userstatv2.patch b/percona/5.0.83-b17-20090706/userstatv2.patch
deleted file mode 100644
index a3719a1..0000000
--- a/percona/5.0.83-b17-20090706/userstatv2.patch
+++ /dev/null
@@ -1,4387 +0,0 @@
-diff -r 1ac0113deff5 BUILD/Makefile.in
---- a/BUILD/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/BUILD/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 Docs/Makefile.in
---- a/Docs/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/Docs/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 Makefile.in
---- a/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 SSL/Makefile.in
---- a/SSL/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/SSL/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 client/Makefile.in
---- a/client/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/client/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 configure
---- a/configure Mon Jun 01 00:35:44 2009 -0700
-+++ b/configure Mon Jun 01 00:36:01 2009 -0700
-@@ -35333,7 +35333,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38777,7 +38861,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 1ac0113deff5 configure.in
---- a/configure.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/configure.in Mon Jun 01 00:36:01 2009 -0700
-@@ -2122,7 +2122,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2758,7 +2769,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 1ac0113deff5 dbug/Makefile.in
---- a/dbug/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/dbug/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/Makefile.in
---- a/extra/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 heap/Makefile.in
---- a/heap/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/heap/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 include/Makefile.in
---- a/include/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/include/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 include/mysql_com.h
---- a/include/mysql_com.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/include/mysql_com.h Mon Jun 01 00:36:01 2009 -0700
-@@ -106,6 +106,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 1ac0113deff5 libmysql/Makefile.in
---- a/libmysql/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/libmysql/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/libmysql_r/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/libmysqld/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 man/Makefile.in
---- a/man/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/man/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 myisam/Makefile.in
---- a/myisam/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/myisam/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/myisammrg/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysql-test/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon Jun 01 00:36:01 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- show global status like "Uptime_%";
- Variable_name Value
-diff -r 1ac0113deff5 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon Jun 01 00:36:01 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 1ac0113deff5 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon Jun 01 00:36:01 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 1ac0113deff5 mysys/Makefile.in
---- a/mysys/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/mysys/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/Makefile.in
---- a/ndb/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/docs/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/include/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/src/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/ndb/tools/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 netware/Makefile.in
---- a/netware/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/netware/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 os2/Makefile.in
---- a/os2/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/os2/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 os2/include/Makefile.in
---- a/os2/include/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/os2/include/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/os2/include/sys/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Mon Jun 01 00:36:01 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 1ac0113deff5 pstack/Makefile.in
---- a/pstack/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/pstack/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/pstack/aout/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 regex/Makefile.in
---- a/regex/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/regex/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 scripts/Makefile.in
---- a/scripts/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/scripts/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 server-tools/Makefile.in
---- a/server-tools/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/server-tools/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 sql/Makefile.in
---- a/sql/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/ha_innodb.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -3338,6 +3338,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3610,6 +3612,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3658,6 +3662,8 @@
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -4089,6 +4095,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 1ac0113deff5 sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/ha_myisam.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1518,13 +1520,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1535,6 +1541,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1545,6 +1558,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1555,6 +1575,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1565,6 +1592,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1575,6 +1609,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1585,6 +1626,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1595,6 +1643,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1611,6 +1666,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1628,6 +1690,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1642,6 +1705,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 1ac0113deff5 sql/handler.cc
---- a/sql/handler.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/handler.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 1ac0113deff5 sql/handler.h
---- a/sql/handler.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/handler.h Mon Jun 01 00:36:01 2009 -0700
-@@ -32,6 +32,10 @@
- #define USING_TRANSACTIONS
- #endif
-
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
-+#endif
-+
- // the following is for checking tables
-
- #define HA_ADMIN_ALREADY_DONE 1
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 1ac0113deff5 sql/lex.h
---- a/sql/lex.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/lex.h Mon Jun 01 00:36:01 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 1ac0113deff5 sql/log.cc
---- a/sql/log.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/log.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 1ac0113deff5 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/mysql_priv.h Mon Jun 01 00:36:01 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 1ac0113deff5 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 1ac0113deff5 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 1ac0113deff5 sql/share/Makefile.in
---- a/sql/share/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/share/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 sql/sql_base.cc
---- a/sql/sql_base.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_base.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 1ac0113deff5 sql/sql_class.cc
---- a/sql/sql_class.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_class.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 1ac0113deff5 sql/sql_class.h
---- a/sql/sql_class.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_class.h Mon Jun 01 00:36:01 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,8 +1943,14 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-
-+ char *get_client_host_port(THD *client);
-+
- public:
- /**
- Add an internal error handler to the thread execution context.
-@@ -1935,6 +1993,11 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-+#define LIST_PROCESS_HOST_LEN 64
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 1ac0113deff5 sql/sql_delete.cc
---- a/sql/sql_delete.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_delete.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -869,6 +870,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 1ac0113deff5 sql/sql_insert.cc
---- a/sql/sql_insert.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_insert.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -989,6 +989,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3064,6 +3065,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 1ac0113deff5 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_lex.h Mon Jun 01 00:36:01 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 1ac0113deff5 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_parse.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -146,6 +152,17 @@
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
- #endif
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- net->vio && net->error && net->report_error)
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4540,6 +4995,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4848,6 +5312,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5692,6 +6157,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5727,6 +6193,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5759,11 +6226,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5797,6 +6268,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5829,6 +6301,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5860,6 +6333,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5913,8 +6392,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5931,9 +6410,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6443,6 +6925,30 @@
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
- LEX *lex= thd->lex;
-@@ -6521,6 +7027,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7532,8 +8075,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 1ac0113deff5 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_prepare.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -81,6 +81,9 @@
- #include <mysql_com.h>
- #endif
-
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- /* A result class used to send cursor rows using the binary protocol. */
-
- class Select_fetch_protocol_prep: public select_send
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2503,6 +2717,43 @@
-
- send_ok(thd);
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-diff -r 1ac0113deff5 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_show.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,10 +4912,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 1ac0113deff5 sql/sql_update.cc
---- a/sql/sql_update.cc Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_update.cc Mon Jun 01 00:36:01 2009 -0700
-@@ -604,7 +604,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1835,5 +1836,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 1ac0113deff5 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/sql_yacc.yy Mon Jun 01 00:36:01 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 1ac0113deff5 sql/structs.h
---- a/sql/structs.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/structs.h Mon Jun 01 00:36:01 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[USERNAME_LENGTH + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[USERNAME_LENGTH + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 1ac0113deff5 sql/table.h
---- a/sql/table.h Mon Jun 01 00:35:44 2009 -0700
-+++ b/sql/table.h Mon Jun 01 00:36:01 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 1ac0113deff5 strings/Makefile.in
---- a/strings/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/strings/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 support-files/Makefile.in
---- a/support-files/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/support-files/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 tests/Makefile.in
---- a/tests/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/tests/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 tools/Makefile.in
---- a/tools/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/tools/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 vio/Makefile.in
---- a/vio/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/vio/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 win/Makefile.in
---- a/win/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/win/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 1ac0113deff5 zlib/Makefile.in
---- a/zlib/Makefile.in Mon Jun 01 00:35:44 2009 -0700
-+++ b/zlib/Makefile.in Mon Jun 01 00:36:01 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.83-b17-20090723/innodb_check_fragmentation.patch b/percona/5.0.83-b17-20090723/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.83-b17-20090723/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.83-b17-20090723/innodb_dict_size_limit.patch b/percona/5.0.83-b17-20090723/innodb_dict_size_limit.patch
deleted file mode 100644
index 843d043..0000000
--- a/percona/5.0.83-b17-20090723/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,483 +0,0 @@
-diff -r 6eeee157fd40 innobase/dict/dict0boot.c
---- a/innobase/dict/dict0boot.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0boot.c Fri Jul 03 15:41:41 2009 -0700
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -r 6eeee157fd40 innobase/dict/dict0crea.c
---- a/innobase/dict/dict0crea.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0crea.c Fri Jul 03 15:41:41 2009 -0700
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1266,6 +1269,11 @@
- que_graph_free(graph);
-
- trx->op_info = "";
-+
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-
- row_mysql_unlock_data_dictionary(trx);
-
-diff -r 6eeee157fd40 innobase/dict/dict0dict.c
---- a/innobase/dict/dict0dict.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0dict.c Fri Jul 03 15:41:41 2009 -0700
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -786,6 +790,8 @@
-
- table->n_mysql_handles_opened++;
- }
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
--
-- ut_error;
--
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(dict_sys->mutex)));
--#endif /* UNIV_SYNC_DEBUG */
--
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-+
-+ //ut_error;
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ ut_ad(mutex_own(&(dict_sys->mutex)));
-+#endif /* UNIV_SYNC_DEBUG */
-+
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1342,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-diff -r 6eeee157fd40 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/ibuf/ibuf0ibuf.c Fri Jul 03 15:41:41 2009 -0700
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -r 6eeee157fd40 innobase/include/dict0dict.h
---- a/innobase/include/dict0dict.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/dict0dict.h Fri Jul 03 15:41:41 2009 -0700
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -r 6eeee157fd40 innobase/include/dict0dict.ic
---- a/innobase/include/dict0dict.ic Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/dict0dict.ic Fri Jul 03 15:41:41 2009 -0700
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -r 6eeee157fd40 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_dict_size_limit;
-
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
-@@ -552,6 +554,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -r 6eeee157fd40 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_dict_size_limit = 0;
-
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
-@@ -1953,6 +1955,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -r 6eeee157fd40 mysql-test/r/innodb_dict_size_limit.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/innodb_dict_size_limit.result Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -r 6eeee157fd40 mysql-test/t/innodb_dict_size_limit.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/innodb_dict_size_limit.test Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -r 6eeee157fd40 patch_info/innodb_dict_size_limit.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_dict_size_limit.info Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
-diff -r 6eeee157fd40 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -r 6eeee157fd40 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-@@ -243,6 +243,7 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -r 6eeee157fd40 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5464,6 +5465,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -r 6eeee157fd40 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -540,6 +540,8 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -930,6 +932,7 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1084,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090723/innodb_extra_rseg.patch b/percona/5.0.83-b17-20090723/innodb_extra_rseg.patch
deleted file mode 100644
index cab3b26..0000000
--- a/percona/5.0.83-b17-20090723/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -r 85e7025cf2d1 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:47 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_extra_rsegments;
-
- extern ulint srv_dict_size_limit;
-
-diff -r 85e7025cf2d1 innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/trx0sys.h Fri Jul 03 15:41:47 2009 -0700
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -r 85e7025cf2d1 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:47 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-
- ulint srv_dict_size_limit = 0;
-
-diff -r 85e7025cf2d1 innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0start.c Fri Jul 03 15:41:47 2009 -0700
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -r 85e7025cf2d1 innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:47 2009 -0700
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -r 85e7025cf2d1 patch_info/innodb_extra_rseg.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_rseg.info Fri Jul 03 15:41:47 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -r 85e7025cf2d1 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1521,6 +1522,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -r 85e7025cf2d1 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:47 2009 -0700
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -r 85e7025cf2d1 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
-@@ -5465,6 +5466,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -r 85e7025cf2d1 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -1087,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -r 85e7025cf2d1 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4180,6 +4182,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4996,6 +5037,16 @@
- {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
- {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
- #endif
-@@ -5177,6 +5228,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.83-b17-20090723/innodb_extra_status.patch b/percona/5.0.83-b17-20090723/innodb_extra_status.patch
deleted file mode 100644
index adc1642..0000000
--- a/percona/5.0.83-b17-20090723/innodb_extra_status.patch
+++ /dev/null
@@ -1,747 +0,0 @@
-diff -r b059d02ec814 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -2353,6 +2353,7 @@
- "AWE: Database pages and free buffers mapped in frames %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
-+ if (file) {
- fprintf(file,
- "Buffer pool size %lu\n"
- "Free buffers %lu\n"
-@@ -2371,11 +2372,13 @@
- + buf_pool->init_flush[BUF_FLUSH_LIST],
- (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
-
-+ } // if (file)
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time,
- buf_pool->last_printout_time);
- buf_pool->last_printout_time = current_time;
-
-+ if (file) {
- fprintf(file,
- "Pages read %lu, created %lu, written %lu\n"
- "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
-@@ -2405,6 +2408,7 @@
- } else {
- fputs("No buffer pool page gets since the last printout\n",
- file);
-+ }
- }
-
- buf_pool->n_page_gets_old = buf_pool->n_page_gets;
-diff -r b059d02ec814 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -3519,9 +3519,15 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ inno_ibuf_size = 0;
-+ inno_ibuf_inserts = 0;
-+ inno_ibuf_merged_recs = 0;
-+ inno_ibuf_merges = 0;
-+
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
-+ if (file) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
-@@ -3542,6 +3548,12 @@
- }
- }
- #endif
-+ } // if (file)
-+ inno_ibuf_size += (ulong) data->size;
-+ inno_ibuf_inserts += (ulong) data->n_inserts;
-+ inno_ibuf_merged_recs += (ulong) data->n_merged_recs;
-+ inno_ibuf_merges += (ulong) data->n_merges;
-+
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
-diff -r b059d02ec814 innobase/include/lock0lock.h
---- a/innobase/include/lock0lock.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/lock0lock.h Mon Nov 03 05:09:34 2008 -0800
-@@ -24,6 +24,10 @@
- #endif /* UNIV_DEBUG */
- /* Buffer for storing information about the most recent deadlock error */
- extern FILE* lock_latest_err_file;
-+
-+/* number of deadlocks happened so far */
-+extern ulint innodb_deadlocks;
-+
-
- /*************************************************************************
- Gets the size of a lock struct. */
-diff -r b059d02ec814 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:09:34 2008 -0800
-@@ -261,6 +261,12 @@
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+extern ibool srv_long_lock_wait;
-+
-+/* variable to count the number long semaphore waits noticed */
-+extern ulint srv_long_lock_waits;
-+
- /* Number of IO operations read/write done for all threads */
- extern ulint os_aio_read_requests;
- extern ulint os_aio_write_requests;
-@@ -278,6 +284,26 @@
- extern ulint inno_pending_ibuf_aio_reads;
- extern ulint inno_pending_log_ios;
- extern ulint inno_pending_sync_ios;
-+
-+/* all 24 innodb status variables, exported to status */
-+extern ulint inno_transaction_count;
-+extern ulint inno_transaction_purge_count;
-+extern ulint inno_transaction_purge_lag;
-+extern ulint inno_num_active_transactions;
-+extern ulint inno_summed_transaction_age;
-+extern ulint inno_longest_transaction_age;
-+extern ulint inno_lock_wait_timeouts;
-+extern ulint inno_num_lock_waiters;
-+extern ulint inno_summed_lock_wait_time;
-+extern ulint inno_longest_lock_wait;
-+extern ulint inno_os_reads;
-+extern ulint inno_os_writes;
-+extern ulint inno_os_fsyncs;
-+extern ulint inno_ibuf_size;
-+extern ulint inno_ibuf_inserts;
-+extern ulint inno_ibuf_merged_recs;
-+extern ulint inno_ibuf_merges;
-+extern ulint inno_log_ios_done;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-@@ -552,6 +578,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_size;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-@@ -587,6 +614,43 @@
- ulint innodb_rows_inserted;
- ulint innodb_rows_updated;
- ulint innodb_rows_deleted;
-+ ibool innodb_long_lock_wait;
-+ ulint innodb_long_lock_waits;
-+
-+ ulint innodb_os_aio_read_requests;
-+ ulint innodb_os_aio_write_requests;
-+ ulint innodb_os_aio_pages_read;
-+ ulint innodb_os_aio_pages_written;
-+ ib_longlong innodb_os_aio_read_time;
-+ ib_longlong innodb_os_aio_write_time;
-+ ib_longlong innodb_os_aio_read_time_avg;
-+ ib_longlong innodb_os_aio_write_time_avg;
-+ ulint innodb_deadlocks;
-+
-+ // the following 24 variables are exported to "show status"
-+ ulint inno_transaction_count;
-+ ulint inno_transaction_purge_count;
-+ ulint inno_transaction_purge_lag;
-+ ulint inno_num_active_transactions;
-+ ulint inno_summed_transaction_age;
-+ ulint inno_longest_transaction_age;
-+ ulint inno_lock_wait_timeouts;
-+ ulint inno_num_lock_waiters;
-+ ulint inno_summed_lock_wait_time;
-+ ulint inno_longest_lock_wait;
-+ ulint inno_pending_normal_aio_reads;
-+ ulint inno_pending_normal_aio_writes;
-+ ulint inno_pending_ibuf_aio_reads;
-+ ulint inno_pending_log_ios;
-+ ulint inno_pending_sync_ios;
-+ ulint inno_os_reads;
-+ ulint inno_os_writes;
-+ ulint inno_os_fsyncs;
-+ ulint inno_ibuf_size;
-+ ulint inno_ibuf_inserts;
-+ ulint inno_ibuf_merged_recs;
-+ ulint inno_ibuf_merges;
-+ ulint inno_log_ios_done;
- };
-
- /* The server system struct */
-diff -r b059d02ec814 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Nov 03 05:09:34 2008 -0800
-@@ -360,6 +360,9 @@
- ibool lock_deadlock_found = FALSE;
- FILE* lock_latest_err_file;
-
-+/* number of deadlocks happened so far */
-+ulint innodb_deadlocks = 0;
-+
- /* Flags for recursive deadlock search */
- #define LOCK_VICTIM_IS_START 1
- #define LOCK_VICTIM_IS_OTHER 2
-@@ -3304,6 +3307,7 @@
-
- FILE* ef = lock_latest_err_file;
-
-+ innodb_deadlocks++;
- rewind(ef);
- ut_print_timestamp(ef);
-
-@@ -4238,6 +4242,7 @@
- innobase_mysql_prepare_print_arbitrary_thd();
- lock_mutex_enter_kernel();
-
-+ if (file) {
- if (lock_deadlock_found) {
- fputs(
- "------------------------\n"
-@@ -4269,6 +4274,12 @@
- fprintf(file,
- "Total number of lock structs in row lock hash table %lu\n",
- (ulong) lock_get_n_rec_locks());
-+ } // if (file)
-+ inno_transaction_purge_count =
-+ (ulong) ut_dulint_get_low(purge_sys->purge_trx_no);
-+ inno_transaction_count =
-+ (ulong) ut_dulint_get_low(trx_sys->max_trx_id);
-+ inno_transaction_purge_lag = (ulong) trx_sys->rseg_history_len;
- }
-
- /*************************************************************************
-@@ -4289,7 +4300,17 @@
- ulint i;
- mtr_t mtr;
- trx_t* trx;
--
-+ time_t current_time = time(NULL);
-+
-+ /* init all counters to be updated */
-+ inno_num_lock_waiters = 0;
-+ inno_summed_lock_wait_time = 0;
-+ inno_longest_lock_wait = 0;
-+ inno_num_active_transactions = 0;
-+ inno_summed_transaction_age = 0;
-+ inno_longest_transaction_age = 0;
-+
-+ if (file) {
- fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
-
- /* First print info on non-active transactions */
-@@ -4304,6 +4325,7 @@
-
- trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
- }
-+ } // if (file)
-
- loop:
- trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
-@@ -4330,6 +4352,7 @@
- }
-
- if (nth_lock == 0) {
-+ if (file) {
- fputs("---", file);
- trx_print(file, trx, 600);
-
-@@ -4341,11 +4364,27 @@
- (ulong) ut_dulint_get_high(trx->read_view->up_limit_id),
- (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
- }
-+ } // if (file)
-+
-+ if (trx->conc_state == TRX_ACTIVE) {
-+ ulong trx_age = (ulong)difftime(time(NULL), trx->start_time);
-+ inno_num_active_transactions++;
-+ inno_summed_transaction_age += trx_age;
-+ if (inno_longest_transaction_age > trx_age)
-+ inno_longest_transaction_age = trx_age;
-+ }
-
- if (trx->que_state == TRX_QUE_LOCK_WAIT) {
-+ ulong wait_time = (ulong)difftime(current_time,
-+ trx->wait_started);
-+ inno_num_lock_waiters++;
-+ inno_summed_lock_wait_time += wait_time;
-+ if (inno_longest_lock_wait < wait_time)
-+ inno_longest_lock_wait = wait_time;
-+ if (file) {
- fprintf(file,
- "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
-- (ulong)difftime(time(NULL), trx->wait_started));
-+ wait_time);
-
- if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(file, trx->wait_lock);
-@@ -4354,10 +4393,16 @@
- }
-
- fputs("------------------\n", file);
-- }
-- }
--
-- if (!srv_print_innodb_lock_monitor) {
-+ } // if (file)
-+ }
-+ }
-+
-+ /* don't print locks per transaction if either
-+ 1) srv_print_innodb_lock_monitor is NOT set,
-+ ie no magic table innodb_lock_monitor is created, or
-+ 2) file == NULL, ie, at counter updating stage from "show status"
-+ */
-+ if (!srv_print_innodb_lock_monitor || !file) {
- nth_trx++;
- goto loop;
- }
-diff -r b059d02ec814 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:09:34 2008 -0800
-@@ -267,6 +267,35 @@
- ulint inno_pending_log_ios = 0;
- ulint inno_pending_sync_ios = 0;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+ibool srv_long_lock_wait = FALSE;
-+
-+/* variable to count the number long semaphore waits noticed */
-+ulint srv_long_lock_waits = 0;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+extern long innobase_min_status_update_time_interval;
-+
-+/* all 24 innodb status variables, exported to status */
-+ulint inno_transaction_count = 0;
-+ulint inno_transaction_purge_count = 0;
-+ulint inno_transaction_purge_lag = 0;
-+ulint inno_num_active_transactions = 0;
-+ulint inno_summed_transaction_age = 0;
-+ulint inno_longest_transaction_age = 0;
-+ulint inno_lock_wait_timeouts = 0; /* Counts number of lock wait timeouts. */
-+ulint inno_num_lock_waiters = 0;
-+ulint inno_summed_lock_wait_time = 0;
-+ulint inno_longest_lock_wait = 0;
-+ulint inno_os_reads = 0;
-+ulint inno_os_writes = 0;
-+ulint inno_os_fsyncs = 0;
-+ulint inno_ibuf_size = 0;
-+ulint inno_ibuf_inserts = 0;
-+ulint inno_ibuf_merged_recs = 0;
-+ulint inno_ibuf_merges = 0;
-+ulint inno_log_ios_done = 0;
-+
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-
-@@ -419,6 +448,10 @@
- const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
-
- time_t srv_last_monitor_time;
-+
-+/* last time innodb status were updated thru show status */
-+time_t srv_last_innodb_status_time = 0;
-+
-
- mutex_t srv_innodb_monitor_mutex;
-
-@@ -677,6 +710,24 @@
-
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-+
-+/*************************************************************************
-+Prints counters for work done by srv_master_thread. */
-+
-+static
-+void
-+srv_print_extra(
-+/*===================*/
-+ FILE *file) /* in: output stream */
-+{
-+ fprintf(file, "srv_master_thread loops: %lu 1_second, %lu sleeps, "
-+ "%lu 10_second, %lu background, %lu flush\n",
-+ srv_main_1_second_loops, srv_main_sleeps,
-+ srv_main_10_second_loops, srv_main_background_loops,
-+ srv_main_flush_loops);
-+ fprintf(file, "srv_master_thread log flush: %lu sync, %lu async\n",
-+ srv_sync_flush, srv_async_flush);
-+}
-
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-@@ -1685,12 +1736,13 @@
- fputs("----------\n"
- "BACKGROUND THREAD\n"
- "----------\n", file);
-+ srv_print_extra(file);
- fil_print(file);
--
-
- fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
-+ fprintf(file, "Lock wait timeouts %lu\n", inno_lock_wait_timeouts);
- sync_print(file);
-
- /* Conceptually, srv_innodb_monitor_mutex has a very high latching
-@@ -1709,24 +1761,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1815,6 +1849,27 @@
- (srv_n_rows_read - srv_n_rows_read_old)
- / time_elapsed);
-
-+ /* Print open transaction details */
-+ lock_print_info_summary(file);
-+
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- srv_n_rows_inserted_old = srv_n_rows_inserted;
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
-@@ -1833,7 +1888,8 @@
- void
- srv_export_innodb_status(void)
- {
--
-+ long time_elapsed;
-+ time_t current_time;
- mutex_enter(&srv_innodb_monitor_mutex);
- export_vars.innodb_data_pending_reads= os_n_pending_reads;
- export_vars.innodb_data_pending_writes= os_n_pending_writes;
-@@ -1844,6 +1900,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_size= dict_sys->size;
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-@@ -1854,10 +1911,12 @@
- export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
- export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
- export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
-- export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
-+ /* This function uses too much CPU for large buffer caches. */
-+ export_vars.innodb_buffer_pool_pages_latched= 1; /* buf_get_latched_pages_number(); */
- export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
- export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
- UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
-+
- export_vars.innodb_page_size= UNIV_PAGE_SIZE;
- export_vars.innodb_log_waits= srv_log_waits;
- export_vars.innodb_os_log_written= srv_os_log_written;
-@@ -1885,6 +1944,103 @@
- export_vars.innodb_rows_inserted= srv_n_rows_inserted;
- export_vars.innodb_rows_updated= srv_n_rows_updated;
- export_vars.innodb_rows_deleted= srv_n_rows_deleted;
-+ export_vars.innodb_long_lock_wait = srv_long_lock_wait;
-+ export_vars.innodb_long_lock_waits = srv_long_lock_waits;
-+
-+ export_vars.innodb_os_aio_read_requests = os_aio_read_requests;
-+ export_vars.innodb_os_aio_write_requests = os_aio_write_requests;
-+
-+ export_vars.innodb_os_aio_pages_read = os_aio_pages_read;
-+ export_vars.innodb_os_aio_pages_written = os_aio_pages_written;
-+
-+ export_vars.innodb_os_aio_read_time = os_aio_read_time;
-+ export_vars.innodb_os_aio_write_time = os_aio_write_time;
-+
-+ if (os_aio_read_requests > 0 ) {
-+ export_vars.innodb_os_aio_read_time_avg
-+ = os_aio_read_time / os_aio_read_requests;
-+ } else {
-+ export_vars.innodb_os_aio_read_time_avg = 0;
-+ }
-+ if (os_aio_write_requests > 0 ) {
-+ export_vars.innodb_os_aio_write_time_avg
-+ = os_aio_write_time / os_aio_write_requests;
-+ } else {
-+ export_vars.innodb_os_aio_write_time_avg = 0;
-+ }
-+
-+ export_vars.innodb_deadlocks = innodb_deadlocks;
-+
-+ // simulate srv_printf_innodb_monitor, invoked by innodb_show_status
-+ // 0. direct printout inno_lock_wait_timeouts, declared in srv0srv.c
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_lock_wait_timeouts = inno_lock_wait_timeouts;
-+
-+ // *_print functions are allowed to be called once every
-+ // some seconds to prevent too frequent invocation.
-+ // the number is innobase_min_status_update_time_interval
-+ current_time = time(NULL);
-+ time_elapsed = difftime(current_time, srv_last_innodb_status_time);
-+ if (time_elapsed >= innobase_min_status_update_time_interval) {
-+ os_aio_print(NULL);
-+ ibuf_print(NULL);
-+ buf_print_io(NULL);
-+ lock_print_info_summary(NULL);
-+ lock_print_info_all_transactions(NULL);
-+
-+ srv_last_innodb_status_time = current_time;
-+ }
-+
-+ // 1. os_aio_print
-+ // the following were filled by calling os_aio_print
-+ // total # of variable(s) updated: 8
-+
-+ export_vars.inno_pending_normal_aio_reads =
-+ inno_pending_normal_aio_reads;
-+ export_vars.inno_pending_normal_aio_writes =
-+ inno_pending_normal_aio_writes;
-+ export_vars.inno_pending_ibuf_aio_reads = inno_pending_ibuf_aio_reads;
-+ export_vars.inno_pending_log_ios = inno_pending_log_ios;
-+ export_vars.inno_pending_sync_ios = inno_pending_sync_ios;
-+ export_vars.inno_os_reads = os_n_file_reads;
-+ export_vars.inno_os_writes = os_n_file_writes;
-+ export_vars.inno_os_fsyncs = os_n_fsyncs;
-+
-+ // 2. ibuf_print()
-+ // total # of variable(s) updated: 4
-+
-+ export_vars.inno_ibuf_size = inno_ibuf_size;
-+ export_vars.inno_ibuf_inserts = inno_ibuf_inserts;
-+ export_vars.inno_ibuf_merged_recs = inno_ibuf_merged_recs;
-+ export_vars.inno_ibuf_merges = inno_ibuf_merges;
-+
-+ // 3. log_print
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_log_ios_done = (ulong) log_sys->n_log_ios;
-+
-+ // 5. lock_print_info_summary
-+ // it enters the mutexes
-+ // 1) innobase_mysql_prepare_print_arbitrary_thd()
-+ // 2) lock_mutex_enter_kernel()
-+ // total # of variable(s) updated: 3
-+
-+ export_vars.inno_transaction_count = inno_transaction_count;
-+ export_vars.inno_transaction_purge_count =
-+ inno_transaction_purge_count;
-+ export_vars.inno_transaction_purge_lag = inno_transaction_purge_lag;
-+
-+ // 6. lock_print_info_all_transactions(NULL)
-+ // it exits two mutexes entered from lock_print_info_summary(NULL)
-+ // total # of variable(s) updated: 6
-+
-+ export_vars.inno_num_active_transactions = inno_num_active_transactions;
-+ export_vars.inno_summed_transaction_age = inno_summed_transaction_age;
-+ export_vars.inno_longest_transaction_age = inno_longest_transaction_age;
-+
-+ export_vars.inno_num_lock_waiters = inno_num_lock_waiters;
-+ export_vars.inno_summed_lock_wait_time = inno_summed_lock_wait_time;
-+ export_vars.inno_longest_lock_wait = inno_longest_lock_wait;
-+
- mutex_exit(&srv_innodb_monitor_mutex);
-
- }
-@@ -2026,6 +2182,7 @@
- if (thr_get_trx(slot->thr)->wait_lock) {
- lock_cancel_waiting_and_release(
- thr_get_trx(slot->thr)->wait_lock);
-+ ++inno_lock_wait_timeouts;
- }
- }
- }
-diff -r b059d02ec814 patch_info/innodb_extra_status.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_status.info Mon Nov 03 05:09:34 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_extra_status.patch
-+Name=Adds additional information of InnoDB counters into SHOW STATUS
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-03
-+VT: Initial porting
-diff -r b059d02ec814 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -299,12 +299,36 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_size",
-+ (char*) &export_vars.innodb_dict_size, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
- {"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
-+ {"long_lock_wait",
-+ (char*) &export_vars.innodb_long_lock_wait, SHOW_BOOL},
-+ {"long_lock_waits",
-+ (char*) &export_vars.innodb_long_lock_waits, SHOW_LONG},
-+
-+ {"os_read_requests",
-+ (char*) &export_vars.innodb_os_aio_read_requests, SHOW_LONG},
-+ {"os_write_requests",
-+ (char*) &export_vars.innodb_os_aio_write_requests, SHOW_LONG},
-+ {"os_pages_read",
-+ (char*) &export_vars.innodb_os_aio_pages_read, SHOW_LONG},
-+ {"os_pages_written",
-+ (char*) &export_vars.innodb_os_aio_pages_written, SHOW_LONG},
-+ {"os_read_time",
-+ (char*) &export_vars.innodb_os_aio_read_time, SHOW_LONGLONG},
-+ {"os_write_time",
-+ (char*) &export_vars.innodb_os_aio_write_time, SHOW_LONGLONG},
-+ {"time_per_read",
-+ (char*) &export_vars.innodb_os_aio_read_time_avg, SHOW_LONGLONG},
-+ {"time_per_write",
-+ (char*) &export_vars.innodb_os_aio_write_time_avg, SHOW_LONGLONG},
-+
- {"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
- {"os_log_pending_fsyncs",
-@@ -339,6 +363,56 @@
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
- {"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
-+ {"deadlocks",
-+ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
-+
-+ /* 24 innodb status variables exported to status */
-+ {"transaction_count",
-+ (char*) &export_vars.inno_transaction_count, SHOW_LONG},
-+ {"transaction_purge_count",
-+ (char*) &export_vars.inno_transaction_purge_count, SHOW_LONG},
-+ {"transaction_purge_lag",
-+ (char*) &export_vars.inno_transaction_purge_lag, SHOW_LONG},
-+ {"active_transactions",
-+ (char*) &export_vars.inno_num_active_transactions, SHOW_LONG},
-+ {"summed_transaction_age",
-+ (char*) &export_vars.inno_summed_transaction_age, SHOW_LONG},
-+ {"longest_transaction_age",
-+ (char*) &export_vars.inno_longest_transaction_age, SHOW_LONG},
-+ {"lock_wait_timeouts",
-+ (char*) &export_vars.inno_lock_wait_timeouts, SHOW_LONG},
-+ {"lock_waiters",
-+ (char*) &export_vars.inno_num_lock_waiters, SHOW_LONG},
-+ {"summed_lock_wait_time",
-+ (char*) &export_vars.inno_summed_lock_wait_time, SHOW_LONG},
-+ {"longest_lock_wait",
-+ (char*) &export_vars.inno_longest_lock_wait, SHOW_LONG},
-+ {"pending_normal_aio_reads",
-+ (char*) &export_vars.inno_pending_normal_aio_reads, SHOW_LONG},
-+ {"pending_normal_aio_writes",
-+ (char*) &export_vars.inno_pending_normal_aio_writes, SHOW_LONG},
-+ {"pending_ibuf_aio_reads",
-+ (char*) &export_vars.inno_pending_ibuf_aio_reads, SHOW_LONG},
-+ {"pending_log_ios",
-+ (char*) &export_vars.inno_pending_log_ios, SHOW_LONG},
-+ {"pending_sync_ios",
-+ (char*) &export_vars.inno_pending_sync_ios, SHOW_LONG},
-+ {"os_reads",
-+ (char*) &export_vars.inno_os_reads, SHOW_LONG},
-+ {"os_writes",
-+ (char*) &export_vars.inno_os_writes, SHOW_LONG},
-+ {"os_fsyncs",
-+ (char*) &export_vars.inno_os_fsyncs, SHOW_LONG},
-+ {"ibuf_inserts",
-+ (char*) &export_vars.inno_ibuf_size, SHOW_LONG},
-+ {"ibuf_size",
-+ (char*) &export_vars.inno_ibuf_inserts, SHOW_LONG},
-+ {"ibuf_merged_recs",
-+ (char*) &export_vars.inno_ibuf_merged_recs, SHOW_LONG},
-+ {"ibuf_merges",
-+ (char*) &export_vars.inno_ibuf_merges, SHOW_LONG},
-+ {"log_ios_done",
-+ (char*) &export_vars.inno_log_ios_done, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}};
-
- /* General functions */
-diff -r b059d02ec814 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:09:34 2008 -0800
-@@ -198,6 +198,7 @@
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
- extern long innobase_max_merged_io;
-+extern long innobase_min_status_update_time_interval;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-diff -r b059d02ec814 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -4950,6 +4950,7 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -6031,6 +6032,14 @@
- (gptr*) &srv_thread_sleep_delay,
- (gptr*) &srv_thread_sleep_delay,
- 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
-+ {"innodb_status_update_interval",
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
-+ "Minimum time interval in seconds before InnoDB status counters "
-+ "are updated during SHOW STATUS. "
-+ "InnoDB counters are always updated during SHOW INNODB STATUS.",
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ 0, GET_LONG, REQUIRED_ARG, 30, 0, 3600, 0, 1, 0},
- #endif /* HAVE_INNOBASE_DB */
- {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
- "The number of seconds the server waits for activity on an interactive connection before closing it.",
-diff -r b059d02ec814 sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -948,6 +948,8 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
- {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
-+ {"innodb_status_update_interval",
-+ (char*) &innobase_min_status_update_time_interval, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090723/innodb_fsync_source.patch b/percona/5.0.83-b17-20090723/innodb_fsync_source.patch
deleted file mode 100644
index 2961b78..0000000
--- a/percona/5.0.83-b17-20090723/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r ef44d8017b6b innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:32 2009 -0700
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r ef44d8017b6b innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/fil/fil0fil.c Fri Jul 03 15:41:32 2009 -0700
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4167,8 +4188,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4177,7 +4199,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4282,7 +4304,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4323,7 +4346,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r ef44d8017b6b innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/fil0fil.h Fri Jul 03 15:41:32 2009 -0700
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -625,14 +632,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -640,7 +659,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r ef44d8017b6b innobase/include/log0log.h
---- a/innobase/include/log0log.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/log0log.h Fri Jul 03 15:41:32 2009 -0700
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Flushes the log buffer. Forces it to disk depending on the value of
-@@ -751,6 +774,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r ef44d8017b6b innobase/log/log0log.c
---- a/innobase/log/log0log.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/log/log0log.c Fri Jul 03 15:41:32 2009 -0700
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1574,7 +1590,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1944,11 +1960,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1961,7 +1977,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2589,7 +2606,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2670,7 +2687,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3207,8 +3225,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3241,7 +3259,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3363,15 +3381,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r ef44d8017b6b innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:32 2009 -0700
-@@ -1698,6 +1698,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r ef44d8017b6b innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:32 2009 -0700
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r ef44d8017b6b innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0trx.c Fri Jul 03 15:41:32 2009 -0700
-@@ -942,19 +942,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1701,18 +1703,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1948,19 +1953,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r ef44d8017b6b patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Fri Jul 03 15:41:32 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.83-b17-20090723/innodb_io_patches.patch b/percona/5.0.83-b17-20090723/innodb_io_patches.patch
deleted file mode 100644
index aaef29a..0000000
--- a/percona/5.0.83-b17-20090723/innodb_io_patches.patch
+++ /dev/null
@@ -1,1379 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-05-08 06:12:03.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-07-02 16:44:49.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-07-02 16:44:49.000000000 +0900
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +190,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +401,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-05-08 06:12:04.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-07-02 16:44:49.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/log0log.h b/innobase/include/log0log.h
---- a/innobase/include/log0log.h 2009-05-08 06:12:06.000000000 +0900
-+++ b/innobase/include/log0log.h 2009-07-02 16:44:49.000000000 +0900
-@@ -169,6 +169,13 @@
- log_buffer_flush_to_disk(void);
- /*==========================*/
- /********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
-+/*=============================*/
-+/********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
- buffer pool and also may make a new checkpoint. NOTE: this function may only
- be called if the calling thread owns no synchronization objects! */
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-07-02 16:44:49.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-02 18:02:38.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1524,6 +1524,29 @@
- }
-
- /********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*=============================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
-+}
-+/********************************************************************
- Tries to establish a big enough margin of free space in the log buffer, such
- that a new log entry can be catenated without an immediate need for a flush. */
- static
-@@ -3326,6 +3349,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-07-02 16:44:49.000000000 +0900
-@@ -66,6 +66,28 @@
-
- ibool os_aio_print_debug = FALSE;
-
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-+
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-
-@@ -74,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -84,11 +108,11 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
-+// ibool io_already_done;/* used only in simulated aio:
-+// TRUE if the physical i/o already
-+// made and only the slot message
-+// needs to be passed to the caller
-+// of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -137,6 +161,13 @@
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-+
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
- static os_aio_array_t* os_aio_read_array = NULL;
-@@ -145,11 +176,17 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
- /* If the following is TRUE, read i/o handler threads try to
- wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -2878,8 +2915,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2889,6 +2928,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2896,14 +2937,17 @@
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-+ os_aio_first_write_segment = os_aio_first_read_segment + n_read_threads;
- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-
- srv_io_thread_function[0] = "insert buffer thread";
-@@ -2912,14 +2956,14 @@
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-+ os_aio_read_array = os_aio_array_create(n_per_seg,
- n_read_segs);
- for (i = 2; i < 2 + n_read_segs; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
- srv_io_thread_function[i] = "read thread";
- }
-
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-+ os_aio_write_array = os_aio_array_create(n_per_seg,
- n_write_segs);
- for (i = 2 + n_read_segs; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-@@ -3181,6 +3225,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3199,6 +3250,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3206,6 +3267,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-@@ -3228,7 +3290,8 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+// slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3281,6 +3344,7 @@
- ut_ad(slot->reserved);
-
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3317,16 +3381,18 @@
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
- os_mutex_enter(array->mutex);
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
- /* Found an i/o request */
-
- break;
-@@ -3336,7 +3402,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3347,8 +3431,6 @@
- os_aio_simulated_wake_handler_threads(void)
- /*=======================================*/
- {
-- ulint i;
--
- if (os_aio_use_native_aio) {
- /* We do not use simulated aio: do nothing */
-
-@@ -3357,9 +3439,10 @@
-
- os_aio_recommend_sleep_for_read_threads = FALSE;
-
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ os_aio_simulated_wake_handler_thread(0);
-+ os_aio_simulated_wake_handler_thread(1);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_read_segment);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_write_segment);
- }
-
- /**************************************************************************
-@@ -3640,7 +3723,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
-@@ -3648,12 +3731,12 @@
- } else {
- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-+ (array->native_events));
- }
-
- os_mutex_enter(array->mutex);
-
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3830,10 +3913,13 @@
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3841,6 +3927,7 @@
- ibool ret;
- ulint n;
- ulint i;
-+ time_t now;
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-@@ -3853,7 +3940,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
-@@ -3875,9 +3962,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved && slot->io_already_done) {
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3897,67 +3984,57 @@
- then pick the one at the lowest offset. */
-
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-
-+ /* Find the oldest request and the request with the smallest offset */
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-- lowest_offset = slot->offset;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
-
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3965,7 +4042,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3994,6 +4072,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -4001,7 +4081,14 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -4012,6 +4099,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -4081,16 +4171,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4100,6 +4187,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-02 18:36:54.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -330,6 +332,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2228,6 +2248,10 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-+ dulint lsn_old;
-+
-+ dulint oldest_lsn;
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
-@@ -2244,6 +2268,9 @@
-
- mutex_exit(&kernel_mutex);
-
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- os_event_set(srv_sys->operational);
- loop:
- /*****************************************************************/
-@@ -2279,6 +2306,18 @@
- if (!skip_sleep) {
-
- os_thread_sleep(1000000);
-+ /*
-+ mutex_enter(&(log_sys->mutex));
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ dulint lsn = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ if (!ut_dulint_is_zero(oldest_lsn))
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old));
-+ */
- }
-
- skip_sleep = FALSE;
-@@ -2317,13 +2356,14 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2332,7 +2372,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2341,6 +2381,140 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (srv_adaptive_checkpoint == 1) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+ } else if (srv_adaptive_checkpoint == 2) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* defence line (max_checkpoint_age * 1/2) */
-+ dulint lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ ib_longlong level, bpl;
-+ buf_block_t* bpage;
-+
-+ mutex_enter(&buf_pool->mutex);
-+
-+ level = 0;
-+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-+
-+ while (bpage != NULL) {
-+ dulint oldest_modification = bpage->oldest_modification;
-+ if (!ut_dulint_is_zero(oldest_modification)) {
-+ level += log_sys->max_checkpoint_age
-+ - ut_dulint_minus(lsn, oldest_modification);
-+ }
-+ bpage = UT_LIST_GET_NEXT(flush_list, bpage);
-+ }
-+
-+ if (level) {
-+ bpl = ((ib_longlong) UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * ut_dulint_minus(lsn, lsn_old)) / level;
-+ } else {
-+ bpl = 0;
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+
-+ if (!srv_use_doublewrite_buf) {
-+ /* flush is faster than when doublewrite */
-+ bpl = (bpl * 3) / 4;
-+ }
-+
-+ if(bpl) {
-+retry_flush_batch:
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ bpl,
-+ ut_dulint_add(oldest_lsn,
-+ ut_dulint_minus(lsn,
-+ lsn_old)));
-+ if (n_pages_flushed == ULINT_UNDEFINED) {
-+ os_thread_sleep(5000);
-+ goto retry_flush_batch;
-+ }
-+ }
-+
-+ lsn_old = lsn;
-+ /*
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu, blocks to flush:%llu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old), bpl);
-+ */
-+ } else {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
-+ } else {
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2367,23 +2541,25 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2422,14 +2598,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2518,7 +2694,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2535,7 +2711,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2557,7 +2733,14 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-08 06:12:12.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-07-02 16:44:49.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-02 16:44:49.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1417,6 +1418,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7330,6 +7333,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-02 18:10:51.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,15 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
-+
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
- running with the fix disabled because MySQL 5.1 is frozen for such
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-02 18:00:04.000000000 +0900
-@@ -5086,6 +5086,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5403,6 +5413,44 @@
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 200, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. ([none], reflex, estimate)",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7644,6 +7692,38 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
-+ case OPT_INNODB_ADAPTIVE_CHECKPOINT:
-+ if (argument == disabled_my_option)
-+ srv_adaptive_checkpoint = 0;
-+ else if (! argument)
-+ srv_adaptive_checkpoint = 0;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_adaptive_checkpoint_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_adaptive_checkpoint type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_adaptive_checkpoint = (uint) ((type - 1) % 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-02 17:45:29.000000000 +0900
-@@ -489,6 +489,57 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+
-+const char *innodb_adaptive_checkpoint_names[]=
-+{
-+ "none", /* 0 */
-+ "reflex", /* 1 */
-+ "estimate", /* 2 */
-+ /* For compatibility of the older patch */
-+ "0", /* 3 ("none" + 3) */
-+ "1", /* 4 ("reflex" + 3) */
-+ "2", /* 5 ("estimate" + 3) */
-+ NullS
-+};
-+TYPELIB innodb_adaptive_checkpoint_typelib=
-+{
-+ array_elements(innodb_adaptive_checkpoint_names) - 1, "innodb_adaptive_checkpoint_typelib",
-+ innodb_adaptive_checkpoint_names, NULL
-+};
-+sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint,
-+ &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -860,6 +911,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -997,6 +1055,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -1459,6 +1527,18 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+
-+extern void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type)
-+{
-+ srv_adaptive_checkpoint %= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.h 2009-07-02 17:35:17.000000000 +0900
-@@ -31,6 +31,11 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+extern TYPELIB innodb_adaptive_checkpoint_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1153,10 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.83-b17-20090723/innodb_io_pattern.patch b/percona/5.0.83-b17-20090723/innodb_io_pattern.patch
deleted file mode 100644
index 6fc3d83..0000000
--- a/percona/5.0.83-b17-20090723/innodb_io_pattern.patch
+++ /dev/null
@@ -1,688 +0,0 @@
-diff -r d13cd248f14e include/mysql_com.h
---- a/include/mysql_com.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/include/mysql_com.h Fri Jul 03 15:41:25 2009 -0700
-@@ -121,6 +121,9 @@
- #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-+
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
-diff -r d13cd248f14e innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Fri Jul 03 15:41:20 2009 -0700
-+++ b/innobase/buf/buf0buf.c Fri Jul 03 15:41:25 2009 -0700
-@@ -654,6 +654,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1967,6 +1970,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2068,6 +2074,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2083,6 +2109,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2657,3 +2703,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r d13cd248f14e innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/innobase/include/buf0buf.h Fri Jul 03 15:41:25 2009 -0700
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r d13cd248f14e innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/innobase/include/buf0types.h Fri Jul 03 15:41:25 2009 -0700
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r d13cd248f14e innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:25 2009 -0700
-@@ -146,6 +146,11 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r d13cd248f14e innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:20 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:25 2009 -0700
-@@ -352,6 +352,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r d13cd248f14e mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Fri Jul 03 15:41:20 2009 -0700
-+++ b/mysql-test/r/information_schema.result Fri Jul 03 15:41:25 2009 -0700
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r d13cd248f14e mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Fri Jul 03 15:41:20 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Fri Jul 03 15:41:25 2009 -0700
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r d13cd248f14e mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Fri Jul 03 15:41:20 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Fri Jul 03 15:41:25 2009 -0700
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r d13cd248f14e patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Fri Jul 03 15:41:25 2009 -0700
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r d13cd248f14e sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:25 2009 -0700
-@@ -1583,6 +1583,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6548,6 +6550,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r d13cd248f14e sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:25 2009 -0700
-@@ -245,6 +245,9 @@
- extern uint srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-@@ -277,6 +280,9 @@
- bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-+
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-
- void innobase_release_temporary_latches(THD *thd);
-
-diff -r d13cd248f14e sql/lex.h
---- a/sql/lex.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/lex.h Fri Jul 03 15:41:25 2009 -0700
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r d13cd248f14e sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:25 2009 -0700
-@@ -5029,6 +5029,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5461,6 +5464,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r d13cd248f14e sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:25 2009 -0700
-@@ -546,6 +546,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -926,6 +932,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1075,6 +1084,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -3195,6 +3207,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r d13cd248f14e sql/set_var.h
---- a/sql/set_var.h Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/set_var.h Fri Jul 03 15:41:25 2009 -0700
-@@ -990,6 +990,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r d13cd248f14e sql/sql_parse.cc
---- a/sql/sql_parse.cc Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/sql_parse.cc Fri Jul 03 15:41:25 2009 -0700
-@@ -8105,6 +8105,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r d13cd248f14e sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:41:25 2009 -0700
-@@ -32,6 +32,17 @@
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
- #endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
-@@ -4108,6 +4119,67 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4914,6 +4986,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5089,6 +5174,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r d13cd248f14e sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Fri Jul 03 15:41:20 2009 -0700
-+++ b/sql/sql_yacc.yy Fri Jul 03 15:41:25 2009 -0700
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8500,6 +8501,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9552,6 +9554,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.83-b17-20090723/innodb_io_tune.patch b/percona/5.0.83-b17-20090723/innodb_io_tune.patch
deleted file mode 100644
index 3953e1d..0000000
--- a/percona/5.0.83-b17-20090723/innodb_io_tune.patch
+++ /dev/null
@@ -1,1823 +0,0 @@
-diff -r 322370200e6a innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/os0file.h Mon Nov 03 05:08:52 2008 -0800
-@@ -532,21 +532,16 @@
- FALSE otherwise */
- const char* path); /* in: path name */
- /****************************************************************************
--Initializes the asynchronous io system. Creates separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
-+Initializes the asynchronous io system. */
-
--void
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ /* out: number of AIO handler threads */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per IO array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -r 322370200e6a innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-@@ -87,6 +87,14 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-+
-+/* Number of IO operations per second the server can do */
-+extern ulint srv_io_capacity;
-+
-+/* Flush dirty pages when below max dirty percent */
-+extern ibool srv_extra_dirty_writes;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -252,6 +260,24 @@
-
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-+
-+/* Number of IO operations read/write done for all threads */
-+extern ulint os_aio_read_requests;
-+extern ulint os_aio_write_requests;
-+
-+/* Number of pages read/written done for all threads */
-+extern ulint os_aio_pages_read;
-+extern ulint os_aio_pages_written;
-+
-+/* time usec used to perform read/write for all threads */
-+extern ib_longlong os_aio_read_time;
-+extern ib_longlong os_aio_write_time;
-+
-+extern ulint inno_pending_normal_aio_reads;
-+extern ulint inno_pending_normal_aio_writes;
-+extern ulint inno_pending_ibuf_aio_reads;
-+extern ulint inno_pending_log_ios;
-+extern ulint inno_pending_sync_ios;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-diff -r 322370200e6a innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:08:52 2008 -0800
-@@ -1537,6 +1537,30 @@
-
- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
- LOG_WRITE_FROM_BACKGROUND_SYNC);
-+}
-+
-+/********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*==========================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
- }
-
- /********************************************************************
-diff -r 322370200e6a innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/os/os0file.c Mon Nov 03 05:08:52 2008 -0800
-@@ -22,6 +22,8 @@
- #include <errno.h>
- #endif /* UNIV_HOTBACKUP */
-
-+extern long innobase_max_merged_io;
-+
- #undef HAVE_FDATASYNC
-
- #ifdef POSIX_ASYNC_IO
-@@ -63,6 +65,28 @@
- ibool os_aio_use_native_aio = FALSE;
-
- ibool os_aio_print_debug = FALSE;
-+
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-@@ -72,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -82,11 +108,6 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -116,9 +137,6 @@
- in this array */
- ulint n_slots; /* Total number of slots in the aio array.
- This must be divisible by n_threads. */
-- ulint n_segments;/* Number of segments in the aio array of
-- pending aio requests. A thread can wait
-- separately for any one of the segments. */
- ulint n_reserved;/* Number of reserved slots in the
- aio array outside the ibuf segment */
- os_aio_slot_t* slots; /* Pointer to the slots in the array */
-@@ -134,6 +152,17 @@
-
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-+
-+/* Number of threads for reading and writing. */
-+ulint os_aio_read_threads = 0;
-+ulint os_aio_write_threads = 0;
-+
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
-@@ -143,11 +172,39 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
-+/* Count pages read and written per thread */
-+static ulint os_aio_thread_io_reads[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_io_writes[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO operations done. One request can be for N pages. */
-+static ulint os_aio_thread_io_requests[SRV_MAX_N_IO_THREADS];
-+
-+/* usecs spent blocked on an IO request */
-+static double os_aio_thread_io_wait[SRV_MAX_N_IO_THREADS];
-+/* max usecs spent blocked on an IO request */
-+static double os_aio_thread_max_io_wait[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO global segments. An IO handler thread is created for each
-+global segment, except for the segment associated with os_aio_sync_array.
-+Several segments can be associated with os_aio_{read,write}_array. One
-+segment is created for each of the other arrays. This is also the number
-+of valid entries in srv_io_thread_reads, srv_io_thread_writes,
-+srv_io_thread_op_info, srv_io_thread_function and os_aio_segment_wait_events. */
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
--/* If the following is TRUE, read i/o handler threads try to
--wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+/* Set to TRUE to temporarily block reads from being scheduled while a batch
-+of read requests is added to allow them to be merged by the IO handler thread
-+if they are adjacent. Declared volatile because we don't want this to be
-+read from a register in a loop when another thread may change the value in
-+memory.
-+*/
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -166,6 +223,19 @@
- ulint os_file_n_pending_pwrites = 0;
- ulint os_n_pending_writes = 0;
- ulint os_n_pending_reads = 0;
-+
-+/* TODO -- does InnoDB provide a portable method for this? */
-+static double time_usecs() {
-+#ifdef __WIN__
-+ return 0.0;
-+#else
-+ struct timeval tv;
-+ if (gettimeofday(&tv, NULL))
-+ return 0;
-+ else
-+ return tv.tv_sec * 1000000.0 + tv.tv_usec;
-+#endif
-+}
-
- /***************************************************************************
- Gets the operating system version. Currently works only on Windows. */
-@@ -1351,6 +1421,8 @@
- /* We disable OS caching (O_DIRECT) only on data files */
- if (type != OS_LOG_FILE
- && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
-+
-+ fprintf(stderr, "Using O_DIRECT for file %s\n", name);
-
- os_file_set_nocache(file, name, mode_str);
- }
-@@ -1798,6 +1870,32 @@
- #endif /* __WIN__ */
- }
-
-+#ifndef __WIN__
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fsync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fsync(file);
-+}
-+
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fdatasync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fdatasync(file);
-+}
-+#endif
-+
- /***************************************************************************
- Flushes the write buffers of a given file to the disk. */
-
-@@ -1855,21 +1953,21 @@
- /* If we are not on an operating system that supports this,
- then fall back to a plain fsync. */
-
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- } else {
- ret = fcntl(file, F_FULLFSYNC, NULL);
-
- if (ret) {
- /* If we are not on a file system that supports this,
- then fall back to a plain fsync. */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- }
- }
- #elif HAVE_FDATASYNC
-- ret = fdatasync(file);
-+ ret = os_maybe_fdatasync(file);
- #else
- /* fprintf(stderr, "Flushing to file %p\n", file); */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- #endif
- os_n_fsyncs++;
-
-@@ -2298,6 +2396,9 @@
-
- return(TRUE);
- }
-+ fprintf(stderr,
-+"InnoDB: error: os_file_pread wanted %lu and got %lu.\n",
-+ (ulint) n, (ulint) ret);
- #endif
- #ifdef __WIN__
- error_handling:
-@@ -2784,9 +2885,8 @@
- os_aio_array_create(
- /*================*/
- /* out, own: aio array */
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments) /* in: number of segments in the aio array */
-+ ulint n) /* in: maximum number of pending aio operations
-+ allowed */
- {
- os_aio_array_t* array;
- ulint i;
-@@ -2795,7 +2895,6 @@
- OVERLAPPED* over;
- #endif
- ut_a(n > 0);
-- ut_a(n_segments > 0);
-
- array = ut_malloc(sizeof(os_aio_array_t));
-
-@@ -2806,7 +2905,6 @@
- os_event_set(array->is_empty);
-
- array->n_slots = n;
-- array->n_segments = n_segments;
- array->n_reserved = 0;
- array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
- #ifdef __WIN__
-@@ -2833,70 +2931,75 @@
-
- /****************************************************************************
- Initializes the asynchronous io system. Calls also os_io_init_simple.
--Creates a separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
--
--void
-+Creates an aio array for each of non-ibuf read, non-ibuf write, ibuf IO,
-+log IO, and synchronous IO. The caller must create i/o handler thread for all
-+but the synchronous aio array. Multiple threads can access the same array for
-+the non-ibuf read (prefetch) and write (flush dirty buffer pages) arrays.
-+Return the number of AIO handler threads. */
-+
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
-- ulint n_read_segs;
-- ulint n_write_segs;
-- ulint n_per_seg;
-- ulint i;
-+ ulint i;
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-- ut_ad(n % n_segments == 0);
-- ut_ad(n_segments >= 4);
-+ ut_a(ios_per_array >= OS_AIO_N_PENDING_IOS_PER_THREAD);
-+ ut_a(n_read_threads >= 1 && n_read_threads <= 64);
-+ ut_a(n_write_threads >= 1 && n_write_threads <= 64);
-+ ut_a(n_segments < SRV_MAX_N_IO_THREADS);
-
- os_io_init_simple();
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-- }
--
-- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
--
-- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
--
-- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_thread_io_reads[i] = 0;
-+ os_aio_thread_io_writes[i] = 0;
-+ os_aio_thread_io_requests[i] = 0;
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
-+ os_aio_thread_io_wait[i] = 0;
-+ os_aio_thread_max_io_wait[i] = 0;
-+ }
-+
-+ os_aio_read_threads = n_read_threads;
-+ os_aio_write_threads = n_write_threads;
-+ os_aio_first_write_segment = os_aio_first_read_segment + os_aio_read_threads;
-+
-+ fprintf(stderr,
-+ "InnoDB: ios_per_array %lu read threads %lu write threads %lu\n",
-+ ios_per_array, os_aio_read_threads, os_aio_write_threads);
-+
-+ os_aio_ibuf_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[0] = "insert buffer thread";
-
-- os_aio_log_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_log_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-- n_read_segs);
-- for (i = 2; i < 2 + n_read_segs; i++) {
-+ os_aio_read_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_read_segment; i < os_aio_first_write_segment; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "read thread";
-- }
--
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-- n_write_segs);
-- for (i = 2 + n_read_segs; i < n_segments; i++) {
-+ srv_io_thread_function[i] = "read thread";
-+ }
-+
-+ os_aio_write_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_write_segment; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "write thread";
-- }
--
-- os_aio_sync_array = os_aio_array_create(n_slots_sync, 1);
--
-- os_aio_n_segments = n_segments;
-+ srv_io_thread_function[i] = "write thread";
-+ }
-+
-+ os_aio_sync_array = os_aio_array_create(n_slots_sync);
-+
-+ os_aio_n_segments = 2 + os_aio_read_threads + os_aio_write_threads;
-
- os_aio_validate();
-
-@@ -2924,6 +3027,7 @@
-
- pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
- #endif
-+ return os_aio_n_segments;
- }
-
- #ifdef WIN_ASYNC_IO
-@@ -2981,77 +3085,32 @@
- os_event_wait(os_aio_write_array->is_empty);
- }
-
--/**************************************************************************
--Calculates segment number for a slot. */
--static
--ulint
--os_aio_get_segment_no_from_slot(
--/*============================*/
-- /* out: segment number (which is the number
-- used by, for example, i/o-handler threads) */
-- os_aio_array_t* array, /* in: aio wait array */
-- os_aio_slot_t* slot) /* in: slot in this array */
--{
-- ulint segment;
-- ulint seg_len;
--
-- if (array == os_aio_ibuf_array) {
-- segment = 0;
--
-- } else if (array == os_aio_log_array) {
-- segment = 1;
--
-- } else if (array == os_aio_read_array) {
-- seg_len = os_aio_read_array->n_slots /
-- os_aio_read_array->n_segments;
--
-- segment = 2 + slot->pos / seg_len;
-- } else {
-- ut_a(array == os_aio_write_array);
-- seg_len = os_aio_write_array->n_slots /
-- os_aio_write_array->n_segments;
--
-- segment = os_aio_read_array->n_segments + 2
-- + slot->pos / seg_len;
-- }
--
-- return(segment);
--}
--
--/**************************************************************************
--Calculates local segment number and aio array from global segment number. */
--static
--ulint
--os_aio_get_array_and_local_segment(
-+
-+/**************************************************************************
-+Calculates aio array from global segment number. */
-+static
-+os_aio_array_t*
-+os_aio_get_array(
- /*===============================*/
-- /* out: local segment number within
-- the aio array */
-- os_aio_array_t** array, /* out: aio wait array */
-+ /* out: aio wait array */
- ulint global_segment)/* in: global segment number */
- {
-- ulint segment;
-
- ut_a(global_segment < os_aio_n_segments);
-
- if (global_segment == 0) {
-- *array = os_aio_ibuf_array;
-- segment = 0;
-+ return os_aio_ibuf_array;
-
- } else if (global_segment == 1) {
-- *array = os_aio_log_array;
-- segment = 0;
--
-- } else if (global_segment < os_aio_read_array->n_segments + 2) {
-- *array = os_aio_read_array;
--
-- segment = global_segment - 2;
-- } else {
-- *array = os_aio_write_array;
--
-- segment = global_segment - (os_aio_read_array->n_segments + 2);
-- }
--
-- return(segment);
-+ return os_aio_log_array;
-+
-+ } else if (global_segment < os_aio_first_write_segment) {
-+ return os_aio_read_array;
-+
-+ } else {
-+ return os_aio_write_array;
-+
-+ }
- }
-
- /***********************************************************************
-@@ -3160,7 +3219,7 @@
-
- os_aio_simulated_wake_handler_threads();
- }
--
-+
- os_event_wait(array->not_full);
-
- goto loop;
-@@ -3173,7 +3232,7 @@
- break;
- }
- }
--
-+ ut_a(i < array->n_slots);
- array->n_reserved++;
-
- if (array->n_reserved == 1) {
-@@ -3195,7 +3254,7 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3246,8 +3305,9 @@
- os_mutex_enter(array->mutex);
-
- ut_ad(slot->reserved);
--
-+
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3266,36 +3326,40 @@
- }
-
- /**************************************************************************
--Wakes up a simulated aio i/o-handler thread if it has something to do. */
-+Wake up the simulated aio i/o-handler threads for a given array if there
-+is work to do. */
- static
- void
- os_aio_simulated_wake_handler_thread(
- /*=================================*/
-- ulint global_segment) /* in: the number of the segment in the aio
-- arrays */
--{
-- os_aio_array_t* array;
-- os_aio_slot_t* slot;
-- ulint segment;
-+ os_aio_array_t* array) /* in: aio array for which wakeup is done */
-+{
-+ os_aio_slot_t* slot;
- ulint n;
- ulint i;
-
- ut_ad(!os_aio_use_native_aio);
-
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
--
-- os_mutex_enter(array->mutex);
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- /* Found an i/o request */
--
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-+
-+ os_mutex_enter(array->mutex);
-+
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i );
-+
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
-+ /* Found an i/o request
-+ /* OS_AIO_NOT_ISSUED means the read or write request has
-+ * yet to be done. OS_AIO_DONE means the request has been
-+ * done but it was part of a set of requests merged into
-+ * one read or write call and was not the first block in
-+ * the request, so the handling of the IO completion for
-+ * that block has not been done. */
-+
- break;
- }
- }
-@@ -3303,7 +3367,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3320,13 +3402,14 @@
- /* We do not use simulated aio: do nothing */
-
- return;
-- }
--
-- os_aio_recommend_sleep_for_read_threads = FALSE;
--
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ }
-+
-+ os_aio_recommend_sleep_for_read_threads = FALSE;
-+
-+ os_aio_simulated_wake_handler_thread(os_aio_ibuf_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_log_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_read_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_write_array);
- }
-
- /**************************************************************************
-@@ -3339,18 +3422,13 @@
- os_aio_simulated_put_read_threads_to_sleep(void)
- /*============================================*/
- {
-- os_aio_array_t* array;
- ulint g;
-
-+ /* TODO(mcallaghan): provide similar function for write? */
- os_aio_recommend_sleep_for_read_threads = TRUE;
-
-- for (g = 0; g < os_aio_n_segments; g++) {
-- os_aio_get_array_and_local_segment(&array, g);
--
-- if (array == os_aio_read_array) {
--
-- os_event_reset(os_aio_segment_wait_events[g]);
-- }
-+ for (g = os_aio_first_read_segment; g < os_aio_first_write_segment; g++) {
-+ os_event_reset(os_aio_segment_wait_events[g]);
- }
- }
-
-@@ -3480,8 +3558,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else if (type == OS_FILE_WRITE) {
-@@ -3497,8 +3574,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else {
-@@ -3561,7 +3637,7 @@
- os_aio_windows_handle(
- /*==================*/
- /* out: TRUE if the aio operation succeeded */
-- ulint segment, /* in: the number of the segment in the aio
-+ ulint global_segment, /* in: the number of the segment in the aio
- arrays to wait for; segment 0 is the ibuf
- i/o thread, segment 1 the log i/o thread,
- then follow the non-ibuf read threads, and as
-@@ -3579,7 +3655,6 @@
- void** message2,
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
-- ulint orig_seg = segment;
- os_aio_array_t* array;
- os_aio_slot_t* slot;
- ulint n;
-@@ -3588,33 +3663,30 @@
- BOOL ret;
- DWORD len;
-
-- if (segment == ULINT_UNDEFINED) {
-+ if (global_segment == ULINT_UNDEFINED) {
- array = os_aio_sync_array;
-- segment = 0;
-- } else {
-- segment = os_aio_get_array_and_local_segment(&array, segment);
-+ } else {
-+ array = os_aio_get_array(global_segment);
- }
-
- /* NOTE! We only access constant fields in os_aio_array. Therefore
- we do not have to acquire the protecting mutex yet */
-
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
-+
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
- i = pos;
- } else {
-- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
-- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-- }
--
-- os_mutex_enter(array->mutex);
--
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ srv_set_io_thread_op_info(global_segment, "wait Windows aio");
-+ i = os_event_wait_multiple(n, (array->native_events));
-+ }
-+
-+ os_mutex_enter(array->mutex);
-+
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3787,14 +3859,16 @@
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
- os_aio_array_t* array;
-- ulint segment;
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3802,8 +3876,10 @@
- ibool ret;
- ulint n;
- ulint i;
--
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-+
-+ double start_usecs, stop_usecs, elapsed_usecs;
-+ time_t now;
-+ array = os_aio_get_array(global_segment);
-
- restart:
- /* NOTE! We only access constant fields in os_aio_array. Therefore
-@@ -3812,11 +3888,10 @@
- srv_set_io_thread_op_info(global_segment,
- "looking for i/o requests (a)");
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
-+
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-
- if (array == os_aio_read_array
- && os_aio_recommend_sleep_for_read_threads) {
-@@ -3836,9 +3911,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved && slot->io_already_done) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3846,79 +3921,66 @@
- }
-
- ret = TRUE;
--
-+
- goto slot_io_done;
- }
- }
-
-- n_consecutive = 0;
--
-- /* If there are at least 2 seconds old requests, then pick the oldest
-- one to prevent starvation. If several requests have the same age,
-- then pick the one at the lowest offset. */
--
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
--
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-+
-+ /* Find the oldest request and the request with the smallest offset */
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-+
-+ /* If there are at least 2 seconds old requests, then pick the oldest
-+ one to prevent starvation. If several requests have the same age,
-+ then pick the one at the lowest offset. */
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
-+ }
-+
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
-+ /* Found an i/o request */
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
--
-- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-- lowest_offset = slot->offset;
-- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3926,7 +3988,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3935,7 +3998,8 @@
-
- slot = slot2;
-
-- if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE) {
-+ if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE
-+ && n_consecutive < innobase_max_merged_io) {
-
- goto consecutive_loop;
- } else {
-@@ -3955,6 +4019,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -3962,7 +4028,16 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -3973,6 +4048,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -3998,6 +4076,7 @@
-
- /* Do the i/o with ordinary, synchronous i/o functions: */
- if (slot->type == OS_FILE_WRITE) {
-+ os_aio_thread_io_writes[global_segment] += n_consecutive;
- if (array == os_aio_write_array) {
- if ((total_len % UNIV_PAGE_SIZE != 0)
- || (slot->offset % UNIV_PAGE_SIZE != 0)) {
-@@ -4012,16 +4091,34 @@
- os_file_check_page_trailers(combined_buf, total_len);
- }
-
-+ start_usecs = time_usecs();
- ret = os_file_write(slot->name, slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
--
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
- if (array == os_aio_write_array) {
- os_file_check_page_trailers(combined_buf, total_len);
- }
-- } else {
-+ os_aio_write_requests++;
-+ os_aio_pages_written += n_consecutive;
-+ os_aio_write_time += (ib_longlong)elapsed_usecs;
-+ } else {
-+ start_usecs = time_usecs();
-+ os_aio_thread_io_reads[global_segment] += n_consecutive;
- ret = os_file_read(slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
-- }
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
-+ os_aio_read_requests++;
-+ os_aio_pages_read += n_consecutive;
-+ os_aio_read_time += (ib_longlong)elapsed_usecs;
-+ }
-+ if (elapsed_usecs > os_aio_thread_max_io_wait[global_segment])
-+ os_aio_thread_max_io_wait[global_segment] = elapsed_usecs;
-+ os_aio_thread_io_wait[global_segment] += elapsed_usecs;
-+ os_aio_thread_io_requests[global_segment]++;
-
- ut_a(ret);
- srv_set_io_thread_op_info(global_segment, "file i/o done");
-@@ -4042,16 +4139,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4061,6 +4155,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-@@ -4070,7 +4166,8 @@
- os_mutex_exit(array->mutex);
-
- os_aio_array_free_slot(array, slot);
--
-+ srv_set_io_thread_op_info(global_segment, "exited handler");
-+
- return(ret);
-
- wait_for_io:
-@@ -4115,7 +4212,6 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-@@ -4165,11 +4261,20 @@
- double time_elapsed;
- double avg_bytes_read;
- ulint i;
--
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-- fprintf(file, "I/O thread %lu state: %s (%s)", (ulong) i,
-- srv_io_thread_op_info[i],
-- srv_io_thread_function[i]);
-+ ulint num_issued, num_done, num_claimed;
-+
-+ if (file) {
-+ for (i = 0; i < os_aio_n_segments; i++) {
-+ fprintf(file,
-+ "I/O thread %lu state: %s (%s) reads %lu writes %lu "
-+ "requests %lu io secs %lf io msecs/request %lf max_io_wait %lf",
-+ i, srv_io_thread_op_info[i], srv_io_thread_function[i],
-+ os_aio_thread_io_reads[i], os_aio_thread_io_writes[i],
-+ os_aio_thread_io_requests[i],
-+ os_aio_thread_io_wait[i] / 1000000.0,
-+ os_aio_thread_io_requests[i] ?
-+ os_aio_thread_io_wait[i] / os_aio_thread_io_requests[i] / 1000.0 : 0.0,
-+ os_aio_thread_max_io_wait[i] / 1000.0);
-
- #ifndef __WIN__
- if (os_aio_segment_wait_events[i]->is_set) {
-@@ -4181,6 +4286,7 @@
- }
-
- fputs("Pending normal aio reads:", file);
-+ } // if (file)
-
- array = os_aio_read_array;
- loop:
-@@ -4189,14 +4295,23 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- n_reserved = 0;
-+ num_done = num_issued = num_claimed = 0;
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
- if (slot->reserved) {
-+ if (slot->status == OS_AIO_ISSUED)
-+ num_issued++;
-+ else if (slot->status == OS_AIO_DONE)
-+ num_done++;
-+ else {
-+ ut_ad(slot->status == OS_AIO_CLAIMED);
-+ num_claimed++;
-+ }
-+
- n_reserved++;
- /* fprintf(stderr, "Reserved slot, messages %p %p\n",
- slot->message1, slot->message2); */
-@@ -4206,42 +4321,56 @@
-
- ut_a(array->n_reserved == n_reserved);
-
-- fprintf(file, " %lu", (ulong) n_reserved);
--
-+ if (file) fprintf(file, " %lu", (ulong) n_reserved);
-+
- os_mutex_exit(array->mutex);
-
- if (array == os_aio_read_array) {
-- fputs(", aio writes:", file);
--
-+ inno_pending_normal_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", aio writes:", file);
- array = os_aio_write_array;
-
- goto loop;
- }
-
- if (array == os_aio_write_array) {
-- fputs(",\n ibuf aio reads:", file);
-+ inno_pending_normal_aio_writes = (ulong) n_reserved;
-+ if (file) fputs(",\n ibuf aio reads:", file);
- array = os_aio_ibuf_array;
-
- goto loop;
- }
-
- if (array == os_aio_ibuf_array) {
-- fputs(", log i/o's:", file);
-+ inno_pending_ibuf_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", log i/o's:", file);
- array = os_aio_log_array;
-
- goto loop;
- }
-
- if (array == os_aio_log_array) {
-- fputs(", sync i/o's:", file);
-+ inno_pending_log_ios = (ulong) n_reserved;
-+ if (file) fputs(", sync i/o's:", file);
- array = os_aio_sync_array;
-
- goto loop;
- }
-
-- putc('\n', file);
-+ if (array == os_aio_sync_array) {
-+ inno_pending_sync_ios = (ulong) n_reserved;
-+ }
-+
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time, os_last_printout);
-+
-+ if (file) {
-+ putc('\n', file);
-+ fprintf(file,
-+ "Summary of background IO slot status: %lu issued, "
-+ "%lu done, %lu claimed, sleep set %d\n",
-+ num_issued, num_done, num_claimed,
-+ os_aio_recommend_sleep_for_read_threads);
-
- fprintf(file,
- "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
-@@ -4274,6 +4403,7 @@
- / time_elapsed,
- (os_n_fsyncs - os_n_fsyncs_old)
- / time_elapsed);
-+ } // if (file)
-
- os_n_file_reads_old = os_n_file_reads;
- os_n_file_writes_old = os_n_file_writes;
-diff -r 322370200e6a innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-@@ -164,7 +164,17 @@
- ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
- ulint srv_lock_table_size = ULINT_MAX;
-
-+ulint srv_io_capacity = ULINT_MAX; /* Number of IO operations per
-+ second the server can do */
-+
-+ibool srv_extra_dirty_writes = TRUE; /* Write dirty pages to disk when pct
-+ dirty < max dirty pct */
-+
-+/* Deprecated by srv_n_{read,write}_io_threads */
- ulint srv_n_file_io_threads = ULINT_MAX;
-+/* Number of background IO threads for read and write requests */
-+ulint srv_n_read_io_threads = ULINT_MAX;
-+ulint srv_n_write_io_threads = ULINT_MAX;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -238,6 +248,24 @@
-
- /* variable to count the number of random read-aheads */
- ulint srv_read_ahead_rnd = 0;
-+
-+/* Number of IO operations read/write done for all threads */
-+ulint os_aio_read_requests = 0;
-+ulint os_aio_write_requests = 0;
-+
-+/* Number of pages read/written done for all threads */
-+ulint os_aio_pages_read = 0;
-+ulint os_aio_pages_written = 0;
-+
-+/* time usec used to perform read/write for all threads */
-+ib_longlong os_aio_read_time = 0;
-+ib_longlong os_aio_write_time = 0;
-+
-+ulint inno_pending_normal_aio_reads = 0;
-+ulint inno_pending_normal_aio_writes = 0;
-+ulint inno_pending_ibuf_aio_reads = 0;
-+ulint inno_pending_log_ios = 0;
-+ulint inno_pending_sync_ios = 0;
-
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-@@ -413,6 +441,23 @@
-
- ulint srv_main_thread_process_no = 0;
- ulint srv_main_thread_id = 0;
-+
-+// The following count work done by srv_master_thread.
-+
-+// Iterations by the 'once per second' loop.
-+ulint srv_main_1_second_loops = 0;
-+// Calls to sleep by the 'once per second' loop.
-+ulint srv_main_sleeps = 0;
-+// Iterations by the 'once per 10 seconds' loop.
-+ulint srv_main_10_second_loops = 0;
-+// Iterations of the loop bounded by the 'background_loop' label.
-+ulint srv_main_background_loops = 0;
-+// Iterations of the loop bounded by the 'flush_loop' label.
-+ulint srv_main_flush_loops = 0;
-+// Calls to log_buffer_flush_to_disk.
-+ulint srv_sync_flush = 0;
-+// Calls to log_buffer_flush_maybe_sync.
-+ulint srv_async_flush = 0;
-
- /*
- IMPLEMENTATION OF THE SERVER MAIN PROGRAM
-@@ -2170,7 +2215,12 @@
- }
-
- /*************************************************************************
--The master thread controlling the server. */
-+Returns the number of IO operations that is X percent of the capacity.
-+
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity.
-+*/
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-
- #ifndef __WIN__
- void*
-@@ -2199,11 +2249,15 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
- #endif
-+ fprintf(stderr, "InnoDB master thread running with io_capacity %lu\n",
-+ srv_io_capacity);
-+
- srv_main_thread_process_no = os_proc_get_number();
- srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
-
-@@ -2275,26 +2329,28 @@
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-+ srv_sync_flush++;
-
- srv_main_thread_op_info = "making checkpoint";
- log_free_check();
-
-- /* If there were less than 5 i/os during the
-- one second sleep, we assume that there is free
-- disk i/o capacity available, and it makes sense to
-- do an insert buffer merge. */
-+ /* If i/os during one second sleep were less than 5% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to do an insert buffer merge. */
-
- n_pend_ios = buf_get_n_pending_ios()
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2303,7 +2359,8 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2325,36 +2382,47 @@
-
- /* ---- We perform the following code approximately once per
- 10 seconds when there is database activity */
-+ srv_main_10_second_loops++;
-
- #ifdef MEM_PERIODIC_CHECK
- /* Check magic numbers of every allocated mem block once in 10
- seconds */
- mem_validate_all_blocks();
- #endif
-- /* If there were less than 200 i/os during the 10 second period,
-- we assume that there is free disk i/o capacity available, and it
-- makes sense to flush 100 pages. */
-+ /* If i/os during the 10 second period were less than 200% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to flush srv_io_capacity pages.
-+
-+ Note that this is done regardless of the fraction of dirty
-+ pages relative to the max requested by the user. The one second
-+ loop above requests writes for that case. The writes done here
-+ are not required, and may be disabled. */
-
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (srv_extra_dirty_writes &&
-+ n_pend_ios < PCT_IO(3) && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2378,8 +2446,9 @@
- if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2393,14 +2462,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2434,7 +2503,7 @@
-
- /* The server has been quiet for a while: start running background
- operations */
--
-+ srv_main_background_loops++;
- srv_main_thread_op_info = "doing background drop tables";
-
- n_tables_to_drop = row_drop_tables_for_mysql_in_background();
-@@ -2472,6 +2541,7 @@
-
- log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2487,9 +2557,13 @@
- srv_main_thread_op_info = "doing insert buffer merge";
-
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
-- n_bytes_merged = 0;
-+ n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ /* This should do an amount of IO similar to the number of
-+ * dirty pages that will be flushed in the call to
-+ * buf_flush_batch below. Otherwise, the system favors
-+ * clean pages over cleanup throughput. */
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2503,10 +2577,11 @@
-
- flush_loop:
- srv_main_thread_op_info = "flushing buffer pool pages";
-+ srv_main_flush_loops++;
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2528,7 +2603,17 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ srv_main_thread_op_info = (char*) "flushing log";
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ srv_sync_flush++;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -r 322370200e6a innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0start.c Mon Nov 03 05:08:52 2008 -0800
-@@ -973,6 +973,7 @@
- ulint i;
- ibool srv_file_per_table_original_value = srv_file_per_table;
- mtr_t mtr;
-+ ulint n_threads;
- #ifdef HAVE_DARWIN_THREADS
- # ifdef F_FULLFSYNC
- /* This executable has been compiled on Mac OS X 10.3 or later.
-@@ -1206,24 +1207,32 @@
- }
-
- /* Restrict the maximum number of file i/o threads */
-- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
--
-- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ if ((srv_n_read_io_threads + srv_n_write_io_threads) > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many read(%d) or write(%d) IO threads, max is %d\n",
-+ srv_n_read_io_threads, srv_n_write_io_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- if (!os_aio_use_native_aio) {
-- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /* More than 4 threads are now supported. */
-+ n_threads = os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ } else {
-+ /* Might need more slots here. Alas, I don't do windows. */
-+ n_threads = os_aio_init(SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ }
-
-- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-- } else {
-- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ if (n_threads > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many IO threads(%d), max is %d\n",
-+ n_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- fil_init(srv_max_n_open_files);
-@@ -1259,11 +1268,11 @@
-
- /* Create i/o-handler threads: */
-
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-+ for (i = 0; i < n_threads; i++) {
- n[i] = i;
-
- os_thread_create(io_handler_thread, n + i, thread_ids + i);
-- }
-+ }
-
- #ifdef UNIV_LOG_ARCHIVE
- if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
-diff -r 322370200e6a patch_info/innodb_io_tune.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_tune.info Mon Nov 03 05:08:52 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_io_tune.patch
-+Name=Tune InnoDB IO settings
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
-diff -r 322370200e6a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -147,7 +147,7 @@
- innobase_additional_mem_pool_size, innobase_file_io_threads,
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
--
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -175,6 +175,23 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+
-+/* Max number of IO requests merged to perform large IO in background
-+ IO threads.
-+*/
-+long innobase_max_merged_io = 64;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+long innobase_min_status_update_time_interval = 30;
-+
-+
-+/* Default number of IO per second supported by server. Tunes background
-+ IO rate
-+*/
-+long innobase_io_capacity = 100;
-+
-+/* Write dirty pages when pct dirty is less than max pct dirty */
-+my_bool innobase_extra_dirty_writes = TRUE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1372,7 +1389,11 @@
-
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
-+ srv_io_capacity = (ulint) innobase_io_capacity;
-+ srv_extra_dirty_writes = (ibool) innobase_extra_dirty_writes;
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -r 322370200e6a sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-@@ -197,6 +197,7 @@
-
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
-+extern long innobase_max_merged_io;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -205,10 +206,14 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_force_recovery;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
- extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
- extern char *innobase_unix_file_flush_method;
-+extern long innobase_io_capacity;
-+extern my_bool innobase_extra_dirty_writes;
-+
- /* The following variables have to be my_bool for SHOW VARIABLES to work */
- extern my_bool innobase_log_archive,
- innobase_use_doublewrite,
-diff -r 322370200e6a sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -4932,6 +4932,11 @@
- OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_MAX_MERGED_IO,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_EXTRA_DIRTY_WRITES,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
-@@ -5302,6 +5307,25 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_max_merged_io", OPT_INNODB_MAX_MERGED_IO,
-+ "Max number of IO requests merged to issue large IO from background IO threads.",
-+ (gptr*) &innobase_max_merged_io,
-+ (gptr*) &innobase_max_merged_io, 0, GET_LONG, REQUIRED_ARG, 64, 1, 64, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.", (gptr*) &innobase_read_io_threads,
-+ (gptr*) &innobase_read_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.", (gptr*) &innobase_write_io_threads,
-+ (gptr*) &innobase_write_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &innobase_io_capacity,
-+ (gptr*) &innobase_io_capacity, 0, GET_LONG,
-+ REQUIRED_ARG, 100, 100, 999999999, 0, 1, 0},
-+ {"innodb_extra_dirty_writes", OPT_INNODB_EXTRA_DIRTY_WRITES,
-+ "When set, flush dirty buffer pages when dirty pct is less than max dirty pct. ",
-+ (gptr*) &innobase_extra_dirty_writes, (gptr*) &innobase_extra_dirty_writes,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 322370200e6a sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -919,12 +919,14 @@
- {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
- {"innodb_adaptive_hash_index", (char*) &innobase_adaptive_hash_index, SHOW_MY_BOOL},
- {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
-+ {"innodb_extra_dirty_writes", (char*) &innobase_extra_dirty_writes, SHOW_MY_BOOL},
- {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
-+ {"innodb_io_capacity", (char*) &innobase_io_capacity, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
- {"innodb_locks_unsafe_for_binlog", (char*) &innobase_locks_unsafe_for_binlog, SHOW_MY_BOOL},
- {"innodb_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
-@@ -943,6 +945,9 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
-+ {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090723/innodb_locks_held.patch b/percona/5.0.83-b17-20090723/innodb_locks_held.patch
deleted file mode 100644
index 062fa47..0000000
--- a/percona/5.0.83-b17-20090723/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1711,24 +1713,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1822,6 +1806,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r e9fb5b8bcf78 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -825,6 +825,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -942,6 +944,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r e9fb5b8bcf78 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
-@@ -243,6 +243,8 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-diff -r e9fb5b8bcf78 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -5016,6 +5016,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5364,6 +5366,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r e9fb5b8bcf78 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -527,6 +527,12 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -906,6 +912,8 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1023,6 +1031,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.83-b17-20090723/innodb_rw_lock.patch b/percona/5.0.83-b17-20090723/innodb_rw_lock.patch
deleted file mode 100644
index b4a1a79..0000000
--- a/percona/5.0.83-b17-20090723/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(btr_search_latch.writer_count == 0);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.83-b17-20090723/innodb_show_bp.patch b/percona/5.0.83-b17-20090723/innodb_show_bp.patch
deleted file mode 100644
index a56ae9a..0000000
--- a/percona/5.0.83-b17-20090723/innodb_show_bp.patch
+++ /dev/null
@@ -1,447 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,13 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.83-b17-20090723/innodb_show_hashed_memory.patch b/percona/5.0.83-b17-20090723/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.83-b17-20090723/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.83-b17-20090723/innodb_show_hashed_memory_standalone.patch b/percona/5.0.83-b17-20090723/innodb_show_hashed_memory_standalone.patch
deleted file mode 100644
index bf8f6b4..0000000
--- a/percona/5.0.83-b17-20090723/innodb_show_hashed_memory_standalone.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,80 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes());
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.83-b17-20090723/innodb_split_buf_pool_mutex.patch b/percona/5.0.83-b17-20090723/innodb_split_buf_pool_mutex.patch
deleted file mode 100644
index 7fa7ac0..0000000
--- a/percona/5.0.83-b17-20090723/innodb_split_buf_pool_mutex.patch
+++ /dev/null
@@ -1,1870 +0,0 @@
-diff -r 7ac364cc9b41 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0buf.c Fri Jul 03 15:41:57 2009 -0700
-@@ -549,6 +549,17 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_BUF_LRU_LIST);
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_BUF_PAGE_HASH);
-+ mutex_create(&(buf_pool->free_mutex));
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_BUF_FREE_LIST);
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_BUF_FLUSH_LIST);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +735,8 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -753,6 +766,7 @@
- {
- buf_block_t* bck;
-
-+ ut_error; /* don't support AWE */
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -851,7 +865,7 @@
- buf_block_t* block) /* in: block to make younger */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(!mutex_own(&(buf_pool->mutex)));
-+ ut_ad(!mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Note that we read freed_page_clock's without holding any mutex:
-@@ -860,12 +874,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- }
- }
-
-@@ -881,7 +895,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +903,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +914,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +924,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +965,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +986,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +994,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1013,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1023,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1065,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1073,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1094,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1102,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1181,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ //mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1226,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ //mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1238,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1242,7 +1263,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1685,7 +1706,7 @@
- buf_block_t* block) /* in: block to init */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
-@@ -1792,7 +1813,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1829,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1845,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1901,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1913,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1937,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1949,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1963,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +1999,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2082,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2090,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2126,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,10 +2136,23 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
-@@ -2132,6 +2178,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2188,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2215,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2195,7 +2241,10 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ /* for keep the new latch order, it cannot validate correctly... */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2256,18 +2305,26 @@
- }
-
- ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
-+ /* because of latching order with block->mutex, we cannot get free_mutex before that */
-+/*
- if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
- fprintf(stderr, "Free list len %lu, free blocks %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free);
- ut_error;
- }
-+*/
-+ /* because of latching order with block->mutex, we cannot get flush_list_mutex before that */
-+/*
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+*/
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2356,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2411,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,7 +2448,7 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2404,7 +2465,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2493,7 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2501,7 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(ratio);
- }
-@@ -2460,7 +2521,10 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- if (srv_use_awe) {
- fprintf(stderr,
-@@ -2533,7 +2597,10 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-
- /**************************************************************************
-@@ -2563,7 +2630,7 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2586,7 +2653,7 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(TRUE);
- }
-@@ -2626,11 +2693,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:57 2009 -0700
-@@ -49,7 +49,9 @@
- buf_block_t* block) /* in: block which is modified */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -79,7 +81,9 @@
- buf_block_t* b;
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- prev_b = NULL;
-@@ -113,16 +117,18 @@
- BUF_BLOCK_FILE_PAGE and in the LRU list */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
-- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ if (!block->in_LRU_list || block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -148,12 +154,13 @@
- ulint flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-+ //ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
-+ if (block->state == BUF_BLOCK_FILE_PAGE
-+ && (ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
- && (block->io_fix == 0)) {
- if (flush_type != BUF_FLUSH_LRU) {
-
-@@ -182,15 +189,17 @@
- {
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block->oldest_modification = ut_dulint_zero;
-
- UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
-
- ut_d(UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- (buf_pool->n_flush[block->flush_type])--;
-
-@@ -536,18 +545,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +755,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +789,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +800,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -831,6 +842,7 @@
- ulint space;
- ulint offset;
- ibool found;
-+ ulint remaining = 0;
-
- ut_ad((flush_type == BUF_FLUSH_LRU)
- || (flush_type == BUF_FLUSH_LIST));
-@@ -849,6 +861,12 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- for (;;) {
- /* If we have flushed enough, leave the loop */
-@@ -865,7 +883,10 @@
- } else {
- ut_ad(flush_type == BUF_FLUSH_LIST);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ remaining = UT_LIST_GET_LEN(buf_pool->flush_list);
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- if (!block
- || (ut_dulint_cmp(block->oldest_modification,
- lsn_limit) >= 0)) {
-@@ -895,7 +916,9 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- old_page_count = page_count;
-
-@@ -915,7 +938,9 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -927,16 +952,25 @@
-
- mutex_exit(&block->mutex);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block = UT_LIST_GET_PREV(flush_list, block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ remaining--;
- }
- }
-
- /* If we could not find anything to flush, leave the loop */
-
-- if (!found) {
-+ if (!found && !remaining) {
- break;
- }
- }
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
-
- (buf_pool->init_flush)[flush_type] = FALSE;
-
-@@ -997,7 +1031,7 @@
- ulint n_replaceable;
- ulint distance = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-@@ -1007,6 +1041,12 @@
- && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN
- + BUF_FLUSH_EXTRA_MARGIN)
- && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
-+
-+ if (!block->in_LRU_list) {
-+ /* reatart. but it is very optimistic */
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+ continue;
-+ }
-
- mutex_enter(&block->mutex);
-
-@@ -1021,7 +1061,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1040,8 +1080,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1051,7 +1092,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1101,11 +1142,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0lru.c Fri Jul 03 15:41:57 2009 -0700
-@@ -108,7 +108,7 @@
-
- page_arr = ut_malloc(sizeof(ulint)
- * BUF_LRU_DROP_SEARCH_HASH_SIZE);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- scan_again:
- num_entries = 0;
-@@ -147,12 +147,12 @@
- }
- /* Array full. We release the buf_pool->mutex to
- obey the latching order. */
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- buf_LRU_drop_page_hash_batch(id, page_arr,
- num_entries);
- num_entries = 0;
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- } else {
- mutex_exit(&block->mutex);
- }
-@@ -177,7 +177,7 @@
- }
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- /* Drop any remaining batch of search hashed pages. */
- buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);
-@@ -206,7 +206,8 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +245,8 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +276,8 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +300,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +316,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +340,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +363,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,7 +386,6 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
-@@ -381,6 +393,16 @@
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,6 +413,7 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-
- mutex_exit(&(buf_pool->mutex));
-@@ -398,6 +421,8 @@
- return(FALSE);
- }
- }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +474,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +483,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +507,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,10 +563,16 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ mutex_enter(&(buf_pool->free_mutex));
-+ block = UT_LIST_GET_LAST(buf_pool->free);
-+ if (!block) {
-+ mutex_exit(&(buf_pool->free_mutex));
-+ goto no_block;
-+ }
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-+ mutex_exit(&(buf_pool->free_mutex));
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
- ut_a(!block->in_LRU_list);
-
-@@ -564,7 +597,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -572,11 +605,12 @@
-
- return(block);
- }
-+no_block:
-
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +647,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -655,7 +689,7 @@
-
- ut_a(buf_pool->LRU_old);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5);
-
-@@ -730,7 +764,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -796,7 +830,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -861,7 +895,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -964,7 +998,7 @@
- buf_block_t* block) /* in: block, must not contain a file page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -981,8 +1015,10 @@
- /* Wipe contents of page to reveal possible stale pointers to it */
- memset(block->frame, '\0', UNIV_PAGE_SIZE);
- #endif
-+ mutex_enter(&(buf_pool->free_mutex));
- UT_LIST_ADD_FIRST(free, buf_pool->free, block);
- block->in_free_list = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (srv_use_awe && block->frame) {
- /* Add to the list of mapped pages */
-@@ -1004,7 +1040,7 @@
- may or may not be a hash index to the page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -1062,7 +1098,7 @@
- be in a state where it can be freed */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
-@@ -1085,7 +1121,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1130,6 +1166,9 @@
- ut_a(buf_pool->LRU_old_len == old_len);
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
- block = UT_LIST_GET_FIRST(buf_pool->free);
-@@ -1140,7 +1179,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1195,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1239,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0rea.c Fri Jul 03 15:41:57 2009 -0700
-@@ -237,10 +237,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -252,7 +254,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -348,7 +350,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -451,6 +453,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -464,6 +467,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -480,12 +484,11 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
--
-- mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -493,10 +496,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -512,7 +516,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -588,7 +592,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -656,7 +660,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -728,7 +732,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r 7ac364cc9b41 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0buf.h Fri Jul 03 15:41:57 2009 -0700
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r 7ac364cc9b41 innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0buf.ic Fri Jul 03 15:41:57 2009 -0700
-@@ -112,7 +112,8 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+try_again:
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -120,9 +121,13 @@
- lsn = ut_dulint_zero;
- } else {
- lsn = block->oldest_modification;
-+ if (ut_dulint_cmp(lsn, ut_dulint_zero) == 0) {
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ goto try_again;
-+ }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -137,7 +142,7 @@
- /* out: new clock value */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- buf_pool->ulint_clock++;
-@@ -392,18 +397,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +430,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +438,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -456,7 +461,7 @@
- block = buf_block_align(frame);
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /*UNIV_SYNC_DEBUG */
-
-@@ -477,7 +482,7 @@
- buf_block_t* block) /* in: block */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /* UNIV_SYNC_DEBUG */
-
-@@ -555,7 +560,8 @@
-
- ut_ad(buf_pool);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_EX)
-+ || rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_SHARED));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Look for the page in the hash table */
-@@ -631,11 +637,14 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ /* buf_flush_note_modification() should be called before this function. */
-+/*
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
- mutex_enter(&buf_pool->mutex);
- buf_flush_note_modification(block, mtr);
- mutex_exit(&buf_pool->mutex);
- }
-+*/
-
- mutex_enter(&block->mutex);
-
-diff -r 7ac364cc9b41 innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0flu.h Fri Jul 03 15:41:57 2009 -0700
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r 7ac364cc9b41 innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0flu.ic Fri Jul 03 15:41:57 2009 -0700
-@@ -38,11 +38,14 @@
- mtr_t* mtr) /* in: mtr */
- {
- ut_ad(block);
-+
-+ mutex_enter(&block->mutex);
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0);
-@@ -52,15 +55,19 @@
- block->newest_modification = mtr->end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = mtr->start_lsn;
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- mtr->start_lsn) <= 0);
- }
-+
-+ mutex_exit(&block->mutex);
-
- ++srv_buf_pool_write_requests;
- }
-@@ -78,29 +85,32 @@
- set of mtr's */
- {
- ut_ad(block);
-+
-+ mutex_enter(&(block->mutex));
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
--
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
- block->newest_modification = end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = start_lsn;
-
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_sorted_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(block->mutex));
- }
-diff -r 7ac364cc9b41 innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/sync0sync.h Fri Jul 03 15:41:57 2009 -0700
-@@ -438,8 +438,12 @@
- SYNC_SEARCH_SYS, as memory allocation
- can call routines there! Otherwise
- the level is SYNC_MEM_HASH. */
-+#define SYNC_BUF_LRU_LIST 157
-+#define SYNC_BUF_PAGE_HASH 156
-+#define SYNC_BUF_BLOCK 155
-+#define SYNC_BUF_FREE_LIST 153
- #define SYNC_BUF_POOL 150
--#define SYNC_BUF_BLOCK 149
-+#define SYNC_BUF_FLUSH_LIST 149
- #define SYNC_DOUBLEWRITE 140
- #define SYNC_ANY_LATCH 135
- #define SYNC_THR_LOCAL 133
-diff -r 7ac364cc9b41 innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/log/log0recv.c Fri Jul 03 15:41:57 2009 -0700
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r 7ac364cc9b41 innobase/mtr/mtr0mtr.c
---- a/innobase/mtr/mtr0mtr.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/mtr/mtr0mtr.c Fri Jul 03 15:41:57 2009 -0700
-@@ -103,6 +103,38 @@
- }
- }
-
-+UNIV_INLINE
-+void
-+mtr_memo_note_modification_all(
-+/*===========================*/
-+ mtr_t* mtr) /* in: mtr */
-+{
-+ mtr_memo_slot_t* slot;
-+ dyn_array_t* memo;
-+ ulint offset;
-+
-+ ut_ad(mtr);
-+ ut_ad(mtr->magic_n == MTR_MAGIC_N);
-+ ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in
-+ commit */
-+ ut_ad(mtr->modifications);
-+
-+ memo = &(mtr->memo);
-+
-+ offset = dyn_array_get_data_size(memo);
-+
-+ while (offset > 0) {
-+ offset -= sizeof(mtr_memo_slot_t);
-+ slot = dyn_array_get_element(memo, offset);
-+
-+ if (UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-+ }
-+}
-+
- /****************************************************************
- Writes the contents of a mini-transaction log, if any, to the database log. */
- static
-@@ -177,6 +209,8 @@
- #endif
- if (mtr->modifications) {
- mtr_log_reserve_and_write(mtr);
-+
-+ mtr_memo_note_modification_all(mtr);
- }
-
- /* We first update the modification info to buffer pages, and only
-@@ -187,11 +221,12 @@
- required when we insert modified buffer pages in to the flush list
- which must be sorted on oldest_modification. */
-
-- mtr_memo_pop_all(mtr);
--
- if (mtr->modifications) {
- log_release();
- }
-+
-+ /* All unlocking has been moved here, after log_sys mutex release. */
-+ mtr_memo_pop_all(mtr);
-
- #ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTED;
-@@ -262,6 +297,12 @@
- slot = dyn_array_get_element(memo, offset);
-
- if ((object == slot->object) && (type == slot->type)) {
-+ if (mtr->modifications &&
-+ UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-
- mtr_memo_slot_release(mtr, slot);
-
-diff -r 7ac364cc9b41 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:57 2009 -0700
-@@ -367,6 +367,7 @@
- ulong srv_n_free_tickets_to_enter = 500;
- ulong srv_thread_sleep_delay = 10000;
- ulint srv_spin_wait_delay = 5;
-+ulint srv_spins_microsec = 50;
- ibool srv_priority_boost = TRUE;
-
- ibool srv_print_thread_releases = FALSE;
-@@ -673,6 +674,47 @@
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-
-+static
-+void
-+srv_align_spins_microsec(void)
-+{
-+ ulint start_sec, end_sec;
-+ ulint start_usec, end_usec;
-+ ib_longlong usecs;
-+
-+ /* change temporary */
-+ srv_spins_microsec = 1;
-+
-+ if (ut_usectime(&start_sec, &start_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ ut_delay(100000);
-+
-+ if (ut_usectime(&end_sec, &end_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ usecs = (end_sec - start_sec) * 1000000LL + (end_usec - start_usec);
-+
-+ if (usecs) {
-+ srv_spins_microsec = 100000 / usecs;
-+ if (srv_spins_microsec == 0)
-+ srv_spins_microsec = 1;
-+ if (srv_spins_microsec > 50)
-+ srv_spins_microsec = 50;
-+ } else {
-+ srv_spins_microsec = 50;
-+ }
-+end:
-+ if (srv_spins_microsec != 50)
-+ fprintf(stderr,
-+ "InnoDB: unit of spin count at ut_delay() is aligned to %lu\n",
-+ srv_spins_microsec);
-+}
-+
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-
-@@ -905,6 +947,8 @@
- srv_slot_t* slot;
- dict_table_t* table;
- ulint i;
-+
-+ srv_align_spins_microsec();
-
- srv_sys = mem_alloc(sizeof(srv_sys_t));
-
-@@ -2661,7 +2705,7 @@
- ib_longlong level, bpl;
- buf_block_t* bpage;
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- level = 0;
- bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-@@ -2683,7 +2727,7 @@
- bpl = 0;
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- if (!srv_use_doublewrite_buf) {
- /* flush is faster than when doublewrite */
-diff -r 7ac364cc9b41 innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/sync/sync0sync.c Fri Jul 03 15:41:57 2009 -0700
-@@ -1105,11 +1105,19 @@
- } else if (level == SYNC_DOUBLEWRITE) {
- ut_a(sync_thread_levels_g(array, SYNC_DOUBLEWRITE));
- } else if (level == SYNC_BUF_BLOCK) {
-- ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL)
-+ ut_a((sync_thread_levels_contain(array, SYNC_BUF_LRU_LIST)
- && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1))
- || sync_thread_levels_g(array, SYNC_BUF_BLOCK));
- } else if (level == SYNC_BUF_POOL) {
- ut_a(sync_thread_levels_g(array, SYNC_BUF_POOL));
-+ } else if (level == SYNC_BUF_FLUSH_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FLUSH_LIST));
-+ } else if (level == SYNC_BUF_FREE_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FREE_LIST));
-+ } else if (level == SYNC_BUF_PAGE_HASH) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_PAGE_HASH));
-+ } else if (level == SYNC_BUF_LRU_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_LRU_LIST));
- } else if (level == SYNC_SEARCH_SYS) {
- ut_a(sync_thread_levels_g(array, SYNC_SEARCH_SYS));
- } else if (level == SYNC_TRX_LOCK_HEAP) {
-diff -r 7ac364cc9b41 innobase/ut/ut0ut.c
---- a/innobase/ut/ut0ut.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/ut/ut0ut.c Fri Jul 03 15:41:57 2009 -0700
-@@ -347,6 +347,7 @@
- /*****************************************************************
- Runs an idle loop on CPU. The argument gives the desired delay
- in microseconds on 100 MHz Pentium + Visual C++. */
-+extern ulint srv_spins_microsec;
-
- ulint
- ut_delay(
-@@ -358,7 +359,11 @@
-
- j = 0;
-
-- for (i = 0; i < delay * 50; i++) {
-+ for (i = 0; i < delay * srv_spins_microsec; i++) {
-+#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__)
-+ /* it is equal to the instruction 'pause' */
-+ __asm__ __volatile__ ("rep; nop");
-+#endif
- j += i;
- }
-
-diff -r 7ac364cc9b41 patch_info/innodb_split_buf_pool_mutex.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_split_buf_pool_mutex.info Fri Jul 03 15:41:57 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_split_buf_pool_mutex.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=Backport from XtraDB
-diff -r 7ac364cc9b41 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:50 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:57 2009 -0700
-@@ -1503,6 +1503,13 @@
- /* We set srv_pool_size here in units of 1 kB. InnoDB internally
- changes the value so that it becomes the number of database pages. */
-
-+ if (innobase_buffer_pool_awe_mem_mb) {
-+ /* split_buf_pool_mutex.patch don't support AWE */
-+ fputs("InnoDB: Warning: split_buf_pool_mutex.patch don't support AWE. Disabled.\n",
-+ stderr);
-+ innobase_buffer_pool_awe_mem_mb = 0;
-+ }
-+
- if (innobase_buffer_pool_awe_mem_mb == 0) {
- /* Careful here: we first convert the signed long int to ulint
- and only after that divide */
diff --git a/percona/5.0.83-b17-20090723/innodb_thread_concurrency_timer_based.patch b/percona/5.0.83-b17-20090723/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 3b8f659..0000000
--- a/percona/5.0.83-b17-20090723/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090723/innodb_use_sys_malloc.patch b/percona/5.0.83-b17-20090723/innodb_use_sys_malloc.patch
deleted file mode 100644
index 64f7d58..0000000
--- a/percona/5.0.83-b17-20090723/innodb_use_sys_malloc.patch
+++ /dev/null
@@ -1,225 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-06 16:06:51.000000000 +0900
-@@ -90,6 +90,7 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_use_sys_malloc;
- extern ibool srv_thread_concurrency_timer_based;
-
- extern ulint srv_n_file_io_threads;
-diff -ruN a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
---- a/innobase/mem/mem0dbg.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0dbg.c 2009-07-06 16:48:17.000000000 +0900
-@@ -134,6 +134,14 @@
- mem_hash_initialized = TRUE;
- #endif
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ /* When innodb_use_sys_malloc is set, the
-+ mem_comm_pool won't be used for any allocations. We
-+ create a dummy mem_comm_pool, because some statistics
-+ and debugging code relies on it being initialized. */
-+ size = 1;
-+ }
-+
- mem_comm_pool = mem_pool_create(size);
- }
-
-diff -ruN a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c
---- a/innobase/mem/mem0pool.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0pool.c 2009-07-06 17:22:09.000000000 +0900
-@@ -11,6 +11,7 @@
- #include "mem0pool.ic"
- #endif
-
-+#include "srv0srv.h"
- #include "sync0sync.h"
- #include "ut0mem.h"
- #include "ut0lst.h"
-@@ -191,8 +192,6 @@
- ulint i;
- ulint used;
-
-- ut_a(size > 10000);
--
- pool = ut_malloc(sizeof(mem_pool_t));
-
- /* We do not set the memory to zero (FALSE) in the pool,
-@@ -330,6 +329,10 @@
- ulint n;
- ibool ret;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(malloc(size));
-+ }
-+
- n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
-
- mutex_enter(&(pool->mutex));
-@@ -457,6 +460,11 @@
- ulint size;
- ulint n;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ free(ptr);
-+ return;
-+ }
-+
- /* It may be that the area was really allocated from the OS with
- regular malloc: check if ptr points within our memory pool */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-06 16:08:06.000000000 +0900
-@@ -273,6 +273,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_use_sys_malloc = TRUE;
- ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-06 16:23:38.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ fprintf(stderr,
-+ "InnoDB: The InnoDB memory heap is disabled\n");
-+ }
-+
- #ifdef HAVE_ATOMIC_BUILTINS
- fprintf(stderr,
- "InnoDB: use atomic builtins.\n");
-diff -ruN a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
---- a/innobase/ut/ut0mem.c 2009-05-08 06:12:13.000000000 +0900
-+++ b/innobase/ut/ut0mem.c 2009-07-06 16:42:26.000000000 +0900
-@@ -15,6 +15,7 @@
- #include "mem0mem.h"
- #include "os0sync.h"
- #include "os0thread.h"
-+#include "srv0srv.h"
-
- /* This struct is placed first in every allocated memory block */
- typedef struct ut_mem_block_struct ut_mem_block_t;
-@@ -70,6 +71,18 @@
- ulint retry_count = 0;
- 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);
-+ }
-+#endif
-+ return(ret);
-+ }
-+
- ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-
- if (!ut_mem_block_list_inited) {
-@@ -223,6 +236,11 @@
- {
- 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);
-@@ -275,6 +293,10 @@
- ulint min_size;
- void* new_ptr;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(realloc(ptr, size));
-+ }
-+
- if (ptr == NULL) {
-
- return(ut_malloc(size));
-diff -ruN a/patch_info/innodb_use_sys_malloc.info b/patch_info/innodb_use_sys_malloc.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_use_sys_malloc.info 2009-07-06 16:04:24.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_use_sys_malloc.patch
-+Name=InnoDB uses malloc directly (backport from InnoDB-Plugin)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-06 16:10:15.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_use_sys_malloc;
- my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -1492,6 +1493,8 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_use_sys_malloc = (ibool) innobase_use_sys_malloc;
-+
- srv_thread_concurrency_timer_based =
- (ibool) innobase_thread_concurrency_timer_based;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-06 16:10:42.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_use_sys_malloc;
- extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-06 16:16:56.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_USE_SYS_MALLOC,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5470,6 +5471,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_use_sys_malloc", OPT_INNODB_USE_SYS_MALLOC,
-+ "Use OS memory allocator instead of InnoDB's internal memory allocator",
-+ (gptr*) &innobase_use_sys_malloc, (gptr*) &innobase_use_sys_malloc,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
- {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- "Use InnoDB timer based concurrency throttling. ",
- (gptr*) &innobase_thread_concurrency_timer_based,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-06 16:22:05.000000000 +0900
-@@ -1093,6 +1093,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.83-b17-20090723/microsec_process.patch b/percona/5.0.83-b17-20090723/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.83-b17-20090723/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.83-b17-20090723/microslow_innodb.patch b/percona/5.0.83-b17-20090723/microslow_innodb.patch
deleted file mode 100644
index e28f091..0000000
--- a/percona/5.0.83-b17-20090723/microslow_innodb.patch
+++ /dev/null
@@ -1,2493 +0,0 @@
-diff -r 069dc6d4f269 include/my_getopt.h
---- a/include/my_getopt.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/include/my_getopt.h Mon Jun 01 00:35:30 2009 -0700
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 069dc6d4f269 include/my_time.h
---- a/include/my_time.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/include/my_time.h Mon Jun 01 00:35:30 2009 -0700
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 069dc6d4f269 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/buf/buf0buf.c Mon Jun 01 00:35:30 2009 -0700
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1090,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1142,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1158,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1190,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1303,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1276,6 +1323,12 @@
- break;
- }
- }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
- }
-
- fix_type = MTR_MEMO_BUF_FIX;
-@@ -1296,12 +1349,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1384,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,7 +1499,7 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
-@@ -1448,6 +1507,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-@@ -1470,6 +1534,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1559,6 +1624,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-diff -r 069dc6d4f269 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/buf/buf0rea.c Mon Jun 01 00:35:30 2009 -0700
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 069dc6d4f269 innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/fil/fil0fil.c Mon Jun 01 00:35:30 2009 -0700
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 069dc6d4f269 innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/buf0rea.h Mon Jun 01 00:35:30 2009 -0700
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 069dc6d4f269 innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/fil0fil.h Mon Jun 01 00:35:30 2009 -0700
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 069dc6d4f269 innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/os0file.h Mon Jun 01 00:35:30 2009 -0700
-@@ -11,6 +11,8 @@
-
- #include "univ.i"
-
-+#include "trx0types.h"
-+
- #ifndef __WIN__
- #include <dirent.h>
- #include <sys/stat.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 069dc6d4f269 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:35:30 2009 -0700
-@@ -27,6 +27,8 @@
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-
-+extern ibool srv_slow_log;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-
-diff -r 069dc6d4f269 innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/include/trx0trx.h Mon Jun 01 00:35:30 2009 -0700
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 069dc6d4f269 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:35:30 2009 -0700
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 069dc6d4f269 innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/os/os0file.c Mon Jun 01 00:35:30 2009 -0700
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1905,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1919,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1948,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1968,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1981,6 +2005,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(ret);
- }
- #endif
-@@ -2103,7 +2134,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2144,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2209,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3169,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3423,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3463,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3497,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 069dc6d4f269 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:35:30 2009 -0700
-@@ -48,6 +48,8 @@
- #include "srv0start.h"
- #include "row0mysql.h"
-
-+ibool srv_slow_log = 0;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
- ibool srv_lower_case_table_names = FALSE;
-@@ -1002,6 +1004,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1060,6 +1066,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1115,12 +1122,23 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_waiting_threads--;
-diff -r 069dc6d4f269 innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/innobase/trx/trx0trx.c Mon Jun 01 00:35:30 2009 -0700
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 069dc6d4f269 mysys/my_getopt.c
---- a/mysys/my_getopt.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/mysys/my_getopt.c Mon Jun 01 00:35:30 2009 -0700
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1061,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 069dc6d4f269 patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Mon Jun 01 00:35:30 2009 -0700
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 069dc6d4f269 scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Mon Jun 01 00:35:20 2009 -0700
-+++ b/scripts/mysqldumpslow.sh Mon Jun 01 00:35:30 2009 -0700
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 069dc6d4f269 sql-common/my_time.c
---- a/sql-common/my_time.c Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql-common/my_time.c Mon Jun 01 00:35:30 2009 -0700
-@@ -1253,3 +1253,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 069dc6d4f269 sql/filesort.cc
---- a/sql/filesort.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/filesort.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 069dc6d4f269 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/ha_innodb.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -819,9 +820,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1324,6 +1350,8 @@
-
- /* -------------- Log files ---------------------------*/
-
-+ srv_slow_log = (ibool) opt_slow_log;
-+
- /* The default dir for log files is the datadir of MySQL */
-
- if (!innobase_log_group_home_dir) {
-@@ -4694,6 +4722,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4959,6 +4993,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5046,6 +5086,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5112,6 +5158,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len1 = strlen(from);
- name_len2 = strlen(to);
-
-@@ -6119,6 +6171,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6242,7 +6295,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 069dc6d4f269 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:35:30 2009 -0700
-@@ -271,6 +271,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 069dc6d4f269 sql/log.cc
---- a/sql/log.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/log.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2289,11 +2289,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2303,7 +2304,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2333,22 +2335,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 069dc6d4f269 sql/log_event.cc
---- a/sql/log_event.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/log_event.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2057,6 +2057,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 069dc6d4f269 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/mysql_priv.h Mon Jun 01 00:35:30 2009 -0700
-@@ -507,6 +507,78 @@
-
- #define STRING_BUFFER_USUAL_SIZE 80
-
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-+
- enum enum_parsing_place
- {
- NO_MATTER,
-@@ -1365,6 +1437,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1376,7 +1449,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 069dc6d4f269 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -176,7 +176,6 @@
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
-
--
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
- #endif
-@@ -411,10 +410,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -509,6 +511,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -588,7 +591,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3697,6 +3700,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4947,7 +4952,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5038,11 +5043,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5441,10 +5453,19 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
- "Path to transaction coordinator log (used for transactions that affect "
- "more than one storage engine, when binary log is disabled)",
-@@ -5808,6 +5829,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6110,11 +6134,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6893,7 +6937,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7364,6 +7412,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7696,10 +7773,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 069dc6d4f269 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -697,6 +717,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -720,6 +744,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -773,6 +798,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -994,8 +1021,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1022,6 +1052,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1109,6 +1140,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1149,6 +1182,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1777,6 +1811,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1933,6 +1978,19 @@
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
- }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
-+ }
- case SHOW_HA_ROWS:
- {
- ha_rows value;
-@@ -2765,6 +2823,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3534,6 +3616,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 069dc6d4f269 sql/set_var.h
---- a/sql/set_var.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/set_var.h Mon Jun 01 00:35:30 2009 -0700
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -378,7 +384,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ulonglong :public sys_var_thd
- {
- public:
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -478,6 +496,66 @@
- };
-
-
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
- class sys_var_thd_storage_engine :public sys_var_thd
- {
- protected:
-@@ -1087,3 +1165,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 069dc6d4f269 sql/slave.cc
---- a/sql/slave.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/slave.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -2975,6 +2975,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 069dc6d4f269 sql/sql_cache.cc
---- a/sql/sql_cache.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_cache.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1402,6 +1402,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1409,6 +1410,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 069dc6d4f269 sql/sql_class.cc
---- a/sql/sql_class.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_class.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -190,7 +190,7 @@
- table_map_for_update(0),
- global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2251,6 +2251,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2267,7 +2273,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2320,6 +2332,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 069dc6d4f269 sql/sql_class.h
---- a/sql/sql_class.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_class.h Mon Jun 01 00:35:30 2009 -0700
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1129,6 +1134,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1185,6 +1196,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1293,10 +1309,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1696,11 +1726,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 069dc6d4f269 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_parse.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,28 +2363,58 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-- thd->end_time(); // Set start time
-+ ulonglong start_of_query_timer= thd->start_timer;
-+ thd->end_time(); // Set start timea
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-+
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
-+
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((thd->start_time > thd->time_after_lock &&
-- (ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time) ||
-- (thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END)
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
-+
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2669,6 +2709,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6203,6 +6245,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 069dc6d4f269 sql/sql_select.cc
---- a/sql/sql_select.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_select.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -6262,8 +6262,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6278,8 +6281,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9340,6 +9346,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10200,6 +10207,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 069dc6d4f269 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/sql_show.cc Mon Jun 01 00:35:30 2009 -0700
-@@ -1560,6 +1560,12 @@
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
-+ break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
- break;
-diff -r 069dc6d4f269 sql/structs.h
---- a/sql/structs.h Mon Jun 01 00:35:20 2009 -0700
-+++ b/sql/structs.h Mon Jun 01 00:35:30 2009 -0700
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.83-b17-20090723/mirror_binlog.patch b/percona/5.0.83-b17-20090723/mirror_binlog.patch
deleted file mode 100644
index d52e806..0000000
--- a/percona/5.0.83-b17-20090723/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5098,6 +5098,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
- };
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.83-b17-20090723/mysql-test.patch b/percona/5.0.83-b17-20090723/mysql-test.patch
deleted file mode 100644
index 7fce8e0..0000000
--- a/percona/5.0.83-b17-20090723/mysql-test.patch
+++ /dev/null
@@ -1,108 +0,0 @@
---- a/mysql-test/r/information_schema.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/information_schema.result 2009-05-07 19:32:59.000000000 +0000
-@@ -60,6 +60,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- columns_priv
- db
- func
-@@ -743,7 +744,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--109
-+110
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -819,7 +820,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 24
-+information_schema 25
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1228,6 +1229,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1267,6 +1269,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1342,6 +1345,7 @@
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
---- a/mysql-test/r/information_schema_db.result 2009-05-07 19:31:27.000000000 +0000
-+++ b/mysql-test/r/information_schema_db.result 2009-05-07 19:35:01.000000000 +0000
-@@ -29,6 +29,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
---- a/mysql-test/r/mysqlshow.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/mysqlshow.result 2009-05-07 19:36:32.000000000 +0000
-@@ -103,6 +103,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -132,6 +133,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
---- a/mysql-test/r/profiling.result 2009-05-28 19:39:42.000000000 +0000
-+++ b/mysql-test/r/profiling.result 2009-05-28 19:40:14.000000000 +0000
-@@ -6,6 +6,8 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 15
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 0
-@@ -16,12 +18,16 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 100
-+profiling_server OFF
-+profiling_use_getrusage OFF
- set session profiling = ON;
- set session profiling_history_size=30;
- show session variables like 'profil%';
- Variable_name Value
- profiling ON
- profiling_history_size 30
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 1
diff --git a/percona/5.0.83-b17-20090723/mysqld_safe_syslog.patch b/percona/5.0.83-b17-20090723/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.83-b17-20090723/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.83-b17-20090723/profiling_slow.patch b/percona/5.0.83-b17-20090723/profiling_slow.patch
deleted file mode 100644
index 78d35a0..0000000
--- a/percona/5.0.83-b17-20090723/profiling_slow.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-diff -r 4636d2e0b0d0 patch_info/profiling_slow.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/profiling_slow.info Fri Jul 03 15:40:29 2009 -0700
-@@ -0,0 +1,9 @@
-+File=profiling_slow.info
-+Name=profiling from SHOW PROFILE to slow.log
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2009-05-18
-+Initial implementation
-diff -r 4636d2e0b0d0 sql/log.cc
---- a/sql/log.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/log.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -2402,6 +2402,11 @@
- tmp_errno=errno;
- }
- }
-+
-+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
-+ thd->profiling.print_current(&log_file);
-+#endif
-+
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
- if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
-diff -r 4636d2e0b0d0 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -5052,6 +5052,8 @@
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_PROFILING_SERVER,
-+ OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
-@@ -5675,6 +5677,16 @@
- (gptr*) &global_system_variables.profiling_history_size,
- (gptr*) &max_system_variables.profiling_history_size,
- 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
-+ {"profiling_server", OPT_PROFILING_SERVER,
-+ "Enable profiling of all threads",
-+ (gptr*) &global_system_variables.profiling_server,
-+ (gptr*) &max_system_variables.profiling_server, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
-+ {"profiling_use_getrusage", OPT_PROFILING_USE_GETRUSAGE,
-+ "Enable getrusage function call for profiling",
-+ (gptr*) &global_system_variables.profiling_use_getrusage,
-+ (gptr*) &max_system_variables.profiling_use_getrusage, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
- #endif
- {"relay-log", OPT_RELAY_LOG,
- "The location and name to use for relay logs.",
-diff -r 4636d2e0b0d0 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -592,6 +592,10 @@
- ulonglong(OPTION_PROFILING));
- static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
- &SV::profiling_history_size);
-+static sys_var_thd_bool sys_profiling_server("profiling_server",
-+ &SV::profiling_server);
-+static sys_var_thd_bool sys_profiling_use_getrusage("profiling_use_getrusage",
-+ &SV::profiling_use_getrusage);
- #endif
-
- /* Local state variables */
-@@ -764,6 +768,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- &sys_profiling,
- &sys_profiling_history_size,
-+ &sys_profiling_server,
-+ &sys_profiling_use_getrusage,
- #endif
- &sys_pseudo_thread_id,
- &sys_query_alloc_block_size,
-@@ -1094,6 +1100,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- {sys_profiling.name, (char*) &sys_profiling, SHOW_SYS},
- {sys_profiling_history_size.name, (char*) &sys_profiling_history_size, SHOW_SYS},
-+ {sys_profiling_server.name, (char*) &sys_profiling_server, SHOW_SYS},
-+ {sys_profiling_use_getrusage.name, (char*) &sys_profiling_use_getrusage, SHOW_SYS},
- #endif
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
-diff -r 4636d2e0b0d0 sql/sql_class.h
---- a/sql/sql_class.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_class.h Fri Jul 03 15:40:29 2009 -0700
-@@ -550,6 +550,8 @@
- ulong optimizer_search_depth;
- ulong preload_buff_size;
- ulong profiling_history_size;
-+ my_bool profiling_server;
-+ my_bool profiling_use_getrusage;
- ulong query_cache_type;
- ulong log_slow_rate_limit;
- ulong read_buff_size;
-diff -r 4636d2e0b0d0 sql/sql_profile.cc
---- a/sql/sql_profile.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -221,9 +221,22 @@
- */
- void PROF_MEASUREMENT::collect()
- {
-+ struct timespec tp;
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
- #ifdef HAVE_GETRUSAGE
-- getrusage(RUSAGE_SELF, &rusage);
-+ if ((profile->get_profiling())->enabled_getrusage())
-+ getrusage(RUSAGE_SELF, &rusage);
-+#endif
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ {
-+ cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
-+ }
-+ else
-+ {
-+ cpu_time_usecs= 0;
-+ }
- #endif
- }
-
-@@ -341,7 +354,7 @@
- finish_current_query();
- }
-
-- enabled= (((thd)->options & OPTION_PROFILING) != 0);
-+ enabled= (((thd)->options & OPTION_PROFILING) != 0) || ( thd->variables.profiling_server );
-
- if (! enabled) DBUG_VOID_RETURN;
-
-@@ -379,7 +392,8 @@
- status_change("ending", NULL, NULL, 0);
-
- if ((enabled) && /* ON at start? */
-- ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
-+ (((thd->options & OPTION_PROFILING) != 0) ||
-+ (thd->variables.profiling_server)) && /* and ON at end? */
- (current->query_source != NULL) &&
- (! current->entries.is_empty()))
- {
-@@ -480,6 +494,88 @@
- DBUG_VOID_RETURN;
- }
-
-+bool PROFILING::enabled_getrusage()
-+{
-+ return thd->variables.profiling_use_getrusage;
-+}
-+
-+/**
-+ Print output for current query to file
-+*/
-+
-+int PROFILING::print_current(IO_CACHE *log_file)
-+{
-+ DBUG_ENTER("PROFILING::print_current");
-+ ulonglong row_number= 0;
-+ char query_time_buff[22+7];
-+ char query_cpu_time_buff[22+7];
-+
-+ QUERY_PROFILE *query;
-+ /* Get current query */
-+ if (current == NULL)
-+ {
-+ DBUG_RETURN(0);
-+ }
-+
-+ query= current;
-+
-+ my_b_printf(log_file, "# PROFILE_VALUES ");
-+
-+ void *entry_iterator;
-+ PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
-+ /* ...and for each query, go through all its state-change steps. */
-+ for (entry_iterator= query->entries.new_iterator();
-+ entry_iterator != NULL;
-+ entry_iterator= query->entries.iterator_next(entry_iterator),
-+ previous=entry, row_number++)
-+ {
-+ entry= query->entries.iterator_value(entry_iterator);
-+
-+ /* Skip the first. We count spans of fence, not fence-posts. */
-+ if (previous == NULL) {first= entry; continue;}
-+
-+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
-+ {
-+ /*
-+ We got here via a SHOW command. That means that we stored
-+ information about the query we wish to show and that isn't
-+ in a WHERE clause at a higher level to filter out rows we
-+ wish to exclude.
-+
-+ Because that functionality isn't available in the server yet,
-+ we must filter here, at the wrong level. Once one can con-
-+ struct where and having conditions at the SQL layer, then this
-+ condition should be ripped out.
-+ */
-+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
-+ {
-+ if (query != last)
-+ continue;
-+ }
-+ else
-+ {
-+ if (thd->lex->profile_query_id != query->profiling_query_id)
-+ continue;
-+ }
-+ }
-+
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
-+
-+ }
-+
-+ my_b_printf(log_file, "\n");
-+ if ((entry != NULL) && (first != NULL))
-+ {
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /**
- Fill the information schema table, "query_profile", as defined in show.cc .
- There are two ways to get to this function: Selecting from the information
-diff -r 4636d2e0b0d0 sql/sql_profile.h
---- a/sql/sql_profile.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.h Fri Jul 03 15:40:29 2009 -0700
-@@ -193,6 +193,7 @@
- unsigned int line;
-
- double time_usecs;
-+ double cpu_time_usecs;
- char *allocated_status_memory;
-
- void set_label(const char *status_arg, const char *function_arg,
-@@ -243,6 +244,11 @@
-
- /* Show this profile. This is called by PROFILING. */
- bool show(uint options);
-+
-+public:
-+
-+ inline PROFILING * get_profiling() { return profiling; };
-+
- };
-
-
-@@ -288,9 +294,11 @@
-
- /* SHOW PROFILES */
- bool show_profiles();
-+ bool enabled_getrusage();
-
- /* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
-+ int print_current(IO_CACHE *log_file);
- };
-
- # endif /* HAVE_PROFILING */
diff --git a/percona/5.0.83-b17-20090723/series b/percona/5.0.83-b17-20090723/series
deleted file mode 100644
index 8b68665..0000000
--- a/percona/5.0.83-b17-20090723/series
+++ /dev/null
@@ -1,20 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-profiling_slow.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_show_hashed_memory.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-innodb_use_sys_malloc.patch
-innodb_split_buf_pool_mutex.patch
-innodb_rw_lock.patch
-mysql-test.patch
diff --git a/percona/5.0.83-b17-20090723/show_patches.patch b/percona/5.0.83-b17-20090723/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.83-b17-20090723/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.83-b17-20090723/split_buf_pool_mutex_fixed_optimistic_safe.patch b/percona/5.0.83-b17-20090723/split_buf_pool_mutex_fixed_optimistic_safe.patch
deleted file mode 100644
index fe86f60..0000000
--- a/percona/5.0.83-b17-20090723/split_buf_pool_mutex_fixed_optimistic_safe.patch
+++ /dev/null
@@ -1,1316 +0,0 @@
-diff -r fb75578f988a innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0buf.c Mon Jun 01 00:37:25 2009 -0700
-@@ -549,6 +549,19 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_create(&(buf_pool->free_mutex));
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_NO_ORDER_CHECK);
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_NO_ORDER_CHECK);
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_NO_ORDER_CHECK);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +737,10 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -860,12 +877,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->LRU_mutex));
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
- }
-
-@@ -881,7 +898,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +906,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +917,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +927,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +968,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +989,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +997,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1016,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1026,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1068,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1076,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1097,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1105,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1184,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ // mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1229,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ // mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1241,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1234,7 +1258,9 @@
- LRU list and we must put it to awe_LRU_free_mapped list once
- mapped to a frame */
-
-+ mutex_enter_fast(&(buf_pool->mutex));
- buf_awe_map_page_to_frame(block, TRUE);
-+ mutex_exit(&buf_pool->mutex);
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -1242,7 +1268,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ // mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1792,7 +1818,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1834,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1850,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1906,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1918,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1942,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1954,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1968,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +2004,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2087,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2095,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2131,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,11 +2141,26 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
- if (srv_io_pattern && srv_io_pattern_trace_running) {
-@@ -2132,6 +2185,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2195,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2222,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2192,10 +2245,22 @@
- ulint n_flush = 0;
- ulint n_free = 0;
- ulint n_page = 0;
-+ ulint n_single_flush_tmp = 0;
-+ ulint n_lru_flush_tmp = 0;
-+ ulint n_list_flush_tmp = 0;
-
- ut_ad(buf_pool);
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+
- mutex_enter(&(buf_pool->mutex));
-+ n_single_flush_tmp = buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE];
-+ n_list_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LIST];
-+ n_lru_flush_tmp = buf_pool->n_flush[BUF_FLUSH_LRU];
-+ mutex_exit(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2263,11 +2328,14 @@
- }
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
-- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
-- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+ ut_a(n_single_flush_tmp == n_single_flush);
-+ ut_a(n_list_flush_tmp == n_list_flush);
-+ ut_a(n_lru_flush_tmp == n_lru_flush);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2367,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2422,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,8 +2459,6 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2404,7 +2474,6 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2501,9 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2511,9 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ratio);
- }
-@@ -2460,6 +2533,9 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -2533,6 +2609,9 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
- }
-
-@@ -2563,8 +2642,6 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
--
- for (i = 0; i < buf_pool->curr_size; i++) {
-
- block = buf_pool_get_nth_block(buf_pool, i);
-@@ -2586,8 +2663,6 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
--
- return(TRUE);
- }
-
-@@ -2626,11 +2701,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r fb75578f988a innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0flu.c Mon Jun 01 00:37:25 2009 -0700
-@@ -117,12 +117,14 @@
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* I permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -536,18 +538,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +748,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +782,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +793,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -849,7 +853,14 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+
- for (;;) {
- /* If we have flushed enough, leave the loop */
- if (page_count >= min_n) {
-@@ -895,7 +906,10 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- old_page_count = page_count;
-
-@@ -915,7 +929,10 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -938,6 +955,13 @@
- }
- }
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex));
-+
- (buf_pool->init_flush)[flush_type] = FALSE;
-
- if ((buf_pool->n_flush[flush_type] == 0)
-@@ -996,11 +1020,15 @@
- buf_block_t* block;
- ulint n_replaceable;
- ulint distance = 0;
--
-- mutex_enter(&(buf_pool->mutex));
-+
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-+ //mutex_enter(&(buf_pool->free_mutex));
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-+ //mutex_exit(&(buf_pool->free_mutex));
-+
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while ((block != NULL)
-@@ -1021,7 +1049,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1040,8 +1068,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1051,7 +1080,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1101,11 +1130,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r fb75578f988a innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0lru.c Mon Jun 01 00:37:25 2009 -0700
-@@ -206,7 +206,10 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +247,10 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +280,10 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +306,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +322,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +346,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->LRU_mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +369,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,14 +392,25 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
- freed = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,13 +421,21 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-+ mutex_exit(&(buf_pool->mutex));
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-
- return(FALSE);
- }
- }
-+ if (!freed) {
-+ //mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +487,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +496,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +520,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex)); /* LRU info:optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,7 +576,7 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ block = UT_LIST_GET_LAST(buf_pool->free);
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-@@ -564,7 +604,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -576,7 +616,7 @@
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +653,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -1085,7 +1125,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1128,7 +1168,10 @@
-
- if (buf_pool->LRU_old) {
- ut_a(buf_pool->LRU_old_len == old_len);
-- }
-+ }
-+
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
-@@ -1140,7 +1183,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1199,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1243,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r fb75578f988a innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/buf/buf0rea.c Mon Jun 01 00:37:25 2009 -0700
-@@ -237,10 +237,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -251,8 +253,9 @@
- recent_blocks++;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ // mutex_exit(&(buf_pool->mutex));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -348,7 +351,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -451,6 +454,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -464,6 +468,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -480,12 +485,13 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -493,10 +499,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -512,7 +519,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -588,7 +595,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -656,7 +663,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -728,7 +735,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r fb75578f988a innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0buf.h Mon Jun 01 00:37:25 2009 -0700
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r fb75578f988a innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0buf.ic Mon Jun 01 00:37:25 2009 -0700
-@@ -112,7 +112,7 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -122,7 +122,7 @@
- lsn = block->oldest_modification;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -392,18 +392,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +425,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +433,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -632,9 +632,9 @@
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->flush_list_mutex);
- buf_flush_note_modification(block, mtr);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->flush_list_mutex);
- }
-
- mutex_enter(&block->mutex);
-diff -r fb75578f988a innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0flu.h Mon Jun 01 00:37:25 2009 -0700
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r fb75578f988a innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/include/buf0flu.ic Mon Jun 01 00:37:25 2009 -0700
-@@ -84,7 +84,7 @@
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
-@@ -102,5 +102,5 @@
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-diff -r fb75578f988a innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Mon Jun 01 00:37:17 2009 -0700
-+++ b/innobase/log/log0recv.c Mon Jun 01 00:37:25 2009 -0700
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r fb75578f988a patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/split_buf_pool_mutex_fixed_optimistic_safe.info Mon Jun 01 00:37:25 2009 -0700
-@@ -0,0 +1,6 @@
-+File=split_buf_pool_mutex_fixed_optimistic_safe.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.83-b17-20090723/userstatv2.patch b/percona/5.0.83-b17-20090723/userstatv2.patch
deleted file mode 100644
index bdcf2f1..0000000
--- a/percona/5.0.83-b17-20090723/userstatv2.patch
+++ /dev/null
@@ -1,4386 +0,0 @@
-diff -r b2a2c62a6d53 BUILD/Makefile.in
---- a/BUILD/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/BUILD/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 Docs/Makefile.in
---- a/Docs/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/Docs/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 Makefile.in
---- a/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 SSL/Makefile.in
---- a/SSL/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/SSL/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 client/Makefile.in
---- a/client/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/client/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 configure
---- a/configure Fri Jul 03 15:40:29 2009 -0700
-+++ b/configure Fri Jul 03 15:40:35 2009 -0700
-@@ -35333,7 +35333,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38777,7 +38861,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r b2a2c62a6d53 configure.in
---- a/configure.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/configure.in Fri Jul 03 15:40:35 2009 -0700
-@@ -2122,7 +2122,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2758,7 +2769,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r b2a2c62a6d53 dbug/Makefile.in
---- a/dbug/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/dbug/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/Makefile.in
---- a/extra/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 heap/Makefile.in
---- a/heap/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/heap/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 include/Makefile.in
---- a/include/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/include/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 include/mysql_com.h
---- a/include/mysql_com.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/include/mysql_com.h Fri Jul 03 15:40:35 2009 -0700
-@@ -106,6 +106,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r b2a2c62a6d53 libmysql/Makefile.in
---- a/libmysql/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/libmysql/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/libmysql_r/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/libmysqld/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 man/Makefile.in
---- a/man/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/man/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 myisam/Makefile.in
---- a/myisam/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/myisam/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/myisammrg/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysql-test/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysql-test/r/information_schema.result Fri Jul 03 15:40:35 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
-diff -r b2a2c62a6d53 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Fri Jul 03 15:40:35 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r b2a2c62a6d53 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Fri Jul 03 15:40:35 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r b2a2c62a6d53 mysys/Makefile.in
---- a/mysys/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/mysys/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/Makefile.in
---- a/ndb/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/docs/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/include/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/src/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/ndb/tools/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 netware/Makefile.in
---- a/netware/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/netware/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 os2/Makefile.in
---- a/os2/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/os2/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 os2/include/Makefile.in
---- a/os2/include/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/os2/include/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/os2/include/sys/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Fri Jul 03 15:40:35 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r b2a2c62a6d53 pstack/Makefile.in
---- a/pstack/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/pstack/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/pstack/aout/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 regex/Makefile.in
---- a/regex/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/regex/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 scripts/Makefile.in
---- a/scripts/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/scripts/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 server-tools/Makefile.in
---- a/server-tools/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/server-tools/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 sql/Makefile.in
---- a/sql/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -3338,6 +3338,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3610,6 +3612,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3657,6 +3661,8 @@
- innodb_srv_conc_enter_innodb(prebuilt->trx);
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-+
-+ if (error == DB_SUCCESS) rows_changed++;
-
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
-@@ -4089,6 +4095,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r b2a2c62a6d53 sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/ha_myisam.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1518,13 +1520,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1535,6 +1541,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1545,6 +1558,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1555,6 +1575,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1565,6 +1592,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1575,6 +1609,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1585,6 +1626,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1595,6 +1643,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1611,6 +1666,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1628,6 +1690,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1642,6 +1705,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r b2a2c62a6d53 sql/handler.cc
---- a/sql/handler.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/handler.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r b2a2c62a6d53 sql/handler.h
---- a/sql/handler.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/handler.h Fri Jul 03 15:40:35 2009 -0700
-@@ -30,6 +30,10 @@
- #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
- defined(HAVE_NDBCLUSTER_DB)
- #define USING_TRANSACTIONS
-+#endif
-+
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
- #endif
-
- // the following is for checking tables
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r b2a2c62a6d53 sql/lex.h
---- a/sql/lex.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/lex.h Fri Jul 03 15:40:35 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r b2a2c62a6d53 sql/log.cc
---- a/sql/log.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/log.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r b2a2c62a6d53 sql/mysql_priv.h
---- a/sql/mysql_priv.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/mysql_priv.h Fri Jul 03 15:40:35 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r b2a2c62a6d53 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r b2a2c62a6d53 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r b2a2c62a6d53 sql/share/Makefile.in
---- a/sql/share/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/share/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 sql/sql_base.cc
---- a/sql/sql_base.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_base.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r b2a2c62a6d53 sql/sql_class.cc
---- a/sql/sql_class.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_class.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r b2a2c62a6d53 sql/sql_class.h
---- a/sql/sql_class.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_class.h Fri Jul 03 15:40:35 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,7 +1943,13 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-+
-+ char *get_client_host_port(THD *client);
-
- public:
- /**
-@@ -1935,6 +1993,11 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-+#define LIST_PROCESS_HOST_LEN 64
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r b2a2c62a6d53 sql/sql_delete.cc
---- a/sql/sql_delete.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_delete.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -887,6 +888,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r b2a2c62a6d53 sql/sql_insert.cc
---- a/sql/sql_insert.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_insert.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -989,6 +989,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3064,6 +3065,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r b2a2c62a6d53 sql/sql_lex.h
---- a/sql/sql_lex.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_lex.h Fri Jul 03 15:40:35 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r b2a2c62a6d53 sql/sql_parse.cc
---- a/sql/sql_parse.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_parse.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -145,6 +151,17 @@
- #ifndef EMBEDDED_LIBRARY
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-+
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- net->vio && net->error && net->report_error)
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4540,6 +4995,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4848,6 +5312,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5692,6 +6157,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5727,6 +6193,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5759,11 +6226,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5797,6 +6268,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5829,6 +6301,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5860,6 +6333,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5913,8 +6392,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5931,9 +6410,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6442,6 +6924,30 @@
- */
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
-@@ -6521,6 +7027,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7532,8 +8075,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r b2a2c62a6d53 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_prepare.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -80,6 +80,9 @@
- #else
- #include <mysql_com.h>
- #endif
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-
- /* A result class used to send cursor rows using the binary protocol. */
-
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2502,6 +2716,43 @@
- stmt->state= Query_arena::PREPARED;
-
- send_ok(thd);
-+
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-
- DBUG_VOID_RETURN;
- }
-diff -r b2a2c62a6d53 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,10 +4912,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r b2a2c62a6d53 sql/sql_update.cc
---- a/sql/sql_update.cc Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_update.cc Fri Jul 03 15:40:35 2009 -0700
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r b2a2c62a6d53 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/sql_yacc.yy Fri Jul 03 15:40:35 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r b2a2c62a6d53 sql/structs.h
---- a/sql/structs.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/structs.h Fri Jul 03 15:40:35 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[USERNAME_LENGTH + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[USERNAME_LENGTH + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r b2a2c62a6d53 sql/table.h
---- a/sql/table.h Fri Jul 03 15:40:29 2009 -0700
-+++ b/sql/table.h Fri Jul 03 15:40:35 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r b2a2c62a6d53 strings/Makefile.in
---- a/strings/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/strings/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 support-files/Makefile.in
---- a/support-files/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/support-files/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 tests/Makefile.in
---- a/tests/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/tests/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 tools/Makefile.in
---- a/tools/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/tools/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 vio/Makefile.in
---- a/vio/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/vio/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 win/Makefile.in
---- a/win/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/win/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r b2a2c62a6d53 zlib/Makefile.in
---- a/zlib/Makefile.in Fri Jul 03 15:40:29 2009 -0700
-+++ b/zlib/Makefile.in Fri Jul 03 15:40:35 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.84-b18-20090811/README-GENTOO b/percona/5.0.84-b18-20090811/README-GENTOO
deleted file mode 100644
index 06b2234..0000000
--- a/percona/5.0.84-b18-20090811/README-GENTOO
+++ /dev/null
@@ -1,7 +0,0 @@
-The following patches, while distributed by Percona, are NOT applied in their
-specfile. As such, we do not apply them in Gentoo either:
-=========
-innodb_extra_status.patch
-innodb_io_tune.patch
-innodb_show_hashed_memory_standalone.patch
-mirror_binlog.patch
diff --git a/percona/5.0.84-b18-20090811/innodb_check_fragmentation.patch b/percona/5.0.84-b18-20090811/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.84-b18-20090811/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.84-b18-20090811/innodb_dict_size_limit.patch b/percona/5.0.84-b18-20090811/innodb_dict_size_limit.patch
deleted file mode 100644
index 843d043..0000000
--- a/percona/5.0.84-b18-20090811/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,483 +0,0 @@
-diff -r 6eeee157fd40 innobase/dict/dict0boot.c
---- a/innobase/dict/dict0boot.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0boot.c Fri Jul 03 15:41:41 2009 -0700
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -r 6eeee157fd40 innobase/dict/dict0crea.c
---- a/innobase/dict/dict0crea.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0crea.c Fri Jul 03 15:41:41 2009 -0700
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1266,6 +1269,11 @@
- que_graph_free(graph);
-
- trx->op_info = "";
-+
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-
- row_mysql_unlock_data_dictionary(trx);
-
-diff -r 6eeee157fd40 innobase/dict/dict0dict.c
---- a/innobase/dict/dict0dict.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/dict/dict0dict.c Fri Jul 03 15:41:41 2009 -0700
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -786,6 +790,8 @@
-
- table->n_mysql_handles_opened++;
- }
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
--
-- ut_error;
--
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(dict_sys->mutex)));
--#endif /* UNIV_SYNC_DEBUG */
--
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-+
-+ //ut_error;
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ ut_ad(mutex_own(&(dict_sys->mutex)));
-+#endif /* UNIV_SYNC_DEBUG */
-+
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1342,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-diff -r 6eeee157fd40 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/ibuf/ibuf0ibuf.c Fri Jul 03 15:41:41 2009 -0700
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -r 6eeee157fd40 innobase/include/dict0dict.h
---- a/innobase/include/dict0dict.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/dict0dict.h Fri Jul 03 15:41:41 2009 -0700
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -r 6eeee157fd40 innobase/include/dict0dict.ic
---- a/innobase/include/dict0dict.ic Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/dict0dict.ic Fri Jul 03 15:41:41 2009 -0700
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -r 6eeee157fd40 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_dict_size_limit;
-
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
-@@ -552,6 +554,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -r 6eeee157fd40 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:34 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_dict_size_limit = 0;
-
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
-@@ -1953,6 +1955,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -r 6eeee157fd40 mysql-test/r/innodb_dict_size_limit.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/innodb_dict_size_limit.result Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -r 6eeee157fd40 mysql-test/t/innodb_dict_size_limit.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/innodb_dict_size_limit.test Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -r 6eeee157fd40 patch_info/innodb_dict_size_limit.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_dict_size_limit.info Fri Jul 03 15:41:41 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
-diff -r 6eeee157fd40 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -r 6eeee157fd40 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-@@ -243,6 +243,7 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -r 6eeee157fd40 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5464,6 +5465,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -r 6eeee157fd40 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:34 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-@@ -540,6 +540,8 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -930,6 +932,7 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1084,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/innodb_extra_rseg.patch b/percona/5.0.84-b18-20090811/innodb_extra_rseg.patch
deleted file mode 100644
index cab3b26..0000000
--- a/percona/5.0.84-b18-20090811/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -r 85e7025cf2d1 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:47 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_extra_rsegments;
-
- extern ulint srv_dict_size_limit;
-
-diff -r 85e7025cf2d1 innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/trx0sys.h Fri Jul 03 15:41:47 2009 -0700
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -r 85e7025cf2d1 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:47 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-
- ulint srv_dict_size_limit = 0;
-
-diff -r 85e7025cf2d1 innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0start.c Fri Jul 03 15:41:47 2009 -0700
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -r 85e7025cf2d1 innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:47 2009 -0700
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -r 85e7025cf2d1 patch_info/innodb_extra_rseg.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_rseg.info Fri Jul 03 15:41:47 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -r 85e7025cf2d1 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1521,6 +1522,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -r 85e7025cf2d1 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:47 2009 -0700
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -r 85e7025cf2d1 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
-@@ -5465,6 +5466,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -r 85e7025cf2d1 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -1087,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -r 85e7025cf2d1 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4180,6 +4182,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4996,6 +5037,16 @@
- {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
- {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
- #endif
-@@ -5177,6 +5228,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.84-b18-20090811/innodb_extra_status.patch b/percona/5.0.84-b18-20090811/innodb_extra_status.patch
deleted file mode 100644
index adc1642..0000000
--- a/percona/5.0.84-b18-20090811/innodb_extra_status.patch
+++ /dev/null
@@ -1,747 +0,0 @@
-diff -r b059d02ec814 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -2353,6 +2353,7 @@
- "AWE: Database pages and free buffers mapped in frames %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
-+ if (file) {
- fprintf(file,
- "Buffer pool size %lu\n"
- "Free buffers %lu\n"
-@@ -2371,11 +2372,13 @@
- + buf_pool->init_flush[BUF_FLUSH_LIST],
- (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
-
-+ } // if (file)
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time,
- buf_pool->last_printout_time);
- buf_pool->last_printout_time = current_time;
-
-+ if (file) {
- fprintf(file,
- "Pages read %lu, created %lu, written %lu\n"
- "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
-@@ -2405,6 +2408,7 @@
- } else {
- fputs("No buffer pool page gets since the last printout\n",
- file);
-+ }
- }
-
- buf_pool->n_page_gets_old = buf_pool->n_page_gets;
-diff -r b059d02ec814 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -3519,9 +3519,15 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ inno_ibuf_size = 0;
-+ inno_ibuf_inserts = 0;
-+ inno_ibuf_merged_recs = 0;
-+ inno_ibuf_merges = 0;
-+
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
-+ if (file) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
-@@ -3542,6 +3548,12 @@
- }
- }
- #endif
-+ } // if (file)
-+ inno_ibuf_size += (ulong) data->size;
-+ inno_ibuf_inserts += (ulong) data->n_inserts;
-+ inno_ibuf_merged_recs += (ulong) data->n_merged_recs;
-+ inno_ibuf_merges += (ulong) data->n_merges;
-+
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
-diff -r b059d02ec814 innobase/include/lock0lock.h
---- a/innobase/include/lock0lock.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/lock0lock.h Mon Nov 03 05:09:34 2008 -0800
-@@ -24,6 +24,10 @@
- #endif /* UNIV_DEBUG */
- /* Buffer for storing information about the most recent deadlock error */
- extern FILE* lock_latest_err_file;
-+
-+/* number of deadlocks happened so far */
-+extern ulint innodb_deadlocks;
-+
-
- /*************************************************************************
- Gets the size of a lock struct. */
-diff -r b059d02ec814 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:09:34 2008 -0800
-@@ -261,6 +261,12 @@
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+extern ibool srv_long_lock_wait;
-+
-+/* variable to count the number long semaphore waits noticed */
-+extern ulint srv_long_lock_waits;
-+
- /* Number of IO operations read/write done for all threads */
- extern ulint os_aio_read_requests;
- extern ulint os_aio_write_requests;
-@@ -278,6 +284,26 @@
- extern ulint inno_pending_ibuf_aio_reads;
- extern ulint inno_pending_log_ios;
- extern ulint inno_pending_sync_ios;
-+
-+/* all 24 innodb status variables, exported to status */
-+extern ulint inno_transaction_count;
-+extern ulint inno_transaction_purge_count;
-+extern ulint inno_transaction_purge_lag;
-+extern ulint inno_num_active_transactions;
-+extern ulint inno_summed_transaction_age;
-+extern ulint inno_longest_transaction_age;
-+extern ulint inno_lock_wait_timeouts;
-+extern ulint inno_num_lock_waiters;
-+extern ulint inno_summed_lock_wait_time;
-+extern ulint inno_longest_lock_wait;
-+extern ulint inno_os_reads;
-+extern ulint inno_os_writes;
-+extern ulint inno_os_fsyncs;
-+extern ulint inno_ibuf_size;
-+extern ulint inno_ibuf_inserts;
-+extern ulint inno_ibuf_merged_recs;
-+extern ulint inno_ibuf_merges;
-+extern ulint inno_log_ios_done;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-@@ -552,6 +578,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_size;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-@@ -587,6 +614,43 @@
- ulint innodb_rows_inserted;
- ulint innodb_rows_updated;
- ulint innodb_rows_deleted;
-+ ibool innodb_long_lock_wait;
-+ ulint innodb_long_lock_waits;
-+
-+ ulint innodb_os_aio_read_requests;
-+ ulint innodb_os_aio_write_requests;
-+ ulint innodb_os_aio_pages_read;
-+ ulint innodb_os_aio_pages_written;
-+ ib_longlong innodb_os_aio_read_time;
-+ ib_longlong innodb_os_aio_write_time;
-+ ib_longlong innodb_os_aio_read_time_avg;
-+ ib_longlong innodb_os_aio_write_time_avg;
-+ ulint innodb_deadlocks;
-+
-+ // the following 24 variables are exported to "show status"
-+ ulint inno_transaction_count;
-+ ulint inno_transaction_purge_count;
-+ ulint inno_transaction_purge_lag;
-+ ulint inno_num_active_transactions;
-+ ulint inno_summed_transaction_age;
-+ ulint inno_longest_transaction_age;
-+ ulint inno_lock_wait_timeouts;
-+ ulint inno_num_lock_waiters;
-+ ulint inno_summed_lock_wait_time;
-+ ulint inno_longest_lock_wait;
-+ ulint inno_pending_normal_aio_reads;
-+ ulint inno_pending_normal_aio_writes;
-+ ulint inno_pending_ibuf_aio_reads;
-+ ulint inno_pending_log_ios;
-+ ulint inno_pending_sync_ios;
-+ ulint inno_os_reads;
-+ ulint inno_os_writes;
-+ ulint inno_os_fsyncs;
-+ ulint inno_ibuf_size;
-+ ulint inno_ibuf_inserts;
-+ ulint inno_ibuf_merged_recs;
-+ ulint inno_ibuf_merges;
-+ ulint inno_log_ios_done;
- };
-
- /* The server system struct */
-diff -r b059d02ec814 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Nov 03 05:09:34 2008 -0800
-@@ -360,6 +360,9 @@
- ibool lock_deadlock_found = FALSE;
- FILE* lock_latest_err_file;
-
-+/* number of deadlocks happened so far */
-+ulint innodb_deadlocks = 0;
-+
- /* Flags for recursive deadlock search */
- #define LOCK_VICTIM_IS_START 1
- #define LOCK_VICTIM_IS_OTHER 2
-@@ -3304,6 +3307,7 @@
-
- FILE* ef = lock_latest_err_file;
-
-+ innodb_deadlocks++;
- rewind(ef);
- ut_print_timestamp(ef);
-
-@@ -4238,6 +4242,7 @@
- innobase_mysql_prepare_print_arbitrary_thd();
- lock_mutex_enter_kernel();
-
-+ if (file) {
- if (lock_deadlock_found) {
- fputs(
- "------------------------\n"
-@@ -4269,6 +4274,12 @@
- fprintf(file,
- "Total number of lock structs in row lock hash table %lu\n",
- (ulong) lock_get_n_rec_locks());
-+ } // if (file)
-+ inno_transaction_purge_count =
-+ (ulong) ut_dulint_get_low(purge_sys->purge_trx_no);
-+ inno_transaction_count =
-+ (ulong) ut_dulint_get_low(trx_sys->max_trx_id);
-+ inno_transaction_purge_lag = (ulong) trx_sys->rseg_history_len;
- }
-
- /*************************************************************************
-@@ -4289,7 +4300,17 @@
- ulint i;
- mtr_t mtr;
- trx_t* trx;
--
-+ time_t current_time = time(NULL);
-+
-+ /* init all counters to be updated */
-+ inno_num_lock_waiters = 0;
-+ inno_summed_lock_wait_time = 0;
-+ inno_longest_lock_wait = 0;
-+ inno_num_active_transactions = 0;
-+ inno_summed_transaction_age = 0;
-+ inno_longest_transaction_age = 0;
-+
-+ if (file) {
- fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
-
- /* First print info on non-active transactions */
-@@ -4304,6 +4325,7 @@
-
- trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
- }
-+ } // if (file)
-
- loop:
- trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
-@@ -4330,6 +4352,7 @@
- }
-
- if (nth_lock == 0) {
-+ if (file) {
- fputs("---", file);
- trx_print(file, trx, 600);
-
-@@ -4341,11 +4364,27 @@
- (ulong) ut_dulint_get_high(trx->read_view->up_limit_id),
- (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
- }
-+ } // if (file)
-+
-+ if (trx->conc_state == TRX_ACTIVE) {
-+ ulong trx_age = (ulong)difftime(time(NULL), trx->start_time);
-+ inno_num_active_transactions++;
-+ inno_summed_transaction_age += trx_age;
-+ if (inno_longest_transaction_age > trx_age)
-+ inno_longest_transaction_age = trx_age;
-+ }
-
- if (trx->que_state == TRX_QUE_LOCK_WAIT) {
-+ ulong wait_time = (ulong)difftime(current_time,
-+ trx->wait_started);
-+ inno_num_lock_waiters++;
-+ inno_summed_lock_wait_time += wait_time;
-+ if (inno_longest_lock_wait < wait_time)
-+ inno_longest_lock_wait = wait_time;
-+ if (file) {
- fprintf(file,
- "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
-- (ulong)difftime(time(NULL), trx->wait_started));
-+ wait_time);
-
- if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(file, trx->wait_lock);
-@@ -4354,10 +4393,16 @@
- }
-
- fputs("------------------\n", file);
-- }
-- }
--
-- if (!srv_print_innodb_lock_monitor) {
-+ } // if (file)
-+ }
-+ }
-+
-+ /* don't print locks per transaction if either
-+ 1) srv_print_innodb_lock_monitor is NOT set,
-+ ie no magic table innodb_lock_monitor is created, or
-+ 2) file == NULL, ie, at counter updating stage from "show status"
-+ */
-+ if (!srv_print_innodb_lock_monitor || !file) {
- nth_trx++;
- goto loop;
- }
-diff -r b059d02ec814 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:09:34 2008 -0800
-@@ -267,6 +267,35 @@
- ulint inno_pending_log_ios = 0;
- ulint inno_pending_sync_ios = 0;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+ibool srv_long_lock_wait = FALSE;
-+
-+/* variable to count the number long semaphore waits noticed */
-+ulint srv_long_lock_waits = 0;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+extern long innobase_min_status_update_time_interval;
-+
-+/* all 24 innodb status variables, exported to status */
-+ulint inno_transaction_count = 0;
-+ulint inno_transaction_purge_count = 0;
-+ulint inno_transaction_purge_lag = 0;
-+ulint inno_num_active_transactions = 0;
-+ulint inno_summed_transaction_age = 0;
-+ulint inno_longest_transaction_age = 0;
-+ulint inno_lock_wait_timeouts = 0; /* Counts number of lock wait timeouts. */
-+ulint inno_num_lock_waiters = 0;
-+ulint inno_summed_lock_wait_time = 0;
-+ulint inno_longest_lock_wait = 0;
-+ulint inno_os_reads = 0;
-+ulint inno_os_writes = 0;
-+ulint inno_os_fsyncs = 0;
-+ulint inno_ibuf_size = 0;
-+ulint inno_ibuf_inserts = 0;
-+ulint inno_ibuf_merged_recs = 0;
-+ulint inno_ibuf_merges = 0;
-+ulint inno_log_ios_done = 0;
-+
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-
-@@ -419,6 +448,10 @@
- const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
-
- time_t srv_last_monitor_time;
-+
-+/* last time innodb status were updated thru show status */
-+time_t srv_last_innodb_status_time = 0;
-+
-
- mutex_t srv_innodb_monitor_mutex;
-
-@@ -677,6 +710,24 @@
-
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-+
-+/*************************************************************************
-+Prints counters for work done by srv_master_thread. */
-+
-+static
-+void
-+srv_print_extra(
-+/*===================*/
-+ FILE *file) /* in: output stream */
-+{
-+ fprintf(file, "srv_master_thread loops: %lu 1_second, %lu sleeps, "
-+ "%lu 10_second, %lu background, %lu flush\n",
-+ srv_main_1_second_loops, srv_main_sleeps,
-+ srv_main_10_second_loops, srv_main_background_loops,
-+ srv_main_flush_loops);
-+ fprintf(file, "srv_master_thread log flush: %lu sync, %lu async\n",
-+ srv_sync_flush, srv_async_flush);
-+}
-
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-@@ -1685,12 +1736,13 @@
- fputs("----------\n"
- "BACKGROUND THREAD\n"
- "----------\n", file);
-+ srv_print_extra(file);
- fil_print(file);
--
-
- fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
-+ fprintf(file, "Lock wait timeouts %lu\n", inno_lock_wait_timeouts);
- sync_print(file);
-
- /* Conceptually, srv_innodb_monitor_mutex has a very high latching
-@@ -1709,24 +1761,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1815,6 +1849,27 @@
- (srv_n_rows_read - srv_n_rows_read_old)
- / time_elapsed);
-
-+ /* Print open transaction details */
-+ lock_print_info_summary(file);
-+
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- srv_n_rows_inserted_old = srv_n_rows_inserted;
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
-@@ -1833,7 +1888,8 @@
- void
- srv_export_innodb_status(void)
- {
--
-+ long time_elapsed;
-+ time_t current_time;
- mutex_enter(&srv_innodb_monitor_mutex);
- export_vars.innodb_data_pending_reads= os_n_pending_reads;
- export_vars.innodb_data_pending_writes= os_n_pending_writes;
-@@ -1844,6 +1900,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_size= dict_sys->size;
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-@@ -1854,10 +1911,12 @@
- export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
- export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
- export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
-- export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
-+ /* This function uses too much CPU for large buffer caches. */
-+ export_vars.innodb_buffer_pool_pages_latched= 1; /* buf_get_latched_pages_number(); */
- export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
- export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
- UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
-+
- export_vars.innodb_page_size= UNIV_PAGE_SIZE;
- export_vars.innodb_log_waits= srv_log_waits;
- export_vars.innodb_os_log_written= srv_os_log_written;
-@@ -1885,6 +1944,103 @@
- export_vars.innodb_rows_inserted= srv_n_rows_inserted;
- export_vars.innodb_rows_updated= srv_n_rows_updated;
- export_vars.innodb_rows_deleted= srv_n_rows_deleted;
-+ export_vars.innodb_long_lock_wait = srv_long_lock_wait;
-+ export_vars.innodb_long_lock_waits = srv_long_lock_waits;
-+
-+ export_vars.innodb_os_aio_read_requests = os_aio_read_requests;
-+ export_vars.innodb_os_aio_write_requests = os_aio_write_requests;
-+
-+ export_vars.innodb_os_aio_pages_read = os_aio_pages_read;
-+ export_vars.innodb_os_aio_pages_written = os_aio_pages_written;
-+
-+ export_vars.innodb_os_aio_read_time = os_aio_read_time;
-+ export_vars.innodb_os_aio_write_time = os_aio_write_time;
-+
-+ if (os_aio_read_requests > 0 ) {
-+ export_vars.innodb_os_aio_read_time_avg
-+ = os_aio_read_time / os_aio_read_requests;
-+ } else {
-+ export_vars.innodb_os_aio_read_time_avg = 0;
-+ }
-+ if (os_aio_write_requests > 0 ) {
-+ export_vars.innodb_os_aio_write_time_avg
-+ = os_aio_write_time / os_aio_write_requests;
-+ } else {
-+ export_vars.innodb_os_aio_write_time_avg = 0;
-+ }
-+
-+ export_vars.innodb_deadlocks = innodb_deadlocks;
-+
-+ // simulate srv_printf_innodb_monitor, invoked by innodb_show_status
-+ // 0. direct printout inno_lock_wait_timeouts, declared in srv0srv.c
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_lock_wait_timeouts = inno_lock_wait_timeouts;
-+
-+ // *_print functions are allowed to be called once every
-+ // some seconds to prevent too frequent invocation.
-+ // the number is innobase_min_status_update_time_interval
-+ current_time = time(NULL);
-+ time_elapsed = difftime(current_time, srv_last_innodb_status_time);
-+ if (time_elapsed >= innobase_min_status_update_time_interval) {
-+ os_aio_print(NULL);
-+ ibuf_print(NULL);
-+ buf_print_io(NULL);
-+ lock_print_info_summary(NULL);
-+ lock_print_info_all_transactions(NULL);
-+
-+ srv_last_innodb_status_time = current_time;
-+ }
-+
-+ // 1. os_aio_print
-+ // the following were filled by calling os_aio_print
-+ // total # of variable(s) updated: 8
-+
-+ export_vars.inno_pending_normal_aio_reads =
-+ inno_pending_normal_aio_reads;
-+ export_vars.inno_pending_normal_aio_writes =
-+ inno_pending_normal_aio_writes;
-+ export_vars.inno_pending_ibuf_aio_reads = inno_pending_ibuf_aio_reads;
-+ export_vars.inno_pending_log_ios = inno_pending_log_ios;
-+ export_vars.inno_pending_sync_ios = inno_pending_sync_ios;
-+ export_vars.inno_os_reads = os_n_file_reads;
-+ export_vars.inno_os_writes = os_n_file_writes;
-+ export_vars.inno_os_fsyncs = os_n_fsyncs;
-+
-+ // 2. ibuf_print()
-+ // total # of variable(s) updated: 4
-+
-+ export_vars.inno_ibuf_size = inno_ibuf_size;
-+ export_vars.inno_ibuf_inserts = inno_ibuf_inserts;
-+ export_vars.inno_ibuf_merged_recs = inno_ibuf_merged_recs;
-+ export_vars.inno_ibuf_merges = inno_ibuf_merges;
-+
-+ // 3. log_print
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_log_ios_done = (ulong) log_sys->n_log_ios;
-+
-+ // 5. lock_print_info_summary
-+ // it enters the mutexes
-+ // 1) innobase_mysql_prepare_print_arbitrary_thd()
-+ // 2) lock_mutex_enter_kernel()
-+ // total # of variable(s) updated: 3
-+
-+ export_vars.inno_transaction_count = inno_transaction_count;
-+ export_vars.inno_transaction_purge_count =
-+ inno_transaction_purge_count;
-+ export_vars.inno_transaction_purge_lag = inno_transaction_purge_lag;
-+
-+ // 6. lock_print_info_all_transactions(NULL)
-+ // it exits two mutexes entered from lock_print_info_summary(NULL)
-+ // total # of variable(s) updated: 6
-+
-+ export_vars.inno_num_active_transactions = inno_num_active_transactions;
-+ export_vars.inno_summed_transaction_age = inno_summed_transaction_age;
-+ export_vars.inno_longest_transaction_age = inno_longest_transaction_age;
-+
-+ export_vars.inno_num_lock_waiters = inno_num_lock_waiters;
-+ export_vars.inno_summed_lock_wait_time = inno_summed_lock_wait_time;
-+ export_vars.inno_longest_lock_wait = inno_longest_lock_wait;
-+
- mutex_exit(&srv_innodb_monitor_mutex);
-
- }
-@@ -2026,6 +2182,7 @@
- if (thr_get_trx(slot->thr)->wait_lock) {
- lock_cancel_waiting_and_release(
- thr_get_trx(slot->thr)->wait_lock);
-+ ++inno_lock_wait_timeouts;
- }
- }
- }
-diff -r b059d02ec814 patch_info/innodb_extra_status.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_status.info Mon Nov 03 05:09:34 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_extra_status.patch
-+Name=Adds additional information of InnoDB counters into SHOW STATUS
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-03
-+VT: Initial porting
-diff -r b059d02ec814 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -299,12 +299,36 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_size",
-+ (char*) &export_vars.innodb_dict_size, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
- {"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
-+ {"long_lock_wait",
-+ (char*) &export_vars.innodb_long_lock_wait, SHOW_BOOL},
-+ {"long_lock_waits",
-+ (char*) &export_vars.innodb_long_lock_waits, SHOW_LONG},
-+
-+ {"os_read_requests",
-+ (char*) &export_vars.innodb_os_aio_read_requests, SHOW_LONG},
-+ {"os_write_requests",
-+ (char*) &export_vars.innodb_os_aio_write_requests, SHOW_LONG},
-+ {"os_pages_read",
-+ (char*) &export_vars.innodb_os_aio_pages_read, SHOW_LONG},
-+ {"os_pages_written",
-+ (char*) &export_vars.innodb_os_aio_pages_written, SHOW_LONG},
-+ {"os_read_time",
-+ (char*) &export_vars.innodb_os_aio_read_time, SHOW_LONGLONG},
-+ {"os_write_time",
-+ (char*) &export_vars.innodb_os_aio_write_time, SHOW_LONGLONG},
-+ {"time_per_read",
-+ (char*) &export_vars.innodb_os_aio_read_time_avg, SHOW_LONGLONG},
-+ {"time_per_write",
-+ (char*) &export_vars.innodb_os_aio_write_time_avg, SHOW_LONGLONG},
-+
- {"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
- {"os_log_pending_fsyncs",
-@@ -339,6 +363,56 @@
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
- {"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
-+ {"deadlocks",
-+ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
-+
-+ /* 24 innodb status variables exported to status */
-+ {"transaction_count",
-+ (char*) &export_vars.inno_transaction_count, SHOW_LONG},
-+ {"transaction_purge_count",
-+ (char*) &export_vars.inno_transaction_purge_count, SHOW_LONG},
-+ {"transaction_purge_lag",
-+ (char*) &export_vars.inno_transaction_purge_lag, SHOW_LONG},
-+ {"active_transactions",
-+ (char*) &export_vars.inno_num_active_transactions, SHOW_LONG},
-+ {"summed_transaction_age",
-+ (char*) &export_vars.inno_summed_transaction_age, SHOW_LONG},
-+ {"longest_transaction_age",
-+ (char*) &export_vars.inno_longest_transaction_age, SHOW_LONG},
-+ {"lock_wait_timeouts",
-+ (char*) &export_vars.inno_lock_wait_timeouts, SHOW_LONG},
-+ {"lock_waiters",
-+ (char*) &export_vars.inno_num_lock_waiters, SHOW_LONG},
-+ {"summed_lock_wait_time",
-+ (char*) &export_vars.inno_summed_lock_wait_time, SHOW_LONG},
-+ {"longest_lock_wait",
-+ (char*) &export_vars.inno_longest_lock_wait, SHOW_LONG},
-+ {"pending_normal_aio_reads",
-+ (char*) &export_vars.inno_pending_normal_aio_reads, SHOW_LONG},
-+ {"pending_normal_aio_writes",
-+ (char*) &export_vars.inno_pending_normal_aio_writes, SHOW_LONG},
-+ {"pending_ibuf_aio_reads",
-+ (char*) &export_vars.inno_pending_ibuf_aio_reads, SHOW_LONG},
-+ {"pending_log_ios",
-+ (char*) &export_vars.inno_pending_log_ios, SHOW_LONG},
-+ {"pending_sync_ios",
-+ (char*) &export_vars.inno_pending_sync_ios, SHOW_LONG},
-+ {"os_reads",
-+ (char*) &export_vars.inno_os_reads, SHOW_LONG},
-+ {"os_writes",
-+ (char*) &export_vars.inno_os_writes, SHOW_LONG},
-+ {"os_fsyncs",
-+ (char*) &export_vars.inno_os_fsyncs, SHOW_LONG},
-+ {"ibuf_inserts",
-+ (char*) &export_vars.inno_ibuf_size, SHOW_LONG},
-+ {"ibuf_size",
-+ (char*) &export_vars.inno_ibuf_inserts, SHOW_LONG},
-+ {"ibuf_merged_recs",
-+ (char*) &export_vars.inno_ibuf_merged_recs, SHOW_LONG},
-+ {"ibuf_merges",
-+ (char*) &export_vars.inno_ibuf_merges, SHOW_LONG},
-+ {"log_ios_done",
-+ (char*) &export_vars.inno_log_ios_done, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}};
-
- /* General functions */
-diff -r b059d02ec814 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:09:34 2008 -0800
-@@ -198,6 +198,7 @@
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
- extern long innobase_max_merged_io;
-+extern long innobase_min_status_update_time_interval;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-diff -r b059d02ec814 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -4950,6 +4950,7 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -6031,6 +6032,14 @@
- (gptr*) &srv_thread_sleep_delay,
- (gptr*) &srv_thread_sleep_delay,
- 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
-+ {"innodb_status_update_interval",
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
-+ "Minimum time interval in seconds before InnoDB status counters "
-+ "are updated during SHOW STATUS. "
-+ "InnoDB counters are always updated during SHOW INNODB STATUS.",
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ 0, GET_LONG, REQUIRED_ARG, 30, 0, 3600, 0, 1, 0},
- #endif /* HAVE_INNOBASE_DB */
- {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
- "The number of seconds the server waits for activity on an interactive connection before closing it.",
-diff -r b059d02ec814 sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -948,6 +948,8 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
- {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
-+ {"innodb_status_update_interval",
-+ (char*) &innobase_min_status_update_time_interval, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/innodb_fsync_source.patch b/percona/5.0.84-b18-20090811/innodb_fsync_source.patch
deleted file mode 100644
index 2961b78..0000000
--- a/percona/5.0.84-b18-20090811/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r ef44d8017b6b innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:32 2009 -0700
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r ef44d8017b6b innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/fil/fil0fil.c Fri Jul 03 15:41:32 2009 -0700
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4167,8 +4188,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4177,7 +4199,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4282,7 +4304,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4323,7 +4346,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r ef44d8017b6b innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/fil0fil.h Fri Jul 03 15:41:32 2009 -0700
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -625,14 +632,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -640,7 +659,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r ef44d8017b6b innobase/include/log0log.h
---- a/innobase/include/log0log.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/log0log.h Fri Jul 03 15:41:32 2009 -0700
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Flushes the log buffer. Forces it to disk depending on the value of
-@@ -751,6 +774,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r ef44d8017b6b innobase/log/log0log.c
---- a/innobase/log/log0log.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/log/log0log.c Fri Jul 03 15:41:32 2009 -0700
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1574,7 +1590,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1944,11 +1960,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1961,7 +1977,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2589,7 +2606,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2670,7 +2687,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3207,8 +3225,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3241,7 +3259,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3363,15 +3381,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r ef44d8017b6b innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:32 2009 -0700
-@@ -1698,6 +1698,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r ef44d8017b6b innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:32 2009 -0700
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r ef44d8017b6b innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0trx.c Fri Jul 03 15:41:32 2009 -0700
-@@ -942,19 +942,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1701,18 +1703,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1948,19 +1953,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r ef44d8017b6b patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Fri Jul 03 15:41:32 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.84-b18-20090811/innodb_io_patches.patch b/percona/5.0.84-b18-20090811/innodb_io_patches.patch
deleted file mode 100644
index aaef29a..0000000
--- a/percona/5.0.84-b18-20090811/innodb_io_patches.patch
+++ /dev/null
@@ -1,1379 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-05-08 06:12:03.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-07-02 16:44:49.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-07-02 16:44:49.000000000 +0900
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +190,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +401,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-05-08 06:12:04.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-07-02 16:44:49.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/log0log.h b/innobase/include/log0log.h
---- a/innobase/include/log0log.h 2009-05-08 06:12:06.000000000 +0900
-+++ b/innobase/include/log0log.h 2009-07-02 16:44:49.000000000 +0900
-@@ -169,6 +169,13 @@
- log_buffer_flush_to_disk(void);
- /*==========================*/
- /********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
-+/*=============================*/
-+/********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
- buffer pool and also may make a new checkpoint. NOTE: this function may only
- be called if the calling thread owns no synchronization objects! */
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-07-02 16:44:49.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-02 18:02:38.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1524,6 +1524,29 @@
- }
-
- /********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*=============================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
-+}
-+/********************************************************************
- Tries to establish a big enough margin of free space in the log buffer, such
- that a new log entry can be catenated without an immediate need for a flush. */
- static
-@@ -3326,6 +3349,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-07-02 16:44:49.000000000 +0900
-@@ -66,6 +66,28 @@
-
- ibool os_aio_print_debug = FALSE;
-
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-+
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-
-@@ -74,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -84,11 +108,11 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
-+// ibool io_already_done;/* used only in simulated aio:
-+// TRUE if the physical i/o already
-+// made and only the slot message
-+// needs to be passed to the caller
-+// of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -137,6 +161,13 @@
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-+
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
- static os_aio_array_t* os_aio_read_array = NULL;
-@@ -145,11 +176,17 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
- /* If the following is TRUE, read i/o handler threads try to
- wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -2878,8 +2915,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2889,6 +2928,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2896,14 +2937,17 @@
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-+ os_aio_first_write_segment = os_aio_first_read_segment + n_read_threads;
- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-
- srv_io_thread_function[0] = "insert buffer thread";
-@@ -2912,14 +2956,14 @@
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-+ os_aio_read_array = os_aio_array_create(n_per_seg,
- n_read_segs);
- for (i = 2; i < 2 + n_read_segs; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
- srv_io_thread_function[i] = "read thread";
- }
-
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-+ os_aio_write_array = os_aio_array_create(n_per_seg,
- n_write_segs);
- for (i = 2 + n_read_segs; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-@@ -3181,6 +3225,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3199,6 +3250,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3206,6 +3267,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-@@ -3228,7 +3290,8 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+// slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3281,6 +3344,7 @@
- ut_ad(slot->reserved);
-
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3317,16 +3381,18 @@
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
- os_mutex_enter(array->mutex);
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
- /* Found an i/o request */
-
- break;
-@@ -3336,7 +3402,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3347,8 +3431,6 @@
- os_aio_simulated_wake_handler_threads(void)
- /*=======================================*/
- {
-- ulint i;
--
- if (os_aio_use_native_aio) {
- /* We do not use simulated aio: do nothing */
-
-@@ -3357,9 +3439,10 @@
-
- os_aio_recommend_sleep_for_read_threads = FALSE;
-
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ os_aio_simulated_wake_handler_thread(0);
-+ os_aio_simulated_wake_handler_thread(1);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_read_segment);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_write_segment);
- }
-
- /**************************************************************************
-@@ -3640,7 +3723,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
-@@ -3648,12 +3731,12 @@
- } else {
- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-+ (array->native_events));
- }
-
- os_mutex_enter(array->mutex);
-
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3830,10 +3913,13 @@
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3841,6 +3927,7 @@
- ibool ret;
- ulint n;
- ulint i;
-+ time_t now;
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-@@ -3853,7 +3940,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
-@@ -3875,9 +3962,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved && slot->io_already_done) {
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3897,67 +3984,57 @@
- then pick the one at the lowest offset. */
-
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-
-+ /* Find the oldest request and the request with the smallest offset */
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-- lowest_offset = slot->offset;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
-
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3965,7 +4042,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3994,6 +4072,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -4001,7 +4081,14 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -4012,6 +4099,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -4081,16 +4171,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4100,6 +4187,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-02 18:36:54.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -330,6 +332,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2228,6 +2248,10 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-+ dulint lsn_old;
-+
-+ dulint oldest_lsn;
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
-@@ -2244,6 +2268,9 @@
-
- mutex_exit(&kernel_mutex);
-
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- os_event_set(srv_sys->operational);
- loop:
- /*****************************************************************/
-@@ -2279,6 +2306,18 @@
- if (!skip_sleep) {
-
- os_thread_sleep(1000000);
-+ /*
-+ mutex_enter(&(log_sys->mutex));
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ dulint lsn = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ if (!ut_dulint_is_zero(oldest_lsn))
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old));
-+ */
- }
-
- skip_sleep = FALSE;
-@@ -2317,13 +2356,14 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2332,7 +2372,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2341,6 +2381,140 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (srv_adaptive_checkpoint == 1) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+ } else if (srv_adaptive_checkpoint == 2) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* defence line (max_checkpoint_age * 1/2) */
-+ dulint lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ ib_longlong level, bpl;
-+ buf_block_t* bpage;
-+
-+ mutex_enter(&buf_pool->mutex);
-+
-+ level = 0;
-+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-+
-+ while (bpage != NULL) {
-+ dulint oldest_modification = bpage->oldest_modification;
-+ if (!ut_dulint_is_zero(oldest_modification)) {
-+ level += log_sys->max_checkpoint_age
-+ - ut_dulint_minus(lsn, oldest_modification);
-+ }
-+ bpage = UT_LIST_GET_NEXT(flush_list, bpage);
-+ }
-+
-+ if (level) {
-+ bpl = ((ib_longlong) UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * ut_dulint_minus(lsn, lsn_old)) / level;
-+ } else {
-+ bpl = 0;
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+
-+ if (!srv_use_doublewrite_buf) {
-+ /* flush is faster than when doublewrite */
-+ bpl = (bpl * 3) / 4;
-+ }
-+
-+ if(bpl) {
-+retry_flush_batch:
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ bpl,
-+ ut_dulint_add(oldest_lsn,
-+ ut_dulint_minus(lsn,
-+ lsn_old)));
-+ if (n_pages_flushed == ULINT_UNDEFINED) {
-+ os_thread_sleep(5000);
-+ goto retry_flush_batch;
-+ }
-+ }
-+
-+ lsn_old = lsn;
-+ /*
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu, blocks to flush:%llu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old), bpl);
-+ */
-+ } else {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
-+ } else {
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2367,23 +2541,25 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2422,14 +2598,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2518,7 +2694,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2535,7 +2711,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2557,7 +2733,14 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-08 06:12:12.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-07-02 16:44:49.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-02 16:44:49.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1417,6 +1418,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7330,6 +7333,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-02 18:10:51.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,15 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
-+
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
- running with the fix disabled because MySQL 5.1 is frozen for such
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-02 18:00:04.000000000 +0900
-@@ -5086,6 +5086,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5403,6 +5413,44 @@
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 200, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. ([none], reflex, estimate)",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7644,6 +7692,38 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
-+ case OPT_INNODB_ADAPTIVE_CHECKPOINT:
-+ if (argument == disabled_my_option)
-+ srv_adaptive_checkpoint = 0;
-+ else if (! argument)
-+ srv_adaptive_checkpoint = 0;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_adaptive_checkpoint_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_adaptive_checkpoint type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_adaptive_checkpoint = (uint) ((type - 1) % 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-02 17:45:29.000000000 +0900
-@@ -489,6 +489,57 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+
-+const char *innodb_adaptive_checkpoint_names[]=
-+{
-+ "none", /* 0 */
-+ "reflex", /* 1 */
-+ "estimate", /* 2 */
-+ /* For compatibility of the older patch */
-+ "0", /* 3 ("none" + 3) */
-+ "1", /* 4 ("reflex" + 3) */
-+ "2", /* 5 ("estimate" + 3) */
-+ NullS
-+};
-+TYPELIB innodb_adaptive_checkpoint_typelib=
-+{
-+ array_elements(innodb_adaptive_checkpoint_names) - 1, "innodb_adaptive_checkpoint_typelib",
-+ innodb_adaptive_checkpoint_names, NULL
-+};
-+sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint,
-+ &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -860,6 +911,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -997,6 +1055,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -1459,6 +1527,18 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+
-+extern void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type)
-+{
-+ srv_adaptive_checkpoint %= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.h 2009-07-02 17:35:17.000000000 +0900
-@@ -31,6 +31,11 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+extern TYPELIB innodb_adaptive_checkpoint_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1153,10 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.84-b18-20090811/innodb_io_pattern.patch b/percona/5.0.84-b18-20090811/innodb_io_pattern.patch
deleted file mode 100644
index d9e60e9..0000000
--- a/percona/5.0.84-b18-20090811/innodb_io_pattern.patch
+++ /dev/null
@@ -1,693 +0,0 @@
-diff -r d4826c0a98c2 include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 10:00:12 2009 -0700
-@@ -122,6 +122,9 @@
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-+
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
- #define CLIENT_LONG_FLAG 4 /* Get all column flags */
-diff -r d4826c0a98c2 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/buf/buf0buf.c Wed Jul 29 10:00:12 2009 -0700
-@@ -654,6 +654,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1967,6 +1970,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2068,6 +2074,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2083,6 +2109,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2657,3 +2703,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r d4826c0a98c2 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0buf.h Wed Jul 29 10:00:12 2009 -0700
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r d4826c0a98c2 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0types.h Wed Jul 29 10:00:12 2009 -0700
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r d4826c0a98c2 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/srv0srv.h Wed Jul 29 10:00:12 2009 -0700
-@@ -146,6 +146,11 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r d4826c0a98c2 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/srv/srv0srv.c Wed Jul 29 10:00:12 2009 -0700
-@@ -352,6 +352,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r d4826c0a98c2 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 10:00:12 2009 -0700
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r d4826c0a98c2 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 10:00:12 2009 -0700
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r d4826c0a98c2 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 10:00:12 2009 -0700
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r d4826c0a98c2 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Wed Jul 29 10:00:12 2009 -0700
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r d4826c0a98c2 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -1583,6 +1583,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6551,6 +6553,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r d4826c0a98c2 sql/ha_innodb.h
---- a/sql/ha_innodb.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.h Wed Jul 29 10:00:12 2009 -0700
-@@ -245,6 +245,9 @@
- extern uint srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-@@ -278,6 +281,9 @@
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-+
- void innobase_release_temporary_latches(THD *thd);
-
- void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
-diff -r d4826c0a98c2 sql/lex.h
---- a/sql/lex.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 10:00:12 2009 -0700
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r d4826c0a98c2 sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -5029,6 +5029,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5461,6 +5464,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r d4826c0a98c2 sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -546,6 +546,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -926,6 +932,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1075,6 +1084,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -3210,6 +3222,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r d4826c0a98c2 sql/set_var.h
---- a/sql/set_var.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.h Wed Jul 29 10:00:12 2009 -0700
-@@ -1012,6 +1012,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r d4826c0a98c2 sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -8104,6 +8104,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r d4826c0a98c2 sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -33,6 +33,17 @@
- #include "ha_innodb.h"
- #endif
-
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-+
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
- "select","insert","update","delete","create","drop","reload","shutdown",
-@@ -4108,6 +4119,72 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4914,6 +4986,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5089,6 +5174,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r d4826c0a98c2 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 10:00:12 2009 -0700
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8500,6 +8501,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9552,6 +9554,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.84-b18-20090811/innodb_io_tune.patch b/percona/5.0.84-b18-20090811/innodb_io_tune.patch
deleted file mode 100644
index 3953e1d..0000000
--- a/percona/5.0.84-b18-20090811/innodb_io_tune.patch
+++ /dev/null
@@ -1,1823 +0,0 @@
-diff -r 322370200e6a innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/os0file.h Mon Nov 03 05:08:52 2008 -0800
-@@ -532,21 +532,16 @@
- FALSE otherwise */
- const char* path); /* in: path name */
- /****************************************************************************
--Initializes the asynchronous io system. Creates separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
-+Initializes the asynchronous io system. */
-
--void
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ /* out: number of AIO handler threads */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per IO array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -r 322370200e6a innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-@@ -87,6 +87,14 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-+
-+/* Number of IO operations per second the server can do */
-+extern ulint srv_io_capacity;
-+
-+/* Flush dirty pages when below max dirty percent */
-+extern ibool srv_extra_dirty_writes;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -252,6 +260,24 @@
-
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-+
-+/* Number of IO operations read/write done for all threads */
-+extern ulint os_aio_read_requests;
-+extern ulint os_aio_write_requests;
-+
-+/* Number of pages read/written done for all threads */
-+extern ulint os_aio_pages_read;
-+extern ulint os_aio_pages_written;
-+
-+/* time usec used to perform read/write for all threads */
-+extern ib_longlong os_aio_read_time;
-+extern ib_longlong os_aio_write_time;
-+
-+extern ulint inno_pending_normal_aio_reads;
-+extern ulint inno_pending_normal_aio_writes;
-+extern ulint inno_pending_ibuf_aio_reads;
-+extern ulint inno_pending_log_ios;
-+extern ulint inno_pending_sync_ios;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-diff -r 322370200e6a innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:08:52 2008 -0800
-@@ -1537,6 +1537,30 @@
-
- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
- LOG_WRITE_FROM_BACKGROUND_SYNC);
-+}
-+
-+/********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*==========================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
- }
-
- /********************************************************************
-diff -r 322370200e6a innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/os/os0file.c Mon Nov 03 05:08:52 2008 -0800
-@@ -22,6 +22,8 @@
- #include <errno.h>
- #endif /* UNIV_HOTBACKUP */
-
-+extern long innobase_max_merged_io;
-+
- #undef HAVE_FDATASYNC
-
- #ifdef POSIX_ASYNC_IO
-@@ -63,6 +65,28 @@
- ibool os_aio_use_native_aio = FALSE;
-
- ibool os_aio_print_debug = FALSE;
-+
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-@@ -72,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -82,11 +108,6 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -116,9 +137,6 @@
- in this array */
- ulint n_slots; /* Total number of slots in the aio array.
- This must be divisible by n_threads. */
-- ulint n_segments;/* Number of segments in the aio array of
-- pending aio requests. A thread can wait
-- separately for any one of the segments. */
- ulint n_reserved;/* Number of reserved slots in the
- aio array outside the ibuf segment */
- os_aio_slot_t* slots; /* Pointer to the slots in the array */
-@@ -134,6 +152,17 @@
-
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-+
-+/* Number of threads for reading and writing. */
-+ulint os_aio_read_threads = 0;
-+ulint os_aio_write_threads = 0;
-+
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
-@@ -143,11 +172,39 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
-+/* Count pages read and written per thread */
-+static ulint os_aio_thread_io_reads[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_io_writes[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO operations done. One request can be for N pages. */
-+static ulint os_aio_thread_io_requests[SRV_MAX_N_IO_THREADS];
-+
-+/* usecs spent blocked on an IO request */
-+static double os_aio_thread_io_wait[SRV_MAX_N_IO_THREADS];
-+/* max usecs spent blocked on an IO request */
-+static double os_aio_thread_max_io_wait[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO global segments. An IO handler thread is created for each
-+global segment, except for the segment associated with os_aio_sync_array.
-+Several segments can be associated with os_aio_{read,write}_array. One
-+segment is created for each of the other arrays. This is also the number
-+of valid entries in srv_io_thread_reads, srv_io_thread_writes,
-+srv_io_thread_op_info, srv_io_thread_function and os_aio_segment_wait_events. */
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
--/* If the following is TRUE, read i/o handler threads try to
--wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+/* Set to TRUE to temporarily block reads from being scheduled while a batch
-+of read requests is added to allow them to be merged by the IO handler thread
-+if they are adjacent. Declared volatile because we don't want this to be
-+read from a register in a loop when another thread may change the value in
-+memory.
-+*/
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -166,6 +223,19 @@
- ulint os_file_n_pending_pwrites = 0;
- ulint os_n_pending_writes = 0;
- ulint os_n_pending_reads = 0;
-+
-+/* TODO -- does InnoDB provide a portable method for this? */
-+static double time_usecs() {
-+#ifdef __WIN__
-+ return 0.0;
-+#else
-+ struct timeval tv;
-+ if (gettimeofday(&tv, NULL))
-+ return 0;
-+ else
-+ return tv.tv_sec * 1000000.0 + tv.tv_usec;
-+#endif
-+}
-
- /***************************************************************************
- Gets the operating system version. Currently works only on Windows. */
-@@ -1351,6 +1421,8 @@
- /* We disable OS caching (O_DIRECT) only on data files */
- if (type != OS_LOG_FILE
- && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
-+
-+ fprintf(stderr, "Using O_DIRECT for file %s\n", name);
-
- os_file_set_nocache(file, name, mode_str);
- }
-@@ -1798,6 +1870,32 @@
- #endif /* __WIN__ */
- }
-
-+#ifndef __WIN__
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fsync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fsync(file);
-+}
-+
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fdatasync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fdatasync(file);
-+}
-+#endif
-+
- /***************************************************************************
- Flushes the write buffers of a given file to the disk. */
-
-@@ -1855,21 +1953,21 @@
- /* If we are not on an operating system that supports this,
- then fall back to a plain fsync. */
-
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- } else {
- ret = fcntl(file, F_FULLFSYNC, NULL);
-
- if (ret) {
- /* If we are not on a file system that supports this,
- then fall back to a plain fsync. */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- }
- }
- #elif HAVE_FDATASYNC
-- ret = fdatasync(file);
-+ ret = os_maybe_fdatasync(file);
- #else
- /* fprintf(stderr, "Flushing to file %p\n", file); */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- #endif
- os_n_fsyncs++;
-
-@@ -2298,6 +2396,9 @@
-
- return(TRUE);
- }
-+ fprintf(stderr,
-+"InnoDB: error: os_file_pread wanted %lu and got %lu.\n",
-+ (ulint) n, (ulint) ret);
- #endif
- #ifdef __WIN__
- error_handling:
-@@ -2784,9 +2885,8 @@
- os_aio_array_create(
- /*================*/
- /* out, own: aio array */
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments) /* in: number of segments in the aio array */
-+ ulint n) /* in: maximum number of pending aio operations
-+ allowed */
- {
- os_aio_array_t* array;
- ulint i;
-@@ -2795,7 +2895,6 @@
- OVERLAPPED* over;
- #endif
- ut_a(n > 0);
-- ut_a(n_segments > 0);
-
- array = ut_malloc(sizeof(os_aio_array_t));
-
-@@ -2806,7 +2905,6 @@
- os_event_set(array->is_empty);
-
- array->n_slots = n;
-- array->n_segments = n_segments;
- array->n_reserved = 0;
- array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
- #ifdef __WIN__
-@@ -2833,70 +2931,75 @@
-
- /****************************************************************************
- Initializes the asynchronous io system. Calls also os_io_init_simple.
--Creates a separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
--
--void
-+Creates an aio array for each of non-ibuf read, non-ibuf write, ibuf IO,
-+log IO, and synchronous IO. The caller must create i/o handler thread for all
-+but the synchronous aio array. Multiple threads can access the same array for
-+the non-ibuf read (prefetch) and write (flush dirty buffer pages) arrays.
-+Return the number of AIO handler threads. */
-+
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
-- ulint n_read_segs;
-- ulint n_write_segs;
-- ulint n_per_seg;
-- ulint i;
-+ ulint i;
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-- ut_ad(n % n_segments == 0);
-- ut_ad(n_segments >= 4);
-+ ut_a(ios_per_array >= OS_AIO_N_PENDING_IOS_PER_THREAD);
-+ ut_a(n_read_threads >= 1 && n_read_threads <= 64);
-+ ut_a(n_write_threads >= 1 && n_write_threads <= 64);
-+ ut_a(n_segments < SRV_MAX_N_IO_THREADS);
-
- os_io_init_simple();
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-- }
--
-- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
--
-- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
--
-- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_thread_io_reads[i] = 0;
-+ os_aio_thread_io_writes[i] = 0;
-+ os_aio_thread_io_requests[i] = 0;
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
-+ os_aio_thread_io_wait[i] = 0;
-+ os_aio_thread_max_io_wait[i] = 0;
-+ }
-+
-+ os_aio_read_threads = n_read_threads;
-+ os_aio_write_threads = n_write_threads;
-+ os_aio_first_write_segment = os_aio_first_read_segment + os_aio_read_threads;
-+
-+ fprintf(stderr,
-+ "InnoDB: ios_per_array %lu read threads %lu write threads %lu\n",
-+ ios_per_array, os_aio_read_threads, os_aio_write_threads);
-+
-+ os_aio_ibuf_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[0] = "insert buffer thread";
-
-- os_aio_log_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_log_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-- n_read_segs);
-- for (i = 2; i < 2 + n_read_segs; i++) {
-+ os_aio_read_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_read_segment; i < os_aio_first_write_segment; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "read thread";
-- }
--
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-- n_write_segs);
-- for (i = 2 + n_read_segs; i < n_segments; i++) {
-+ srv_io_thread_function[i] = "read thread";
-+ }
-+
-+ os_aio_write_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_write_segment; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "write thread";
-- }
--
-- os_aio_sync_array = os_aio_array_create(n_slots_sync, 1);
--
-- os_aio_n_segments = n_segments;
-+ srv_io_thread_function[i] = "write thread";
-+ }
-+
-+ os_aio_sync_array = os_aio_array_create(n_slots_sync);
-+
-+ os_aio_n_segments = 2 + os_aio_read_threads + os_aio_write_threads;
-
- os_aio_validate();
-
-@@ -2924,6 +3027,7 @@
-
- pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
- #endif
-+ return os_aio_n_segments;
- }
-
- #ifdef WIN_ASYNC_IO
-@@ -2981,77 +3085,32 @@
- os_event_wait(os_aio_write_array->is_empty);
- }
-
--/**************************************************************************
--Calculates segment number for a slot. */
--static
--ulint
--os_aio_get_segment_no_from_slot(
--/*============================*/
-- /* out: segment number (which is the number
-- used by, for example, i/o-handler threads) */
-- os_aio_array_t* array, /* in: aio wait array */
-- os_aio_slot_t* slot) /* in: slot in this array */
--{
-- ulint segment;
-- ulint seg_len;
--
-- if (array == os_aio_ibuf_array) {
-- segment = 0;
--
-- } else if (array == os_aio_log_array) {
-- segment = 1;
--
-- } else if (array == os_aio_read_array) {
-- seg_len = os_aio_read_array->n_slots /
-- os_aio_read_array->n_segments;
--
-- segment = 2 + slot->pos / seg_len;
-- } else {
-- ut_a(array == os_aio_write_array);
-- seg_len = os_aio_write_array->n_slots /
-- os_aio_write_array->n_segments;
--
-- segment = os_aio_read_array->n_segments + 2
-- + slot->pos / seg_len;
-- }
--
-- return(segment);
--}
--
--/**************************************************************************
--Calculates local segment number and aio array from global segment number. */
--static
--ulint
--os_aio_get_array_and_local_segment(
-+
-+/**************************************************************************
-+Calculates aio array from global segment number. */
-+static
-+os_aio_array_t*
-+os_aio_get_array(
- /*===============================*/
-- /* out: local segment number within
-- the aio array */
-- os_aio_array_t** array, /* out: aio wait array */
-+ /* out: aio wait array */
- ulint global_segment)/* in: global segment number */
- {
-- ulint segment;
-
- ut_a(global_segment < os_aio_n_segments);
-
- if (global_segment == 0) {
-- *array = os_aio_ibuf_array;
-- segment = 0;
-+ return os_aio_ibuf_array;
-
- } else if (global_segment == 1) {
-- *array = os_aio_log_array;
-- segment = 0;
--
-- } else if (global_segment < os_aio_read_array->n_segments + 2) {
-- *array = os_aio_read_array;
--
-- segment = global_segment - 2;
-- } else {
-- *array = os_aio_write_array;
--
-- segment = global_segment - (os_aio_read_array->n_segments + 2);
-- }
--
-- return(segment);
-+ return os_aio_log_array;
-+
-+ } else if (global_segment < os_aio_first_write_segment) {
-+ return os_aio_read_array;
-+
-+ } else {
-+ return os_aio_write_array;
-+
-+ }
- }
-
- /***********************************************************************
-@@ -3160,7 +3219,7 @@
-
- os_aio_simulated_wake_handler_threads();
- }
--
-+
- os_event_wait(array->not_full);
-
- goto loop;
-@@ -3173,7 +3232,7 @@
- break;
- }
- }
--
-+ ut_a(i < array->n_slots);
- array->n_reserved++;
-
- if (array->n_reserved == 1) {
-@@ -3195,7 +3254,7 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3246,8 +3305,9 @@
- os_mutex_enter(array->mutex);
-
- ut_ad(slot->reserved);
--
-+
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3266,36 +3326,40 @@
- }
-
- /**************************************************************************
--Wakes up a simulated aio i/o-handler thread if it has something to do. */
-+Wake up the simulated aio i/o-handler threads for a given array if there
-+is work to do. */
- static
- void
- os_aio_simulated_wake_handler_thread(
- /*=================================*/
-- ulint global_segment) /* in: the number of the segment in the aio
-- arrays */
--{
-- os_aio_array_t* array;
-- os_aio_slot_t* slot;
-- ulint segment;
-+ os_aio_array_t* array) /* in: aio array for which wakeup is done */
-+{
-+ os_aio_slot_t* slot;
- ulint n;
- ulint i;
-
- ut_ad(!os_aio_use_native_aio);
-
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
--
-- os_mutex_enter(array->mutex);
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- /* Found an i/o request */
--
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-+
-+ os_mutex_enter(array->mutex);
-+
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i );
-+
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
-+ /* Found an i/o request
-+ /* OS_AIO_NOT_ISSUED means the read or write request has
-+ * yet to be done. OS_AIO_DONE means the request has been
-+ * done but it was part of a set of requests merged into
-+ * one read or write call and was not the first block in
-+ * the request, so the handling of the IO completion for
-+ * that block has not been done. */
-+
- break;
- }
- }
-@@ -3303,7 +3367,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3320,13 +3402,14 @@
- /* We do not use simulated aio: do nothing */
-
- return;
-- }
--
-- os_aio_recommend_sleep_for_read_threads = FALSE;
--
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ }
-+
-+ os_aio_recommend_sleep_for_read_threads = FALSE;
-+
-+ os_aio_simulated_wake_handler_thread(os_aio_ibuf_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_log_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_read_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_write_array);
- }
-
- /**************************************************************************
-@@ -3339,18 +3422,13 @@
- os_aio_simulated_put_read_threads_to_sleep(void)
- /*============================================*/
- {
-- os_aio_array_t* array;
- ulint g;
-
-+ /* TODO(mcallaghan): provide similar function for write? */
- os_aio_recommend_sleep_for_read_threads = TRUE;
-
-- for (g = 0; g < os_aio_n_segments; g++) {
-- os_aio_get_array_and_local_segment(&array, g);
--
-- if (array == os_aio_read_array) {
--
-- os_event_reset(os_aio_segment_wait_events[g]);
-- }
-+ for (g = os_aio_first_read_segment; g < os_aio_first_write_segment; g++) {
-+ os_event_reset(os_aio_segment_wait_events[g]);
- }
- }
-
-@@ -3480,8 +3558,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else if (type == OS_FILE_WRITE) {
-@@ -3497,8 +3574,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else {
-@@ -3561,7 +3637,7 @@
- os_aio_windows_handle(
- /*==================*/
- /* out: TRUE if the aio operation succeeded */
-- ulint segment, /* in: the number of the segment in the aio
-+ ulint global_segment, /* in: the number of the segment in the aio
- arrays to wait for; segment 0 is the ibuf
- i/o thread, segment 1 the log i/o thread,
- then follow the non-ibuf read threads, and as
-@@ -3579,7 +3655,6 @@
- void** message2,
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
-- ulint orig_seg = segment;
- os_aio_array_t* array;
- os_aio_slot_t* slot;
- ulint n;
-@@ -3588,33 +3663,30 @@
- BOOL ret;
- DWORD len;
-
-- if (segment == ULINT_UNDEFINED) {
-+ if (global_segment == ULINT_UNDEFINED) {
- array = os_aio_sync_array;
-- segment = 0;
-- } else {
-- segment = os_aio_get_array_and_local_segment(&array, segment);
-+ } else {
-+ array = os_aio_get_array(global_segment);
- }
-
- /* NOTE! We only access constant fields in os_aio_array. Therefore
- we do not have to acquire the protecting mutex yet */
-
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
-+
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
- i = pos;
- } else {
-- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
-- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-- }
--
-- os_mutex_enter(array->mutex);
--
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ srv_set_io_thread_op_info(global_segment, "wait Windows aio");
-+ i = os_event_wait_multiple(n, (array->native_events));
-+ }
-+
-+ os_mutex_enter(array->mutex);
-+
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3787,14 +3859,16 @@
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
- os_aio_array_t* array;
-- ulint segment;
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3802,8 +3876,10 @@
- ibool ret;
- ulint n;
- ulint i;
--
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-+
-+ double start_usecs, stop_usecs, elapsed_usecs;
-+ time_t now;
-+ array = os_aio_get_array(global_segment);
-
- restart:
- /* NOTE! We only access constant fields in os_aio_array. Therefore
-@@ -3812,11 +3888,10 @@
- srv_set_io_thread_op_info(global_segment,
- "looking for i/o requests (a)");
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
-+
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-
- if (array == os_aio_read_array
- && os_aio_recommend_sleep_for_read_threads) {
-@@ -3836,9 +3911,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved && slot->io_already_done) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3846,79 +3921,66 @@
- }
-
- ret = TRUE;
--
-+
- goto slot_io_done;
- }
- }
-
-- n_consecutive = 0;
--
-- /* If there are at least 2 seconds old requests, then pick the oldest
-- one to prevent starvation. If several requests have the same age,
-- then pick the one at the lowest offset. */
--
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
--
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-+
-+ /* Find the oldest request and the request with the smallest offset */
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-+
-+ /* If there are at least 2 seconds old requests, then pick the oldest
-+ one to prevent starvation. If several requests have the same age,
-+ then pick the one at the lowest offset. */
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
-+ }
-+
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
-+ /* Found an i/o request */
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
--
-- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-- lowest_offset = slot->offset;
-- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3926,7 +3988,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3935,7 +3998,8 @@
-
- slot = slot2;
-
-- if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE) {
-+ if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE
-+ && n_consecutive < innobase_max_merged_io) {
-
- goto consecutive_loop;
- } else {
-@@ -3955,6 +4019,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -3962,7 +4028,16 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -3973,6 +4048,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -3998,6 +4076,7 @@
-
- /* Do the i/o with ordinary, synchronous i/o functions: */
- if (slot->type == OS_FILE_WRITE) {
-+ os_aio_thread_io_writes[global_segment] += n_consecutive;
- if (array == os_aio_write_array) {
- if ((total_len % UNIV_PAGE_SIZE != 0)
- || (slot->offset % UNIV_PAGE_SIZE != 0)) {
-@@ -4012,16 +4091,34 @@
- os_file_check_page_trailers(combined_buf, total_len);
- }
-
-+ start_usecs = time_usecs();
- ret = os_file_write(slot->name, slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
--
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
- if (array == os_aio_write_array) {
- os_file_check_page_trailers(combined_buf, total_len);
- }
-- } else {
-+ os_aio_write_requests++;
-+ os_aio_pages_written += n_consecutive;
-+ os_aio_write_time += (ib_longlong)elapsed_usecs;
-+ } else {
-+ start_usecs = time_usecs();
-+ os_aio_thread_io_reads[global_segment] += n_consecutive;
- ret = os_file_read(slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
-- }
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
-+ os_aio_read_requests++;
-+ os_aio_pages_read += n_consecutive;
-+ os_aio_read_time += (ib_longlong)elapsed_usecs;
-+ }
-+ if (elapsed_usecs > os_aio_thread_max_io_wait[global_segment])
-+ os_aio_thread_max_io_wait[global_segment] = elapsed_usecs;
-+ os_aio_thread_io_wait[global_segment] += elapsed_usecs;
-+ os_aio_thread_io_requests[global_segment]++;
-
- ut_a(ret);
- srv_set_io_thread_op_info(global_segment, "file i/o done");
-@@ -4042,16 +4139,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4061,6 +4155,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-@@ -4070,7 +4166,8 @@
- os_mutex_exit(array->mutex);
-
- os_aio_array_free_slot(array, slot);
--
-+ srv_set_io_thread_op_info(global_segment, "exited handler");
-+
- return(ret);
-
- wait_for_io:
-@@ -4115,7 +4212,6 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-@@ -4165,11 +4261,20 @@
- double time_elapsed;
- double avg_bytes_read;
- ulint i;
--
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-- fprintf(file, "I/O thread %lu state: %s (%s)", (ulong) i,
-- srv_io_thread_op_info[i],
-- srv_io_thread_function[i]);
-+ ulint num_issued, num_done, num_claimed;
-+
-+ if (file) {
-+ for (i = 0; i < os_aio_n_segments; i++) {
-+ fprintf(file,
-+ "I/O thread %lu state: %s (%s) reads %lu writes %lu "
-+ "requests %lu io secs %lf io msecs/request %lf max_io_wait %lf",
-+ i, srv_io_thread_op_info[i], srv_io_thread_function[i],
-+ os_aio_thread_io_reads[i], os_aio_thread_io_writes[i],
-+ os_aio_thread_io_requests[i],
-+ os_aio_thread_io_wait[i] / 1000000.0,
-+ os_aio_thread_io_requests[i] ?
-+ os_aio_thread_io_wait[i] / os_aio_thread_io_requests[i] / 1000.0 : 0.0,
-+ os_aio_thread_max_io_wait[i] / 1000.0);
-
- #ifndef __WIN__
- if (os_aio_segment_wait_events[i]->is_set) {
-@@ -4181,6 +4286,7 @@
- }
-
- fputs("Pending normal aio reads:", file);
-+ } // if (file)
-
- array = os_aio_read_array;
- loop:
-@@ -4189,14 +4295,23 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- n_reserved = 0;
-+ num_done = num_issued = num_claimed = 0;
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
- if (slot->reserved) {
-+ if (slot->status == OS_AIO_ISSUED)
-+ num_issued++;
-+ else if (slot->status == OS_AIO_DONE)
-+ num_done++;
-+ else {
-+ ut_ad(slot->status == OS_AIO_CLAIMED);
-+ num_claimed++;
-+ }
-+
- n_reserved++;
- /* fprintf(stderr, "Reserved slot, messages %p %p\n",
- slot->message1, slot->message2); */
-@@ -4206,42 +4321,56 @@
-
- ut_a(array->n_reserved == n_reserved);
-
-- fprintf(file, " %lu", (ulong) n_reserved);
--
-+ if (file) fprintf(file, " %lu", (ulong) n_reserved);
-+
- os_mutex_exit(array->mutex);
-
- if (array == os_aio_read_array) {
-- fputs(", aio writes:", file);
--
-+ inno_pending_normal_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", aio writes:", file);
- array = os_aio_write_array;
-
- goto loop;
- }
-
- if (array == os_aio_write_array) {
-- fputs(",\n ibuf aio reads:", file);
-+ inno_pending_normal_aio_writes = (ulong) n_reserved;
-+ if (file) fputs(",\n ibuf aio reads:", file);
- array = os_aio_ibuf_array;
-
- goto loop;
- }
-
- if (array == os_aio_ibuf_array) {
-- fputs(", log i/o's:", file);
-+ inno_pending_ibuf_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", log i/o's:", file);
- array = os_aio_log_array;
-
- goto loop;
- }
-
- if (array == os_aio_log_array) {
-- fputs(", sync i/o's:", file);
-+ inno_pending_log_ios = (ulong) n_reserved;
-+ if (file) fputs(", sync i/o's:", file);
- array = os_aio_sync_array;
-
- goto loop;
- }
-
-- putc('\n', file);
-+ if (array == os_aio_sync_array) {
-+ inno_pending_sync_ios = (ulong) n_reserved;
-+ }
-+
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time, os_last_printout);
-+
-+ if (file) {
-+ putc('\n', file);
-+ fprintf(file,
-+ "Summary of background IO slot status: %lu issued, "
-+ "%lu done, %lu claimed, sleep set %d\n",
-+ num_issued, num_done, num_claimed,
-+ os_aio_recommend_sleep_for_read_threads);
-
- fprintf(file,
- "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
-@@ -4274,6 +4403,7 @@
- / time_elapsed,
- (os_n_fsyncs - os_n_fsyncs_old)
- / time_elapsed);
-+ } // if (file)
-
- os_n_file_reads_old = os_n_file_reads;
- os_n_file_writes_old = os_n_file_writes;
-diff -r 322370200e6a innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-@@ -164,7 +164,17 @@
- ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
- ulint srv_lock_table_size = ULINT_MAX;
-
-+ulint srv_io_capacity = ULINT_MAX; /* Number of IO operations per
-+ second the server can do */
-+
-+ibool srv_extra_dirty_writes = TRUE; /* Write dirty pages to disk when pct
-+ dirty < max dirty pct */
-+
-+/* Deprecated by srv_n_{read,write}_io_threads */
- ulint srv_n_file_io_threads = ULINT_MAX;
-+/* Number of background IO threads for read and write requests */
-+ulint srv_n_read_io_threads = ULINT_MAX;
-+ulint srv_n_write_io_threads = ULINT_MAX;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -238,6 +248,24 @@
-
- /* variable to count the number of random read-aheads */
- ulint srv_read_ahead_rnd = 0;
-+
-+/* Number of IO operations read/write done for all threads */
-+ulint os_aio_read_requests = 0;
-+ulint os_aio_write_requests = 0;
-+
-+/* Number of pages read/written done for all threads */
-+ulint os_aio_pages_read = 0;
-+ulint os_aio_pages_written = 0;
-+
-+/* time usec used to perform read/write for all threads */
-+ib_longlong os_aio_read_time = 0;
-+ib_longlong os_aio_write_time = 0;
-+
-+ulint inno_pending_normal_aio_reads = 0;
-+ulint inno_pending_normal_aio_writes = 0;
-+ulint inno_pending_ibuf_aio_reads = 0;
-+ulint inno_pending_log_ios = 0;
-+ulint inno_pending_sync_ios = 0;
-
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-@@ -413,6 +441,23 @@
-
- ulint srv_main_thread_process_no = 0;
- ulint srv_main_thread_id = 0;
-+
-+// The following count work done by srv_master_thread.
-+
-+// Iterations by the 'once per second' loop.
-+ulint srv_main_1_second_loops = 0;
-+// Calls to sleep by the 'once per second' loop.
-+ulint srv_main_sleeps = 0;
-+// Iterations by the 'once per 10 seconds' loop.
-+ulint srv_main_10_second_loops = 0;
-+// Iterations of the loop bounded by the 'background_loop' label.
-+ulint srv_main_background_loops = 0;
-+// Iterations of the loop bounded by the 'flush_loop' label.
-+ulint srv_main_flush_loops = 0;
-+// Calls to log_buffer_flush_to_disk.
-+ulint srv_sync_flush = 0;
-+// Calls to log_buffer_flush_maybe_sync.
-+ulint srv_async_flush = 0;
-
- /*
- IMPLEMENTATION OF THE SERVER MAIN PROGRAM
-@@ -2170,7 +2215,12 @@
- }
-
- /*************************************************************************
--The master thread controlling the server. */
-+Returns the number of IO operations that is X percent of the capacity.
-+
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity.
-+*/
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-
- #ifndef __WIN__
- void*
-@@ -2199,11 +2249,15 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
- #endif
-+ fprintf(stderr, "InnoDB master thread running with io_capacity %lu\n",
-+ srv_io_capacity);
-+
- srv_main_thread_process_no = os_proc_get_number();
- srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
-
-@@ -2275,26 +2329,28 @@
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-+ srv_sync_flush++;
-
- srv_main_thread_op_info = "making checkpoint";
- log_free_check();
-
-- /* If there were less than 5 i/os during the
-- one second sleep, we assume that there is free
-- disk i/o capacity available, and it makes sense to
-- do an insert buffer merge. */
-+ /* If i/os during one second sleep were less than 5% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to do an insert buffer merge. */
-
- n_pend_ios = buf_get_n_pending_ios()
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2303,7 +2359,8 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2325,36 +2382,47 @@
-
- /* ---- We perform the following code approximately once per
- 10 seconds when there is database activity */
-+ srv_main_10_second_loops++;
-
- #ifdef MEM_PERIODIC_CHECK
- /* Check magic numbers of every allocated mem block once in 10
- seconds */
- mem_validate_all_blocks();
- #endif
-- /* If there were less than 200 i/os during the 10 second period,
-- we assume that there is free disk i/o capacity available, and it
-- makes sense to flush 100 pages. */
-+ /* If i/os during the 10 second period were less than 200% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to flush srv_io_capacity pages.
-+
-+ Note that this is done regardless of the fraction of dirty
-+ pages relative to the max requested by the user. The one second
-+ loop above requests writes for that case. The writes done here
-+ are not required, and may be disabled. */
-
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (srv_extra_dirty_writes &&
-+ n_pend_ios < PCT_IO(3) && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2378,8 +2446,9 @@
- if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2393,14 +2462,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2434,7 +2503,7 @@
-
- /* The server has been quiet for a while: start running background
- operations */
--
-+ srv_main_background_loops++;
- srv_main_thread_op_info = "doing background drop tables";
-
- n_tables_to_drop = row_drop_tables_for_mysql_in_background();
-@@ -2472,6 +2541,7 @@
-
- log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2487,9 +2557,13 @@
- srv_main_thread_op_info = "doing insert buffer merge";
-
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
-- n_bytes_merged = 0;
-+ n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ /* This should do an amount of IO similar to the number of
-+ * dirty pages that will be flushed in the call to
-+ * buf_flush_batch below. Otherwise, the system favors
-+ * clean pages over cleanup throughput. */
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2503,10 +2577,11 @@
-
- flush_loop:
- srv_main_thread_op_info = "flushing buffer pool pages";
-+ srv_main_flush_loops++;
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2528,7 +2603,17 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ srv_main_thread_op_info = (char*) "flushing log";
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ srv_sync_flush++;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -r 322370200e6a innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0start.c Mon Nov 03 05:08:52 2008 -0800
-@@ -973,6 +973,7 @@
- ulint i;
- ibool srv_file_per_table_original_value = srv_file_per_table;
- mtr_t mtr;
-+ ulint n_threads;
- #ifdef HAVE_DARWIN_THREADS
- # ifdef F_FULLFSYNC
- /* This executable has been compiled on Mac OS X 10.3 or later.
-@@ -1206,24 +1207,32 @@
- }
-
- /* Restrict the maximum number of file i/o threads */
-- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
--
-- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ if ((srv_n_read_io_threads + srv_n_write_io_threads) > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many read(%d) or write(%d) IO threads, max is %d\n",
-+ srv_n_read_io_threads, srv_n_write_io_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- if (!os_aio_use_native_aio) {
-- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /* More than 4 threads are now supported. */
-+ n_threads = os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ } else {
-+ /* Might need more slots here. Alas, I don't do windows. */
-+ n_threads = os_aio_init(SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ }
-
-- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-- } else {
-- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ if (n_threads > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many IO threads(%d), max is %d\n",
-+ n_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- fil_init(srv_max_n_open_files);
-@@ -1259,11 +1268,11 @@
-
- /* Create i/o-handler threads: */
-
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-+ for (i = 0; i < n_threads; i++) {
- n[i] = i;
-
- os_thread_create(io_handler_thread, n + i, thread_ids + i);
-- }
-+ }
-
- #ifdef UNIV_LOG_ARCHIVE
- if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
-diff -r 322370200e6a patch_info/innodb_io_tune.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_tune.info Mon Nov 03 05:08:52 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_io_tune.patch
-+Name=Tune InnoDB IO settings
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
-diff -r 322370200e6a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -147,7 +147,7 @@
- innobase_additional_mem_pool_size, innobase_file_io_threads,
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
--
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -175,6 +175,23 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+
-+/* Max number of IO requests merged to perform large IO in background
-+ IO threads.
-+*/
-+long innobase_max_merged_io = 64;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+long innobase_min_status_update_time_interval = 30;
-+
-+
-+/* Default number of IO per second supported by server. Tunes background
-+ IO rate
-+*/
-+long innobase_io_capacity = 100;
-+
-+/* Write dirty pages when pct dirty is less than max pct dirty */
-+my_bool innobase_extra_dirty_writes = TRUE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1372,7 +1389,11 @@
-
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
-+ srv_io_capacity = (ulint) innobase_io_capacity;
-+ srv_extra_dirty_writes = (ibool) innobase_extra_dirty_writes;
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -r 322370200e6a sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-@@ -197,6 +197,7 @@
-
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
-+extern long innobase_max_merged_io;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -205,10 +206,14 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_force_recovery;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
- extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
- extern char *innobase_unix_file_flush_method;
-+extern long innobase_io_capacity;
-+extern my_bool innobase_extra_dirty_writes;
-+
- /* The following variables have to be my_bool for SHOW VARIABLES to work */
- extern my_bool innobase_log_archive,
- innobase_use_doublewrite,
-diff -r 322370200e6a sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -4932,6 +4932,11 @@
- OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_MAX_MERGED_IO,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_EXTRA_DIRTY_WRITES,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
-@@ -5302,6 +5307,25 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_max_merged_io", OPT_INNODB_MAX_MERGED_IO,
-+ "Max number of IO requests merged to issue large IO from background IO threads.",
-+ (gptr*) &innobase_max_merged_io,
-+ (gptr*) &innobase_max_merged_io, 0, GET_LONG, REQUIRED_ARG, 64, 1, 64, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.", (gptr*) &innobase_read_io_threads,
-+ (gptr*) &innobase_read_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.", (gptr*) &innobase_write_io_threads,
-+ (gptr*) &innobase_write_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &innobase_io_capacity,
-+ (gptr*) &innobase_io_capacity, 0, GET_LONG,
-+ REQUIRED_ARG, 100, 100, 999999999, 0, 1, 0},
-+ {"innodb_extra_dirty_writes", OPT_INNODB_EXTRA_DIRTY_WRITES,
-+ "When set, flush dirty buffer pages when dirty pct is less than max dirty pct. ",
-+ (gptr*) &innobase_extra_dirty_writes, (gptr*) &innobase_extra_dirty_writes,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 322370200e6a sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -919,12 +919,14 @@
- {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
- {"innodb_adaptive_hash_index", (char*) &innobase_adaptive_hash_index, SHOW_MY_BOOL},
- {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
-+ {"innodb_extra_dirty_writes", (char*) &innobase_extra_dirty_writes, SHOW_MY_BOOL},
- {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
-+ {"innodb_io_capacity", (char*) &innobase_io_capacity, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
- {"innodb_locks_unsafe_for_binlog", (char*) &innobase_locks_unsafe_for_binlog, SHOW_MY_BOOL},
- {"innodb_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
-@@ -943,6 +945,9 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
-+ {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/innodb_locks_held.patch b/percona/5.0.84-b18-20090811/innodb_locks_held.patch
deleted file mode 100644
index 062fa47..0000000
--- a/percona/5.0.84-b18-20090811/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1711,24 +1713,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1822,6 +1806,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r e9fb5b8bcf78 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -825,6 +825,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -942,6 +944,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r e9fb5b8bcf78 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
-@@ -243,6 +243,8 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-diff -r e9fb5b8bcf78 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -5016,6 +5016,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5364,6 +5366,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r e9fb5b8bcf78 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -527,6 +527,12 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -906,6 +912,8 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1023,6 +1031,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.84-b18-20090811/innodb_recovery_patches.patch b/percona/5.0.84-b18-20090811/innodb_recovery_patches.patch
deleted file mode 100644
index 3d3e567..0000000
--- a/percona/5.0.84-b18-20090811/innodb_recovery_patches.patch
+++ /dev/null
@@ -1,217 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-08-04 17:02:36.000000000 +0900
-@@ -85,6 +85,22 @@
- prev_b = NULL;
- b = UT_LIST_GET_FIRST(buf_pool->flush_list);
-
-+ if (srv_fast_recovery) {
-+ /* speed hack */
-+ if (b == NULL || (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0)) {
-+ UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
-+ } else {
-+ b = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ if (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0) {
-+ /* align oldest_modification not to sort */
-+ block->oldest_modification = b->oldest_modification;
-+ }
-+ UT_LIST_ADD_LAST(flush_list, buf_pool->flush_list, block);
-+ }
-+ } else {
-+ /* normal */
- while (b && (ut_dulint_cmp(b->oldest_modification,
- block->oldest_modification) > 0)) {
- prev_b = b;
-@@ -97,6 +113,7 @@
- UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b,
- block);
- }
-+ }
-
- ut_ad(buf_flush_validate_low());
- }
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-08-04 17:11:41.000000000 +0900
-@@ -127,6 +127,46 @@
- block = buf_page_init_for_read(err, mode, space, tablespace_version,
- offset);
- if (block == NULL) {
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=43948 */
-+ if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
-+ /* hashed log recs must be treated here */
-+ recv_addr_t* recv_addr;
-+
-+ mutex_enter(&(recv_sys->mutex));
-+
-+ if (recv_sys->apply_log_recs == FALSE) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ /* recv_get_fil_addr_struct() */
-+ recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
-+ hash_calc_hash(ut_fold_ulint_pair(space, offset),
-+ recv_sys->addr_hash));
-+ while (recv_addr) {
-+ if ((recv_addr->space == space)
-+ && (recv_addr->page_no == offset)) {
-+ break;
-+ }
-+ recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
-+ }
-+
-+ if ((recv_addr == NULL)
-+ || (recv_addr->state == RECV_BEING_PROCESSED)
-+ || (recv_addr->state == RECV_PROCESSED)) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ fprintf(stderr, " (space:%lu is deleted)", space);
-+ recv_addr->state = RECV_PROCESSED;
-+
-+ ut_a(recv_sys->n_addrs);
-+ recv_sys->n_addrs--;
-+
-+ mutex_exit(&(recv_sys->mutex));
-+ }
-+not_to_recover:
-
- return(0);
- }
-@@ -697,11 +737,11 @@
- while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
-
- os_aio_simulated_wake_handler_threads();
-- os_thread_sleep(500000);
-+ os_thread_sleep(10000);
-
- count++;
-
-- if (count > 100) {
-+ if (count > 5000) {
- fprintf(stderr,
- "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
- "InnoDB: reads to the buffer pool to be finished.\n"
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-08-04 17:39:51.000000000 +0900
-@@ -59,6 +59,8 @@
- extern ibool srv_file_per_table;
- extern ibool srv_locks_unsafe_for_binlog;
-
-+extern ibool srv_fast_recovery;
-+
- extern ulint srv_n_data_files;
- extern char** srv_data_file_names;
- extern ulint* srv_data_file_sizes;
-diff -ruN a/innobase/log/log0recv.c b/innobase/log/log0recv.c
---- a/innobase/log/log0recv.c 2009-07-07 21:54:08.000000000 +0900
-+++ b/innobase/log/log0recv.c 2009-08-04 17:15:15.000000000 +0900
-@@ -101,7 +101,7 @@
- use these free frames to read in pages when we start applying the
- log records to the database. */
-
--ulint recv_n_pool_free_frames = 256;
-+ulint recv_n_pool_free_frames = 1024;
-
- /* The maximum lsn we see for a page during the recovery process. If this
- is bigger than the lsn we are able to scan up to, that is an indication that
-@@ -1135,6 +1135,8 @@
- recv_addr = recv_get_fil_addr_struct(space, page_no);
-
- if ((recv_addr == NULL)
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=44140 */
-+ || (recv_addr->state == RECV_BEING_READ && !just_read_in)
- || (recv_addr->state == RECV_BEING_PROCESSED)
- || (recv_addr->state == RECV_PROCESSED)) {
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-04 17:41:05.000000000 +0900
-@@ -88,6 +88,8 @@
- i.e. do not use next-key locking
- except on duplicate key checking and
- foreign key checking */
-+ibool srv_fast_recovery = FALSE;
-+
- ulint srv_n_data_files = 0;
- char** srv_data_file_names = NULL;
- ulint* srv_data_file_sizes = NULL; /* size in database pages */
-diff -ruN a/patch_info/innodb_recovery_patches.info b/patch_info/innodb_recovery_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_recovery_patches.info 2009-08-04 16:58:07.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_recovery_patches.patch
-+Name=Bugfixes and adjustments about recovery process
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-04 17:35:44.000000000 +0900
-@@ -182,6 +182,7 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+my_bool innobase_fast_recovery = FALSE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1534,6 +1535,8 @@
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-+ srv_fast_recovery = (ibool) innobase_fast_recovery;
-+
- srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
- srv_use_checksums = (ibool) innobase_use_checksums;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-08-04 17:37:18.000000000 +0900
-@@ -220,6 +220,7 @@
- innobase_use_large_pages,
- innobase_use_native_aio,
- innobase_file_per_table, innobase_locks_unsafe_for_binlog,
-+ innobase_fast_recovery,
- innobase_rollback_on_timeout,
- innobase_create_status_file,
- innobase_adaptive_hash_index;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/mysqld.cc 2009-08-04 17:48:25.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_USE_SYS_MALLOC,
-+ OPT_INNODB_FAST_RECOVERY,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5347,6 +5348,10 @@
- {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \
- Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
- (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_fast_recovery", OPT_INNODB_FAST_RECOVERY,
-+ "Enable to use speed hack of recovery avoiding flush list sorting.",
-+ (gptr*) &innobase_fast_recovery, (gptr*) &innobase_fast_recovery,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
- "Speeds up the shutdown process of the InnoDB storage engine. Possible "
- "values are 0, 1 (faster)"
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/set_var.cc 2009-08-04 17:51:49.000000000 +0900
-@@ -1088,6 +1088,7 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
-+ {"innodb_fast_recovery", (char*) &innobase_fast_recovery, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/innodb_rw_lock.patch b/percona/5.0.84-b18-20090811/innodb_rw_lock.patch
deleted file mode 100644
index b4a1a79..0000000
--- a/percona/5.0.84-b18-20090811/innodb_rw_lock.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(btr_search_latch.writer_count == 0);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.84-b18-20090811/innodb_show_bp.patch b/percona/5.0.84-b18-20090811/innodb_show_bp.patch
deleted file mode 100644
index 766a3b7..0000000
--- a/percona/5.0.84-b18-20090811/innodb_show_bp.patch
+++ /dev/null
@@ -1,453 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,19 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.84-b18-20090811/innodb_show_hashed_memory.patch b/percona/5.0.84-b18-20090811/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.84-b18-20090811/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.84-b18-20090811/innodb_show_hashed_memory_standalone.patch b/percona/5.0.84-b18-20090811/innodb_show_hashed_memory_standalone.patch
deleted file mode 100644
index bf8f6b4..0000000
--- a/percona/5.0.84-b18-20090811/innodb_show_hashed_memory_standalone.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,80 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes());
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.84-b18-20090811/innodb_split_buf_pool_mutex.patch b/percona/5.0.84-b18-20090811/innodb_split_buf_pool_mutex.patch
deleted file mode 100644
index 7fa7ac0..0000000
--- a/percona/5.0.84-b18-20090811/innodb_split_buf_pool_mutex.patch
+++ /dev/null
@@ -1,1870 +0,0 @@
-diff -r 7ac364cc9b41 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0buf.c Fri Jul 03 15:41:57 2009 -0700
-@@ -549,6 +549,17 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_BUF_LRU_LIST);
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_BUF_PAGE_HASH);
-+ mutex_create(&(buf_pool->free_mutex));
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_BUF_FREE_LIST);
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_BUF_FLUSH_LIST);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +735,8 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -753,6 +766,7 @@
- {
- buf_block_t* bck;
-
-+ ut_error; /* don't support AWE */
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -851,7 +865,7 @@
- buf_block_t* block) /* in: block to make younger */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(!mutex_own(&(buf_pool->mutex)));
-+ ut_ad(!mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Note that we read freed_page_clock's without holding any mutex:
-@@ -860,12 +874,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- }
- }
-
-@@ -881,7 +895,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +903,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +914,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +924,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +965,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +986,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +994,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1013,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1023,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1065,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1073,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1094,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1102,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1181,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ //mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1226,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ //mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1238,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1242,7 +1263,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1685,7 +1706,7 @@
- buf_block_t* block) /* in: block to init */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
-@@ -1792,7 +1813,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1829,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1845,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1901,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1913,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1937,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1949,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1963,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +1999,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2082,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2090,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2126,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,10 +2136,23 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
-@@ -2132,6 +2178,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2188,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2215,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2195,7 +2241,10 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ /* for keep the new latch order, it cannot validate correctly... */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2256,18 +2305,26 @@
- }
-
- ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
-+ /* because of latching order with block->mutex, we cannot get free_mutex before that */
-+/*
- if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
- fprintf(stderr, "Free list len %lu, free blocks %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free);
- ut_error;
- }
-+*/
-+ /* because of latching order with block->mutex, we cannot get flush_list_mutex before that */
-+/*
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+*/
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2356,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2411,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,7 +2448,7 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2404,7 +2465,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2493,7 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2501,7 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(ratio);
- }
-@@ -2460,7 +2521,10 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- if (srv_use_awe) {
- fprintf(stderr,
-@@ -2533,7 +2597,10 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-
- /**************************************************************************
-@@ -2563,7 +2630,7 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2586,7 +2653,7 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(TRUE);
- }
-@@ -2626,11 +2693,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:57 2009 -0700
-@@ -49,7 +49,9 @@
- buf_block_t* block) /* in: block which is modified */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -79,7 +81,9 @@
- buf_block_t* b;
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- prev_b = NULL;
-@@ -113,16 +117,18 @@
- BUF_BLOCK_FILE_PAGE and in the LRU list */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
-- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ if (!block->in_LRU_list || block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -148,12 +154,13 @@
- ulint flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-+ //ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
-+ if (block->state == BUF_BLOCK_FILE_PAGE
-+ && (ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
- && (block->io_fix == 0)) {
- if (flush_type != BUF_FLUSH_LRU) {
-
-@@ -182,15 +189,17 @@
- {
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block->oldest_modification = ut_dulint_zero;
-
- UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
-
- ut_d(UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- (buf_pool->n_flush[block->flush_type])--;
-
-@@ -536,18 +545,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -744,7 +755,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -778,7 +789,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -789,14 +800,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -831,6 +842,7 @@
- ulint space;
- ulint offset;
- ibool found;
-+ ulint remaining = 0;
-
- ut_ad((flush_type == BUF_FLUSH_LRU)
- || (flush_type == BUF_FLUSH_LIST));
-@@ -849,6 +861,12 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- for (;;) {
- /* If we have flushed enough, leave the loop */
-@@ -865,7 +883,10 @@
- } else {
- ut_ad(flush_type == BUF_FLUSH_LIST);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ remaining = UT_LIST_GET_LEN(buf_pool->flush_list);
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- if (!block
- || (ut_dulint_cmp(block->oldest_modification,
- lsn_limit) >= 0)) {
-@@ -895,7 +916,9 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- old_page_count = page_count;
-
-@@ -915,7 +938,9 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -927,16 +952,25 @@
-
- mutex_exit(&block->mutex);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block = UT_LIST_GET_PREV(flush_list, block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ remaining--;
- }
- }
-
- /* If we could not find anything to flush, leave the loop */
-
-- if (!found) {
-+ if (!found && !remaining) {
- break;
- }
- }
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
-
- (buf_pool->init_flush)[flush_type] = FALSE;
-
-@@ -997,7 +1031,7 @@
- ulint n_replaceable;
- ulint distance = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-@@ -1007,6 +1041,12 @@
- && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN
- + BUF_FLUSH_EXTRA_MARGIN)
- && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
-+
-+ if (!block->in_LRU_list) {
-+ /* reatart. but it is very optimistic */
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+ continue;
-+ }
-
- mutex_enter(&block->mutex);
-
-@@ -1021,7 +1061,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1040,8 +1080,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1051,7 +1092,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1101,11 +1142,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0lru.c Fri Jul 03 15:41:57 2009 -0700
-@@ -108,7 +108,7 @@
-
- page_arr = ut_malloc(sizeof(ulint)
- * BUF_LRU_DROP_SEARCH_HASH_SIZE);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- scan_again:
- num_entries = 0;
-@@ -147,12 +147,12 @@
- }
- /* Array full. We release the buf_pool->mutex to
- obey the latching order. */
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- buf_LRU_drop_page_hash_batch(id, page_arr,
- num_entries);
- num_entries = 0;
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- } else {
- mutex_exit(&block->mutex);
- }
-@@ -177,7 +177,7 @@
- }
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- /* Drop any remaining batch of search hashed pages. */
- buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);
-@@ -206,7 +206,8 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +245,8 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +276,8 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +300,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +316,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +340,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +363,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,7 +386,6 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
-@@ -381,6 +393,16 @@
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,6 +413,7 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-
- mutex_exit(&(buf_pool->mutex));
-@@ -398,6 +421,8 @@
- return(FALSE);
- }
- }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +474,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +483,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +507,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,10 +563,16 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ mutex_enter(&(buf_pool->free_mutex));
-+ block = UT_LIST_GET_LAST(buf_pool->free);
-+ if (!block) {
-+ mutex_exit(&(buf_pool->free_mutex));
-+ goto no_block;
-+ }
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-+ mutex_exit(&(buf_pool->free_mutex));
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
- ut_a(!block->in_LRU_list);
-
-@@ -564,7 +597,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -572,11 +605,12 @@
-
- return(block);
- }
-+no_block:
-
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +647,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -655,7 +689,7 @@
-
- ut_a(buf_pool->LRU_old);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5);
-
-@@ -730,7 +764,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -796,7 +830,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -861,7 +895,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -964,7 +998,7 @@
- buf_block_t* block) /* in: block, must not contain a file page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -981,8 +1015,10 @@
- /* Wipe contents of page to reveal possible stale pointers to it */
- memset(block->frame, '\0', UNIV_PAGE_SIZE);
- #endif
-+ mutex_enter(&(buf_pool->free_mutex));
- UT_LIST_ADD_FIRST(free, buf_pool->free, block);
- block->in_free_list = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (srv_use_awe && block->frame) {
- /* Add to the list of mapped pages */
-@@ -1004,7 +1040,7 @@
- may or may not be a hash index to the page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -1062,7 +1098,7 @@
- be in a state where it can be freed */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
-@@ -1085,7 +1121,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1130,6 +1166,9 @@
- ut_a(buf_pool->LRU_old_len == old_len);
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
- block = UT_LIST_GET_FIRST(buf_pool->free);
-@@ -1140,7 +1179,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1195,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1239,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -r 7ac364cc9b41 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/buf/buf0rea.c Fri Jul 03 15:41:57 2009 -0700
-@@ -237,10 +237,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -252,7 +254,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -348,7 +350,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -451,6 +453,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -464,6 +467,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -480,12 +484,11 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
--
-- mutex_exit(&(buf_pool->mutex));
-
- return(0);
- }
-@@ -493,10 +496,11 @@
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -512,7 +516,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -588,7 +592,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -656,7 +660,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -728,7 +732,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -r 7ac364cc9b41 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0buf.h Fri Jul 03 15:41:57 2009 -0700
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -r 7ac364cc9b41 innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0buf.ic Fri Jul 03 15:41:57 2009 -0700
-@@ -112,7 +112,8 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+try_again:
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -120,9 +121,13 @@
- lsn = ut_dulint_zero;
- } else {
- lsn = block->oldest_modification;
-+ if (ut_dulint_cmp(lsn, ut_dulint_zero) == 0) {
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ goto try_again;
-+ }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -137,7 +142,7 @@
- /* out: new clock value */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- buf_pool->ulint_clock++;
-@@ -392,18 +397,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +430,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +438,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -456,7 +461,7 @@
- block = buf_block_align(frame);
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /*UNIV_SYNC_DEBUG */
-
-@@ -477,7 +482,7 @@
- buf_block_t* block) /* in: block */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /* UNIV_SYNC_DEBUG */
-
-@@ -555,7 +560,8 @@
-
- ut_ad(buf_pool);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_EX)
-+ || rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_SHARED));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Look for the page in the hash table */
-@@ -631,11 +637,14 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ /* buf_flush_note_modification() should be called before this function. */
-+/*
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
- mutex_enter(&buf_pool->mutex);
- buf_flush_note_modification(block, mtr);
- mutex_exit(&buf_pool->mutex);
- }
-+*/
-
- mutex_enter(&block->mutex);
-
-diff -r 7ac364cc9b41 innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0flu.h Fri Jul 03 15:41:57 2009 -0700
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -r 7ac364cc9b41 innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/buf0flu.ic Fri Jul 03 15:41:57 2009 -0700
-@@ -38,11 +38,14 @@
- mtr_t* mtr) /* in: mtr */
- {
- ut_ad(block);
-+
-+ mutex_enter(&block->mutex);
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0);
-@@ -52,15 +55,19 @@
- block->newest_modification = mtr->end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = mtr->start_lsn;
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- mtr->start_lsn) <= 0);
- }
-+
-+ mutex_exit(&block->mutex);
-
- ++srv_buf_pool_write_requests;
- }
-@@ -78,29 +85,32 @@
- set of mtr's */
- {
- ut_ad(block);
-+
-+ mutex_enter(&(block->mutex));
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
--
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
- block->newest_modification = end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = start_lsn;
-
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_sorted_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(block->mutex));
- }
-diff -r 7ac364cc9b41 innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/include/sync0sync.h Fri Jul 03 15:41:57 2009 -0700
-@@ -438,8 +438,12 @@
- SYNC_SEARCH_SYS, as memory allocation
- can call routines there! Otherwise
- the level is SYNC_MEM_HASH. */
-+#define SYNC_BUF_LRU_LIST 157
-+#define SYNC_BUF_PAGE_HASH 156
-+#define SYNC_BUF_BLOCK 155
-+#define SYNC_BUF_FREE_LIST 153
- #define SYNC_BUF_POOL 150
--#define SYNC_BUF_BLOCK 149
-+#define SYNC_BUF_FLUSH_LIST 149
- #define SYNC_DOUBLEWRITE 140
- #define SYNC_ANY_LATCH 135
- #define SYNC_THR_LOCAL 133
-diff -r 7ac364cc9b41 innobase/log/log0recv.c
---- a/innobase/log/log0recv.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/log/log0recv.c Fri Jul 03 15:41:57 2009 -0700
-@@ -1693,11 +1693,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -r 7ac364cc9b41 innobase/mtr/mtr0mtr.c
---- a/innobase/mtr/mtr0mtr.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/mtr/mtr0mtr.c Fri Jul 03 15:41:57 2009 -0700
-@@ -103,6 +103,38 @@
- }
- }
-
-+UNIV_INLINE
-+void
-+mtr_memo_note_modification_all(
-+/*===========================*/
-+ mtr_t* mtr) /* in: mtr */
-+{
-+ mtr_memo_slot_t* slot;
-+ dyn_array_t* memo;
-+ ulint offset;
-+
-+ ut_ad(mtr);
-+ ut_ad(mtr->magic_n == MTR_MAGIC_N);
-+ ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in
-+ commit */
-+ ut_ad(mtr->modifications);
-+
-+ memo = &(mtr->memo);
-+
-+ offset = dyn_array_get_data_size(memo);
-+
-+ while (offset > 0) {
-+ offset -= sizeof(mtr_memo_slot_t);
-+ slot = dyn_array_get_element(memo, offset);
-+
-+ if (UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-+ }
-+}
-+
- /****************************************************************
- Writes the contents of a mini-transaction log, if any, to the database log. */
- static
-@@ -177,6 +209,8 @@
- #endif
- if (mtr->modifications) {
- mtr_log_reserve_and_write(mtr);
-+
-+ mtr_memo_note_modification_all(mtr);
- }
-
- /* We first update the modification info to buffer pages, and only
-@@ -187,11 +221,12 @@
- required when we insert modified buffer pages in to the flush list
- which must be sorted on oldest_modification. */
-
-- mtr_memo_pop_all(mtr);
--
- if (mtr->modifications) {
- log_release();
- }
-+
-+ /* All unlocking has been moved here, after log_sys mutex release. */
-+ mtr_memo_pop_all(mtr);
-
- #ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTED;
-@@ -262,6 +297,12 @@
- slot = dyn_array_get_element(memo, offset);
-
- if ((object == slot->object) && (type == slot->type)) {
-+ if (mtr->modifications &&
-+ UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-
- mtr_memo_slot_release(mtr, slot);
-
-diff -r 7ac364cc9b41 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:57 2009 -0700
-@@ -367,6 +367,7 @@
- ulong srv_n_free_tickets_to_enter = 500;
- ulong srv_thread_sleep_delay = 10000;
- ulint srv_spin_wait_delay = 5;
-+ulint srv_spins_microsec = 50;
- ibool srv_priority_boost = TRUE;
-
- ibool srv_print_thread_releases = FALSE;
-@@ -673,6 +674,47 @@
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-
-+static
-+void
-+srv_align_spins_microsec(void)
-+{
-+ ulint start_sec, end_sec;
-+ ulint start_usec, end_usec;
-+ ib_longlong usecs;
-+
-+ /* change temporary */
-+ srv_spins_microsec = 1;
-+
-+ if (ut_usectime(&start_sec, &start_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ ut_delay(100000);
-+
-+ if (ut_usectime(&end_sec, &end_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ usecs = (end_sec - start_sec) * 1000000LL + (end_usec - start_usec);
-+
-+ if (usecs) {
-+ srv_spins_microsec = 100000 / usecs;
-+ if (srv_spins_microsec == 0)
-+ srv_spins_microsec = 1;
-+ if (srv_spins_microsec > 50)
-+ srv_spins_microsec = 50;
-+ } else {
-+ srv_spins_microsec = 50;
-+ }
-+end:
-+ if (srv_spins_microsec != 50)
-+ fprintf(stderr,
-+ "InnoDB: unit of spin count at ut_delay() is aligned to %lu\n",
-+ srv_spins_microsec);
-+}
-+
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-
-@@ -905,6 +947,8 @@
- srv_slot_t* slot;
- dict_table_t* table;
- ulint i;
-+
-+ srv_align_spins_microsec();
-
- srv_sys = mem_alloc(sizeof(srv_sys_t));
-
-@@ -2661,7 +2705,7 @@
- ib_longlong level, bpl;
- buf_block_t* bpage;
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- level = 0;
- bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-@@ -2683,7 +2727,7 @@
- bpl = 0;
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- if (!srv_use_doublewrite_buf) {
- /* flush is faster than when doublewrite */
-diff -r 7ac364cc9b41 innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/sync/sync0sync.c Fri Jul 03 15:41:57 2009 -0700
-@@ -1105,11 +1105,19 @@
- } else if (level == SYNC_DOUBLEWRITE) {
- ut_a(sync_thread_levels_g(array, SYNC_DOUBLEWRITE));
- } else if (level == SYNC_BUF_BLOCK) {
-- ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL)
-+ ut_a((sync_thread_levels_contain(array, SYNC_BUF_LRU_LIST)
- && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1))
- || sync_thread_levels_g(array, SYNC_BUF_BLOCK));
- } else if (level == SYNC_BUF_POOL) {
- ut_a(sync_thread_levels_g(array, SYNC_BUF_POOL));
-+ } else if (level == SYNC_BUF_FLUSH_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FLUSH_LIST));
-+ } else if (level == SYNC_BUF_FREE_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FREE_LIST));
-+ } else if (level == SYNC_BUF_PAGE_HASH) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_PAGE_HASH));
-+ } else if (level == SYNC_BUF_LRU_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_LRU_LIST));
- } else if (level == SYNC_SEARCH_SYS) {
- ut_a(sync_thread_levels_g(array, SYNC_SEARCH_SYS));
- } else if (level == SYNC_TRX_LOCK_HEAP) {
-diff -r 7ac364cc9b41 innobase/ut/ut0ut.c
---- a/innobase/ut/ut0ut.c Fri Jul 03 15:41:50 2009 -0700
-+++ b/innobase/ut/ut0ut.c Fri Jul 03 15:41:57 2009 -0700
-@@ -347,6 +347,7 @@
- /*****************************************************************
- Runs an idle loop on CPU. The argument gives the desired delay
- in microseconds on 100 MHz Pentium + Visual C++. */
-+extern ulint srv_spins_microsec;
-
- ulint
- ut_delay(
-@@ -358,7 +359,11 @@
-
- j = 0;
-
-- for (i = 0; i < delay * 50; i++) {
-+ for (i = 0; i < delay * srv_spins_microsec; i++) {
-+#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__)
-+ /* it is equal to the instruction 'pause' */
-+ __asm__ __volatile__ ("rep; nop");
-+#endif
- j += i;
- }
-
-diff -r 7ac364cc9b41 patch_info/innodb_split_buf_pool_mutex.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_split_buf_pool_mutex.info Fri Jul 03 15:41:57 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_split_buf_pool_mutex.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=Backport from XtraDB
-diff -r 7ac364cc9b41 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:50 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:57 2009 -0700
-@@ -1503,6 +1503,13 @@
- /* We set srv_pool_size here in units of 1 kB. InnoDB internally
- changes the value so that it becomes the number of database pages. */
-
-+ if (innobase_buffer_pool_awe_mem_mb) {
-+ /* split_buf_pool_mutex.patch don't support AWE */
-+ fputs("InnoDB: Warning: split_buf_pool_mutex.patch don't support AWE. Disabled.\n",
-+ stderr);
-+ innobase_buffer_pool_awe_mem_mb = 0;
-+ }
-+
- if (innobase_buffer_pool_awe_mem_mb == 0) {
- /* Careful here: we first convert the signed long int to ulint
- and only after that divide */
diff --git a/percona/5.0.84-b18-20090811/innodb_thread_concurrency_timer_based.patch b/percona/5.0.84-b18-20090811/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 3b8f659..0000000
--- a/percona/5.0.84-b18-20090811/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/innodb_use_sys_malloc.patch b/percona/5.0.84-b18-20090811/innodb_use_sys_malloc.patch
deleted file mode 100644
index 9637315..0000000
--- a/percona/5.0.84-b18-20090811/innodb_use_sys_malloc.patch
+++ /dev/null
@@ -1,265 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-06 16:06:51.000000000 +0900
-@@ -90,6 +90,7 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_use_sys_malloc;
- extern ibool srv_thread_concurrency_timer_based;
-
- extern ulint srv_n_file_io_threads;
-diff -ruN a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h
---- a/innobase/include/ut0mem.h 2009-07-07 21:54:07.000000000 +0900
-+++ b/innobase/include/ut0mem.h 2009-08-03 14:42:17.000000000 +0900
-@@ -30,6 +30,13 @@
-
-
- /**************************************************************************
-+Initializes the mem block list at database startup. */
-+
-+void
-+ut_mem_block_list_init(void);
-+/*========================*/
-+
-+/**************************************************************************
- Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
- defined and set_to_zero is TRUE. */
-
-diff -ruN a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
---- a/innobase/mem/mem0dbg.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0dbg.c 2009-07-06 16:48:17.000000000 +0900
-@@ -134,6 +134,14 @@
- mem_hash_initialized = TRUE;
- #endif
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ /* When innodb_use_sys_malloc is set, the
-+ mem_comm_pool won't be used for any allocations. We
-+ create a dummy mem_comm_pool, because some statistics
-+ and debugging code relies on it being initialized. */
-+ size = 1;
-+ }
-+
- mem_comm_pool = mem_pool_create(size);
- }
-
-diff -ruN a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c
---- a/innobase/mem/mem0pool.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0pool.c 2009-07-06 17:22:09.000000000 +0900
-@@ -11,6 +11,7 @@
- #include "mem0pool.ic"
- #endif
-
-+#include "srv0srv.h"
- #include "sync0sync.h"
- #include "ut0mem.h"
- #include "ut0lst.h"
-@@ -191,8 +192,6 @@
- ulint i;
- ulint used;
-
-- ut_a(size > 10000);
--
- pool = ut_malloc(sizeof(mem_pool_t));
-
- /* We do not set the memory to zero (FALSE) in the pool,
-@@ -330,6 +329,10 @@
- ulint n;
- ibool ret;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(malloc(size));
-+ }
-+
- n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
-
- mutex_enter(&(pool->mutex));
-@@ -457,6 +460,11 @@
- ulint size;
- ulint n;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ free(ptr);
-+ return;
-+ }
-+
- /* It may be that the area was really allocated from the OS with
- regular malloc: check if ptr points within our memory pool */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-06 16:08:06.000000000 +0900
-@@ -273,6 +273,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_use_sys_malloc = TRUE;
- ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-@@ -1012,6 +1013,7 @@
- srv_general_init(void)
- /*==================*/
- {
-+ ut_mem_block_list_init();
- os_sync_init();
- sync_init();
- mem_init(srv_mem_pool_size);
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-06 16:23:38.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ fprintf(stderr,
-+ "InnoDB: The InnoDB memory heap is disabled\n");
-+ }
-+
- #ifdef HAVE_ATOMIC_BUILTINS
- fprintf(stderr,
- "InnoDB: use atomic builtins.\n");
-diff -ruN a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
---- a/innobase/ut/ut0mem.c 2009-05-08 06:12:13.000000000 +0900
-+++ b/innobase/ut/ut0mem.c 2009-07-06 16:42:26.000000000 +0900
-@@ -15,6 +15,7 @@
- #include "mem0mem.h"
- #include "os0sync.h"
- #include "os0thread.h"
-+#include "srv0srv.h"
-
- /* This struct is placed first in every allocated memory block */
- typedef struct ut_mem_block_struct ut_mem_block_t;
-@@ -43,7 +44,7 @@
-
- /**************************************************************************
- Initializes the mem block list at database startup. */
--static
-+
- void
- ut_mem_block_list_init(void)
- /*========================*/
-@@ -70,11 +71,21 @@
- ulint retry_count = 0;
- void* ret;
-
-- ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ ret = malloc(n);
-+ ut_a(ret || !assert_on_error);
-
-- if (!ut_mem_block_list_inited) {
-- ut_mem_block_list_init();
-+#ifdef UNIV_SET_MEM_TO_ZERO
-+ if (set_to_zero) {
-+ memset(ret, '\0', n);
-+ }
-+#endif
-+ return(ret);
- }
-+
-+ ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+
-+ ut_a(ut_mem_block_list_inited);
- retry:
- os_fast_mutex_lock(&ut_list_mutex);
-
-@@ -223,6 +236,11 @@
- {
- 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);
-@@ -275,6 +293,10 @@
- ulint min_size;
- void* new_ptr;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(realloc(ptr, size));
-+ }
-+
- if (ptr == NULL) {
-
- return(ut_malloc(size));
-diff -ruN a/patch_info/innodb_use_sys_malloc.info b/patch_info/innodb_use_sys_malloc.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_use_sys_malloc.info 2009-07-06 16:04:24.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_use_sys_malloc.patch
-+Name=InnoDB uses malloc directly (backport from InnoDB-Plugin)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-06 16:10:15.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_use_sys_malloc;
- my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -1492,6 +1493,8 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_use_sys_malloc = (ibool) innobase_use_sys_malloc;
-+
- srv_thread_concurrency_timer_based =
- (ibool) innobase_thread_concurrency_timer_based;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-06 16:10:42.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_use_sys_malloc;
- extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-06 16:16:56.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_USE_SYS_MALLOC,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5470,6 +5471,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_use_sys_malloc", OPT_INNODB_USE_SYS_MALLOC,
-+ "Use OS memory allocator instead of InnoDB's internal memory allocator",
-+ (gptr*) &innobase_use_sys_malloc, (gptr*) &innobase_use_sys_malloc,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
- {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- "Use InnoDB timer based concurrency throttling. ",
- (gptr*) &innobase_thread_concurrency_timer_based,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-06 16:22:05.000000000 +0900
-@@ -1093,6 +1093,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.84-b18-20090811/microsec_process.patch b/percona/5.0.84-b18-20090811/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.84-b18-20090811/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.84-b18-20090811/microslow_innodb.patch b/percona/5.0.84-b18-20090811/microslow_innodb.patch
deleted file mode 100644
index 11a186c..0000000
--- a/percona/5.0.84-b18-20090811/microslow_innodb.patch
+++ /dev/null
@@ -1,2492 +0,0 @@
-diff -r 1242d4575291 include/my_getopt.h
---- a/include/my_getopt.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_getopt.h Tue Jul 28 23:42:44 2009 -0700
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 1242d4575291 include/my_time.h
---- a/include/my_time.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_time.h Tue Jul 28 23:42:44 2009 -0700
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 1242d4575291 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0buf.c Tue Jul 28 23:42:44 2009 -0700
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1090,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1142,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1158,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1190,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1303,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1276,6 +1323,12 @@
- break;
- }
- }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
- }
-
- fix_type = MTR_MEMO_BUF_FIX;
-@@ -1296,12 +1349,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1384,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,7 +1499,7 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
-@@ -1448,6 +1507,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-@@ -1470,6 +1534,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1559,6 +1624,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-diff -r 1242d4575291 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0rea.c Tue Jul 28 23:42:44 2009 -0700
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 1242d4575291 innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/fil/fil0fil.c Tue Jul 28 23:42:44 2009 -0700
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 1242d4575291 innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/buf0rea.h Tue Jul 28 23:42:44 2009 -0700
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 1242d4575291 innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/fil0fil.h Tue Jul 28 23:42:44 2009 -0700
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 1242d4575291 innobase/include/os0file.h
---- a/innobase/include/os0file.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/os0file.h Tue Jul 28 23:42:44 2009 -0700
-@@ -11,6 +11,8 @@
-
- #include "univ.i"
-
-+#include "trx0types.h"
-+
- #ifndef __WIN__
- #include <dirent.h>
- #include <sys/stat.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 1242d4575291 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/srv0srv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -27,6 +27,8 @@
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-
-+extern ibool srv_slow_log;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-
-diff -r 1242d4575291 innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/trx0trx.h Tue Jul 28 23:42:44 2009 -0700
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 1242d4575291 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/lock/lock0lock.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 1242d4575291 innobase/os/os0file.c
---- a/innobase/os/os0file.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/os/os0file.c Tue Jul 28 23:42:44 2009 -0700
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1905,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1919,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1948,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1968,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1981,6 +2005,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(ret);
- }
- #endif
-@@ -2103,7 +2134,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2144,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2209,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3169,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3423,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3463,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3497,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 1242d4575291 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/srv/srv0srv.c Tue Jul 28 23:42:44 2009 -0700
-@@ -48,6 +48,8 @@
- #include "srv0start.h"
- #include "row0mysql.h"
-
-+ibool srv_slow_log = 0;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
- ibool srv_lower_case_table_names = FALSE;
-@@ -1002,6 +1004,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1060,6 +1066,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1115,12 +1122,23 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_waiting_threads--;
-diff -r 1242d4575291 innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/trx/trx0trx.c Tue Jul 28 23:42:44 2009 -0700
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 1242d4575291 mysys/my_getopt.c
---- a/mysys/my_getopt.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/mysys/my_getopt.c Tue Jul 28 23:42:44 2009 -0700
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1062,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 1242d4575291 patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Tue Jul 28 23:42:44 2009 -0700
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 1242d4575291 scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Tue Jul 28 23:39:12 2009 -0700
-+++ b/scripts/mysqldumpslow.sh Tue Jul 28 23:42:44 2009 -0700
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 1242d4575291 sql-common/my_time.c
---- a/sql-common/my_time.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql-common/my_time.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1253,3 +1253,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 1242d4575291 sql/filesort.cc
---- a/sql/filesort.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/filesort.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 1242d4575291 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -819,9 +820,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1324,6 +1350,8 @@
-
- /* -------------- Log files ---------------------------*/
-
-+ srv_slow_log = (ibool) opt_slow_log;
-+
- /* The default dir for log files is the datadir of MySQL */
-
- if (!innobase_log_group_home_dir) {
-@@ -4697,6 +4725,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4962,6 +4996,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5049,6 +5089,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5115,6 +5161,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len1 = strlen(from);
- name_len2 = strlen(to);
-
-@@ -6122,6 +6174,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6245,7 +6298,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 1242d4575291 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.h Tue Jul 28 23:42:44 2009 -0700
-@@ -271,6 +271,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 1242d4575291 sql/log.cc
---- a/sql/log.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2289,11 +2289,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2303,7 +2304,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2333,22 +2335,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 1242d4575291 sql/log_event.cc
---- a/sql/log_event.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log_event.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2061,6 +2061,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 1242d4575291 sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysql_priv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -507,6 +507,78 @@
-
- #define STRING_BUFFER_USUAL_SIZE 80
-
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-+
- enum enum_parsing_place
- {
- NO_MATTER,
-@@ -1365,6 +1437,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1376,7 +1449,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 1242d4575291 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysqld.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -176,7 +176,6 @@
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
-
--
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
- #endif
-@@ -411,10 +410,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -509,6 +511,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -588,7 +591,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3697,6 +3700,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4947,7 +4952,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5038,11 +5043,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5441,10 +5453,19 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
- "Path to transaction coordinator log (used for transactions that affect "
- "more than one storage engine, when binary log is disabled)",
-@@ -5808,6 +5829,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6110,11 +6134,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6893,7 +6937,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7364,6 +7412,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7696,10 +7773,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 1242d4575291 sql/set_var.cc
---- a/sql/set_var.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -697,6 +717,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -720,6 +744,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -773,6 +798,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -994,8 +1021,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1022,6 +1052,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1109,6 +1140,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1149,6 +1182,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1777,6 +1811,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1933,6 +1978,19 @@
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
- }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
-+ }
- case SHOW_HA_ROWS:
- {
- ha_rows value;
-@@ -2765,6 +2823,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3549,6 +3631,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 1242d4575291 sql/set_var.h
---- a/sql/set_var.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.h Tue Jul 28 23:42:44 2009 -0700
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -378,7 +384,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ulonglong :public sys_var_thd
- {
- public:
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -478,6 +496,66 @@
- };
-
-
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
- class sys_var_thd_storage_engine :public sys_var_thd
- {
- protected:
-@@ -1109,3 +1187,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 1242d4575291 sql/slave.cc
---- a/sql/slave.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/slave.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2983,6 +2983,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 1242d4575291 sql/sql_cache.cc
---- a/sql/sql_cache.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_cache.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1402,6 +1402,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1409,6 +1410,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 1242d4575291 sql/sql_class.cc
---- a/sql/sql_class.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -190,7 +190,7 @@
- table_map_for_update(0),
- global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2251,6 +2251,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2267,7 +2273,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2320,6 +2332,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 1242d4575291 sql/sql_class.h
---- a/sql/sql_class.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.h Tue Jul 28 23:42:44 2009 -0700
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1129,6 +1134,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1185,6 +1196,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1293,10 +1309,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1696,11 +1726,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 1242d4575291 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_parse.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,28 +2363,57 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-- thd->end_time(); // Set start time
-+ ulonglong start_of_query_timer= thd->start_timer;
-+ thd->end_time(); // Set start timea
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-+
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
-+
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((thd->start_time > thd->time_after_lock &&
-- (ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time) ||
-- ((thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END))
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2669,6 +2708,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6203,6 +6244,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 1242d4575291 sql/sql_select.cc
---- a/sql/sql_select.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_select.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -6272,8 +6272,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6288,8 +6291,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9350,6 +9356,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10210,6 +10217,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 1242d4575291 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_show.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1560,6 +1560,12 @@
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
-+ break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
- break;
-diff -r 1242d4575291 sql/structs.h
---- a/sql/structs.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/structs.h Tue Jul 28 23:42:44 2009 -0700
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.84-b18-20090811/mirror_binlog.patch b/percona/5.0.84-b18-20090811/mirror_binlog.patch
deleted file mode 100644
index d52e806..0000000
--- a/percona/5.0.84-b18-20090811/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5098,6 +5098,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
- };
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.84-b18-20090811/mysql-percona.spec b/percona/5.0.84-b18-20090811/mysql-percona.spec
deleted file mode 100644
index 0649c65..0000000
--- a/percona/5.0.84-b18-20090811/mysql-percona.spec
+++ /dev/null
@@ -1,1421 +0,0 @@
-%define mysql_vendor Percona Inc
-%{!?redhat_version:%define redhat_version 5}
-%define distribution rhel%{redhat_version}
-%define release 0.%{distribution}
-%{!?revision:%define revision unknown}
-
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'perconahighperf 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-# rpmbuild -ba mysql-percona.rhel5.spec --define 'percona 1' --define 'mysqlversion 5.0.67' --define 'redhat_version 5'
-
-# Meta information
-# norootforbuild
-
-# use "rpmbuild --with yassl" or "rpm --define '_with_yassl 1'" (for RPM 3.x)
-# to build with yaSSL support (off by default)
-%{?_with_yassl:%define YASSL_BUILD 1}
-%{!?_with_yassl:%define YASSL_BUILD 0}
-
-# FIXME disabled until we move out the version strings from spec file
-## use "rpmbuild --with cluster" or "rpm --define '_with_cluster 1'" (for RPM 3.x)
-## to build with cluster support (off by default)
-##%{?_with_cluster:%define CLUSTER_BUILD 1}
-##%{!?_with_cluster:%define CLUSTER_BUILD 0}
-
-#
-# Product definitions - one of these has to be defined via the RPM build
-# options, e.g. "--define 'enterprise 1'"
-#
-%{!?enterprise:%define enterprise 0}
-%{!?enterprise_gpl:%define enterprise_gpl 0}
-%{!?classic:%define classic 0}
-%{!?cluster:%define cluster 0}
-%{!?cluster_gpl:%define cluster_gpl 0}
-%{!?community:%define community 0}
-%{!?percona:%define percona 0}
-%{!?perconahighperf:%define perconahighperf 0}
-%{!?mysqlversion:%define mysqlversion 5.0.67}
-#%define mysql_version 5.0.67
-
-# On SuSE 9 no separate "debuginfo" package is built. To enable basic
-# debugging on that platform, we don't strip binaries on SuSE 9. We
-# disable the strip of binaries by redefining the RPM macro
-# "__os_install_post" leaving out the script calls that normally does
-# this. We do this in all cases, as on platforms where "debuginfo" is
-# created, a script "find-debuginfo.sh" will be called that will do
-# the strip anyway, part of separating the executable and debug
-# information into separate files put into separate packages.
-#
-# Some references (shows more advanced conditional usage):
-# http://www.redhat.com/archives/rpm-list/2001-November/msg00257.html
-# http://www.redhat.com/archives/rpm-list/2003-February/msg00275.html
-# http://www.redhat.com/archives/rhl-devel-list/2004-January/msg01546.html
-# http://lists.opensuse.org/archive/opensuse-commit/2006-May/1171.html
-
-%define __os_install_post /usr/lib/rpm/brp-compress
-
-
-%if %{percona}
-%define comment MySQL Percona Edition, Revision %{revision}
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-%{patchset}
-%endif
-
-%if %{perconahighperf}
-%define comment MySQL Percona High Performance Edition, Revision %{revision}
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -percona-highperf-%{patchset}
-%endif
-
-%if %{community}
-%define comment MySQL Community Edition
-%define commercial 0
-%define COMMUNITY_BUILD 1
-%define INNODB_BUILD 1
-%define server_suffix -community
-%endif
-
-%if %{enterprise}
-%define comment MySQL Enterprise Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise
-%endif
-
-%if %{enterprise_gpl}
-%define comment MySQL Enterprise Server
-%define commercial 0
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 1
-%define server_suffix -enterprise-gpl
-%endif
-
-%if %{classic}
-%define comment MySQL Classic Server
-%define commercial 1
-%define COMMUNITY_BUILD 0
-%define INNODB_BUILD 0
-%define server_suffix -classic
-%endif
-
-
-%if %{COMMUNITY_BUILD}
-%define cluster_package_prefix -cluster
-%else
-%define cluster_package_prefix -
-%endif
-
-%define mysqld_user mysql
-%define mysqld_group mysql
-%define mysqldatadir /var/lib/mysql
-
-# We don't package all files installed into the build root by intention -
-# See BUG#998 for details.
-%define _unpackaged_files_terminate_build 0
-
-%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com
-Source0: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-%{version}.tar.gz
-
-Patch1: show_patches.patch
-Patch2: microslow_innodb.patch
-Patch3: profiling_slow.patch
-Patch4: userstatv2.patch
-Patch5: microsec_process.patch
-Patch6: innodb_io_patches.patch
-Patch7: mysqld_safe_syslog.patch
-Patch8: innodb_locks_held.patch
-Patch9: innodb_show_bp.patch
-Patch10: innodb_check_fragmentation.patch
-Patch11: innodb_io_pattern.patch
-Patch12: innodb_fsync_source.patch
-Patch13: innodb_show_hashed_memory.patch
-Patch14: innodb_dict_size_limit.patch
-Patch15: innodb_extra_rseg.patch
-Patch16: innodb_thread_concurrency_timer_based.patch
-Patch17: innodb_use_sys_malloc.patch
-Patch18: innodb_recovery_patches.patch
-Patch119: innodb_split_buf_pool_mutex.patch
-Patch120: innodb_rw_lock.patch
-Patch21: mysql-test.patch
-
-Name: MySQL%{server_suffix}
-Summary: MySQL: a very fast and reliable SQL database server
-Group: Applications/Databases
-Version: %{mysqlversion}
-Release: %{release}
-Distribution: Red Hat Enterprise Linux %{redhat_version}
-License: GPL
-Source: mysql-%{mysqlversion}.tar.gz
-URL: http://www.mysql.com/
-Packager: Percona Build Team <info@percona.com>
-Vendor: %{mysql_vendor}
-Provides: msqlormysql MySQL-server mysql
-BuildRequires: gperf perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time
-
-# Think about what you use here since the first step is to
-# run a rm -rf
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
-
-# From the manual
-%description
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-%package -n MySQL-server%{server_suffix}
-Summary: @COMMENT@ for Red Hat Enterprise Linux %{redhat_version}
-Group: Applications/Databases
-Requires: chkconfig coreutils shadow-utils grep procps
-Provides: msqlormysql mysql-server mysql MySQL MySQL-server
-Obsoletes: MySQL mysql mysql-server MySQL-server
-
-%description -n MySQL-server%{server_suffix}
-The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
-and robust SQL (Structured Query Language) database server. MySQL Server
-is intended for mission-critical, heavy-load production systems as well
-as for embedding into mass-deployed software. MySQL is a trademark of
-MySQL AB.
-
-The MySQL software has Dual Licensing, which means you can use the MySQL
-software free of charge under the GNU General Public License
-(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
-licenses from MySQL AB if you do not wish to be bound by the terms of
-the GPL. See the chapter "Licensing and Support" in the manual for
-further info.
-
-The MySQL web site (http://www.mysql.com/) provides the latest
-news and information about the MySQL software. Also please see the
-documentation and the manual for more information.
-
-This package includes the MySQL server binary
-%if %{INNODB_BUILD}
-(configured including InnoDB)
-%endif
-as well as related utilities to run and administer a MySQL server.
-
-If you want to access and work with the database, you have to install
-package "MySQL-client%{server_suffix}" as well!
-
-%package -n MySQL-client%{server_suffix}
-Summary: MySQL - Client
-Group: Applications/Databases
-Obsoletes: mysql-client MySQL-client
-Provides: mysql-client MySQL-client
-
-%description -n MySQL-client%{server_suffix}
-This package contains the standard MySQL clients and administration tools.
-
-%{see_base}
-
-%package -n MySQL-test%{server_suffix}
-Requires: mysql-client perl
-Summary: MySQL - Test suite
-Group: Applications/Databases
-Provides: mysql-test MySQL-test
-Obsoletes: mysql-test MySQL-test
-AutoReqProv: no
-
-%description -n MySQL-test%{server_suffix}
-This package contains the MySQL regression test suite.
-
-%{see_base}
-
-%package -n MySQL-devel%{server_suffix}
-Summary: MySQL - Development header files and libraries
-Group: Applications/Databases
-Provides: mysql-devel MySQL-devel
-Obsoletes: mysql-devel MySQL-devel
-
-%description -n MySQL-devel%{server_suffix}
-This package contains the development header files and libraries
-necessary to develop MySQL client applications.
-
-%{see_base}
-
-%package -n MySQL-shared%{server_suffix}
-Summary: MySQL - Shared libraries
-Group: Applications/Databases
-Provides: mysql-shared MySQL-shared
-# Obsoletes below to correct old missing Provides:/Obsoletes
-Obsoletes: mysql-shared MySQL-shared-standard MySQL-shared-pro
-Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl
-Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared
-
-%description -n MySQL-shared%{server_suffix}
-This package contains the shared libraries (*.so*) which certain
-languages and applications need to dynamically load and use MySQL.
-
-%prep
-%setup -n mysql-%{mysqlversion}
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
-%patch14 -p1
-%patch15 -p1
-%patch16 -p1
-%patch17 -p1
-%patch18 -p1
-%if %{perconahighperf}
-%patch119 -p1
-%patch120 -p1
-%endif
-%patch21 -p1
-
-%build
-
-pushd ..
-tar cfz mysql-%{mysqlversion}%{server_suffix}-src.tar.gz mysql-%{mysqlversion}
-mv mysql-%{mysqlversion}%{server_suffix}-src.tar.gz %{_topdir}
-popd
-
-BuildMySQL() {
-# Evaluate current setting of $DEBUG
-if [ $DEBUG -gt 0 ] ; then
- OPT_COMMENT='--with-comment="%{comment} - Debug (%{license})"'
- OPT_DEBUG='--with-debug'
-else
- OPT_COMMENT='--with-comment="%{comment} (%{license})"'
- OPT_DEBUG=''
-fi
-if [ $BINARYPKG -ne 1 ] ; then
- OPT_PATH='--exec-prefix=%{_exec_prefix} \
- --libexecdir=%{_sbindir} \
- --libdir=%{_libdir} \
- --sysconfdir=%{_sysconfdir} \
- --datadir=%{_datadir} \
- --localstatedir=%{mysqldatadir} \
- --infodir=%{_infodir} \
- --includedir=%{_includedir} \
- --mandir=%{_mandir}'
-else
- OPT_PATH='--prefix=/usr/local/mysql-%{mysqlversion}%{server_suffix}'
-fi
-
-# The --enable-assembler simply does nothing on systems that does not
-# support assembler speedups.
-sh -c "CFLAGS=\"${CFLAGS:-$RPM_OPT_FLAGS}\" \
- CXXFLAGS=\"${CXXFLAGS:-$RPM_OPT_FLAGS}\" \
- LDFLAGS=\"$LDFLAGS\" \
- ./configure \
- $* \
- --enable-assembler \
- --enable-local-infile \
- --with-mysqld-user=%{mysqld_user} \
- --with-unix-socket-path=/var/lib/mysql/mysql.sock \
- --with-pic \
- --prefix=/ \
- --with-extra-charsets=complex \
-%if %{YASSL_BUILD}
- --with-yassl \
-%endif
- $OPT_PATH \
- --enable-thread-safe-client \
-%if %{?comment:1}0
- $OPT_COMMENT \
-%endif
- $OPT_DEBUG \
- --with-readline \
- ; make -j8"
-}
-# end of function definition "BuildMySQL"
-
-
-BuildServer() {
-BuildMySQL "--disable-shared \
-%if %{?server_suffix:1}0
- --with-server-suffix='%{server_suffix}' \
-%endif
- --without-embedded-server \
-%if %{INNODB_BUILD}
- --with-innodb \
-%else
- --without-innodb \
-%endif
- --with-csv-storage-engine \
- --with-archive-storage-engine \
- --with-blackhole-storage-engine \
- --with-federated-storage-engine \
- --without-bench \
- --with-zlib-dir=bundled \
- --with-big-tables"
-
-if [ -n "$MYSQL_CONFLOG_DEST" ] ; then
- cp -fp config.log "$MYSQL_CONFLOG_DEST"
-fi
-
-if [ -f sql/.libs/mysqld ] ; then
- nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym
-else
- nm --numeric-sort sql/mysqld > sql/mysqld.sym
-fi
-}
-# end of function definition "BuildServer"
-
-
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Clean up the BuildRoot first
-[ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR;
-mkdir -p $RBR%{_libdir}/mysql $RBR%{_sbindir}
-
-# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and
-# including exceptions into the code
-if [ -z "$CXX" -a -z "$CC" ] ; then
- export CC="ccache gcc" CXX="ccache gcc"
-fi
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-
-
-if [ "%{redhat_version}" = "5" ] ; then
-export CFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
-fi
-
-if [ "%{redhat_version}" != "5" ] ; then
-export CFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-export CXXFLAGS="-O2 -g -fno-omit-frame-pointer -pipe -m64"
-fi
-
-
-# Create the shared libs seperately to avoid a dependency for the client utilities
-DEBUG=0
-BINARYPKG=0
-BuildMySQL "--enable-shared --without-server"
-
-# Install shared libraries
-cp -av libmysql/.libs/*.so* $RBR/%{_libdir}
-cp -av libmysql_r/.libs/*.so* $RBR/%{_libdir}
-
-# Include libgcc.a in the devel subpackage (BUG 4921)
-if expr "$CC" : "gcc.*" > /dev/null && \
- expr "$CC" : ".* gcc.*" > /dev/null ; then
- libgcc=`$CC $CFLAGS --print-libgcc-file`
- if [ -f $libgcc ] ; then
- install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a
- fi
-fi
-
-# Now create a debug server
-DEBUG=1
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt-debug
-fi
-
-# Get the debug server and its .sym file from the build tree
-if [ -f sql/.libs/mysqld ] ; then
- cp sql/.libs/mysqld $RBR%{_sbindir}/mysqld-debug
-else
- cp sql/mysqld $RBR%{_sbindir}/mysqld-debug
-fi
-
-cp sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld-debug.sym
-
-# Now, the binary package
-DEBUG=0
-BINARYPKG=1
-make clean distclean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-rm -fr /tmp/mysql-%{mysqlversion}%{server_suffix}
-make DESTDIR=/tmp/mysql-%{mysqlversion}%{server_suffix} install
-pushd /tmp/mysql-%{mysqlversion}%{server_suffix}/usr/local
-tar cfz mysql-%{mysqlversion}%{server_suffix}.tar.gz mysql-%{mysqlversion}%{server_suffix}
-mv mysql-%{mysqlversion}%{server_suffix}.tar.gz %{_topdir}
-popd
-
-# Now, the default server
-DEBUG=0
-BINARYPKG=0
-make clean
-
-BuildServer
-
-MYSQL_RPMBUILD_TEST=no
-
-if [ "$MYSQL_RPMBUILD_TEST" != "no" ] ; then
- make test-bt
-fi
-
-
-%install
-RBR=$RPM_BUILD_ROOT
-MBD=$RPM_BUILD_DIR/mysql-%{mysqlversion}
-
-# Ensure that needed directories exists
-install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
-install -d $RBR%{mysqldatadir}/mysql
-install -d $RBR%{_datadir}/mysql-test
-install -d $RBR%{_datadir}/mysql/SELinux/RHEL4
-install -d $RBR%{_includedir}
-install -d $RBR%{_libdir}
-install -d $RBR%{_mandir}
-install -d $RBR%{_sbindir}
-
-make DESTDIR=$RBR benchdir_root=%{_datadir} install
-
-# install symbol files ( for stack trace resolution)
-install -m644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym
-
-# Install logrotate and autostart
-install -m644 $MBD/support-files/mysql-log-rotate \
- $RBR%{_sysconfdir}/logrotate.d/mysql
-install -m755 $MBD/support-files/mysql.server \
- $RBR%{_sysconfdir}/init.d/mysql
-
-# Create a symlink "rcmysql", pointing to the init.script. SuSE users
-# will appreciate that, as all services usually offer this.
-ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql
-
-# Create symbolic compatibility link safe_mysqld -> mysqld_safe
-# (safe_mysqld will be gone in MySQL 4.1)
-ln -sf ./mysqld_safe $RBR%{_bindir}/safe_mysqld
-
-# Touch the place where the my.cnf config file and mysqlmanager.passwd
-# (MySQL Instance Manager password file) might be located
-# Just to make sure it's in the file list and marked as a config file
-touch $RBR%{_sysconfdir}/my.cnf
-touch $RBR%{_sysconfdir}/mysqlmanager.passwd
-
-# Install SELinux files in datadir
-install -m600 $MBD/support-files/RHEL4-SElinux/mysql.{fc,te} \
- $RBR%{_datadir}/mysql/SELinux/RHEL4
-
-
-%pre -n MySQL-server%{server_suffix}
-# Check if we can safely upgrade. An upgrade is only safe if it's from one
-# of our RPMs in the same version family.
-
-installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
-if [ $? -eq 0 -a -n "$installed" ]; then
- vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
- version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
- myvendor='%{mysql_vendor}'
- myversion='%{mysqlversion}'
-
- old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
- new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
-
- [ -z "$vendor" ] && vendor='<unknown>'
- [ -z "$old_family" ] && old_family="<unrecognized version $version>"
- [ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"
-
- error_text=
- if [ "$vendor" != "$myvendor" ]; then
- error_text="$error_text
-The current MySQL server package is provided by a different
-vendor ($vendor) than $myvendor. Some files may be installed
-to different locations, including log files and the service
-startup script in %{_sysconfdir}/init.d/.
-"
- fi
-
- if [ "$old_family" != "$new_family" ]; then
- error_text="$error_text
-Upgrading directly from MySQL $old_family to MySQL $new_family may not
-be safe in all cases. A manual dump and restore using mysqldump is
-recommended. It is important to review the MySQL manual's Upgrading
-section for version-specific incompatibilities.
-"
- fi
-
- if [ -n "$error_text" ]; then
- cat <<HERE >&2
-
-******************************************************************
-A MySQL server package ($installed) is installed.
-$error_text
-A manual upgrade is required.
-
-- Ensure that you have a complete, working backup of your data and my.cnf
- files
-- Shut down the MySQL server cleanly
-- Remove the existing MySQL packages. Usually this command will
- list the packages you should remove:
- rpm -qa | grep -i '^mysql-'
-
- You may choose to use 'rpm --nodeps -ev <package-name>' to remove
- the package which contains the mysqlclient shared library. The
- library will be reinstalled by the MySQL-shared-compat package.
-- Install the new MySQL packages supplied by $myvendor
-- Ensure that the MySQL server is started
-- Run the 'mysql_upgrade' program
-
-This is a brief description of the upgrade process. Important details
-can be found in the MySQL manual, in the Upgrading section.
-******************************************************************
-HERE
- exit 1
- fi
-fi
-
-# Shut down a previously installed server first
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
- echo "Giving mysqld 5 seconds to exit nicely"
- sleep 5
-fi
-
-%post -n MySQL-server%{server_suffix}
-mysql_datadir=%{mysqldatadir}
-
-# Create data directory
-mkdir -p $mysql_datadir/{mysql,test}
-
-# Make MySQL start/shutdown automatically when the machine does it.
-if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --add mysql
-fi
-
-
-
-# Create a MySQL user and group. Do not report any problems if it already
-# exists.
-groupadd -r %{mysqld_group} 2> /dev/null || true
-useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-# The user may already exist, make sure it has the proper group nevertheless (BUG#12823)
-usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
-
-# Change permissions so that the user that will run the MySQL daemon
-# owns all database files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Initiate databases
-%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
-
-# Upgrade databases if needed would go here - but it cannot be automated yet
-
-# Change permissions again to fix any new files.
-chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
-
-# Fix permissions for the permission database so that only the user
-# can read them.
-chmod -R og-rw $mysql_datadir/mysql
-
-# install SELinux files - but don't override existing ones
-SETARGETDIR=/etc/selinux/targeted/src/policy
-SEDOMPROG=$SETARGETDIR/domains/program
-SECONPROG=$SETARGETDIR/file_contexts/program
-if [ -f /etc/redhat-release ] \
- && grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \
- || grep -q "CentOS release 4" /etc/redhat-release ; then
- echo
- echo
- echo 'Notes regarding SELinux on this platform:'
- echo '========================================='
- echo
- echo 'The default policy might cause server startup to fail because it is '
- echo 'not allowed to access critical files. In this case, please update '
- echo 'your installation. '
- echo
- echo 'The default policy might also cause inavailability of SSL related '
- echo 'features because the server is not allowed to access /dev/random '
- echo 'and /dev/urandom. If this is a problem, please do the following: '
- echo
- echo ' 1) install selinux-policy-targeted-sources from your OS vendor'
- echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':'
- echo ' allow mysqld_t random_device_t:chr_file read;'
- echo ' allow mysqld_t urandom_device_t:chr_file read;'
- echo ' 3) cd to '$SETARGETDIR' and issue the following command:'
- echo ' make load'
- echo
- echo
-fi
-
-if [ -x sbin/restorecon ] ; then
- sbin/restorecon -R var/lib/mysql
-fi
-
-# Restart in the same way that mysqld will be started normally.
-if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql start
- echo "Giving mysqld 2 seconds to start"
- sleep 2
-fi
-
-# Allow safe_mysqld to start mysqld and print a message before we exit
-sleep 2
-
-
-%preun -n MySQL-server%{server_suffix}
-if [ $1 = 0 ] ; then
- # Stop MySQL before uninstalling it
- if [ -x %{_sysconfdir}/init.d/mysql ] ; then
- %{_sysconfdir}/init.d/mysql stop > /dev/null
- # Don't start it automatically anymore
- if [ -x /sbin/chkconfig ] ; then
- /sbin/chkconfig --del mysql
- fi
- fi
-fi
-
-# We do not remove the mysql user since it may still own a lot of
-# database files.
-
-# Clean up the BuildRoot
-%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
-
-%files -n MySQL-server%{server_suffix}
-%defattr(-,root,root,0755)
-
-%if %{commercial}
-%doc LICENSE.mysql
-%else
-%doc COPYING README
-%endif
-%doc support-files/my-*.cnf
-
-%doc %attr(644, root, root) %{_infodir}/mysql.info*
-
-%if %{INNODB_BUILD}
-%doc %attr(644, root, man) %{_mandir}/man1/innochecksum.1*
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/my_print_defaults.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisam_ftdump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamchk.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisamlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/myisampack.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_convert_table_format.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_explain_log.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_extensions.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqld.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_multi.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_fix_privilege_tables.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlhotcopy.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
-%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
-%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
-%doc %attr(644, root, man) %{_mandir}/man1/replace.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/resolveip.1*
-%doc %attr(644, root, man) %{_mandir}/man1/safe_mysqld.1*
-
-%ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/mysqlmanager.passwd
-
-%if %{INNODB_BUILD}
-%attr(755, root, root) %{_bindir}/innochecksum
-%endif
-%attr(755, root, root) %{_bindir}/my_print_defaults
-%attr(755, root, root) %{_bindir}/myisam_ftdump
-%attr(755, root, root) %{_bindir}/myisamchk
-%attr(755, root, root) %{_bindir}/myisamlog
-%attr(755, root, root) %{_bindir}/myisampack
-%attr(755, root, root) %{_bindir}/mysql_convert_table_format
-%attr(755, root, root) %{_bindir}/mysql_explain_log
-%attr(755, root, root) %{_bindir}/mysql_fix_extensions
-%attr(755, root, root) %{_bindir}/mysql_fix_privilege_tables
-%attr(755, root, root) %{_bindir}/mysql_install_db
-%attr(755, root, root) %{_bindir}/mysql_secure_installation
-%attr(755, root, root) %{_bindir}/mysql_setpermission
-%attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql
-%attr(755, root, root) %{_bindir}/mysql_upgrade
-%attr(755, root, root) %{_bindir}/mysql_zap
-%attr(755, root, root) %{_bindir}/mysqlbug
-%attr(755, root, root) %{_bindir}/mysqld_multi
-%attr(755, root, root) %{_bindir}/mysqld_safe
-%attr(755, root, root) %{_bindir}/mysqldumpslow
-%attr(755, root, root) %{_bindir}/mysqlhotcopy
-%attr(755, root, root) %{_bindir}/mysqltest
-%attr(755, root, root) %{_bindir}/perror
-%attr(755, root, root) %{_bindir}/replace
-%attr(755, root, root) %{_bindir}/resolve_stack_dump
-%attr(755, root, root) %{_bindir}/resolveip
-%attr(755, root, root) %{_bindir}/safe_mysqld
-
-%attr(755, root, root) %{_sbindir}/mysqld
-%attr(755, root, root) %{_sbindir}/mysqld-debug
-%attr(755, root, root) %{_sbindir}/mysqlmanager
-%attr(755, root, root) %{_sbindir}/rcmysql
-%attr(644, root, root) %{_libdir}/mysql/mysqld.sym
-%attr(644, root, root) %{_libdir}/mysql/mysqld-debug.sym
-
-%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql
-%attr(755, root, root) %{_sysconfdir}/init.d/mysql
-
-%attr(755, root, root) %{_datadir}/mysql/
-
-%files -n MySQL-client%{server_suffix}
-%defattr(-, root, root, 0755)
-%attr(755, root, root) %{_bindir}/msql2mysql
-%attr(755, root, root) %{_bindir}/mysql
-%attr(755, root, root) %{_bindir}/mysql_find_rows
-%attr(755, root, root) %{_bindir}/mysql_tableinfo
-%attr(755, root, root) %{_bindir}/mysql_upgrade_shell
-%attr(755, root, root) %{_bindir}/mysql_waitpid
-%attr(755, root, root) %{_bindir}/mysqlaccess
-%attr(755, root, root) %{_bindir}/mysqladmin
-%attr(755, root, root) %{_bindir}/mysqlbinlog
-%attr(755, root, root) %{_bindir}/mysqlcheck
-%attr(755, root, root) %{_bindir}/mysqldump
-%attr(755, root, root) %{_bindir}/mysqlimport
-%attr(755, root, root) %{_bindir}/mysqlshow
-
-%doc %attr(644, root, man) %{_mandir}/man1/msql2mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_tableinfo.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_waitpid.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlaccess.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqladmin.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlbinlog.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlcheck.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1*
-
-%post -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%postun -n MySQL-shared%{server_suffix}
-/sbin/ldconfig
-
-%files -n MySQL-devel%{server_suffix}
-%defattr(-, root, root, 0755)
-%if %{commercial}
-%else
-%doc EXCEPTIONS-CLIENT
-%endif
-%doc %attr(644, root, man) %{_mandir}/man1/comp_err.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1*
-%attr(755, root, root) %{_bindir}/comp_err
-%attr(755, root, root) %{_bindir}/mysql_config
-%dir %attr(755, root, root) %{_libdir}/mysql
-%{_includedir}/mysql
-%{_libdir}/mysql/libdbug.a
-%{_libdir}/mysql/libheap.a
-%{_libdir}/mysql/libmy*.a
-%{_libdir}/mysql/libmy*.la
-%{_libdir}/mysql/libvio.a
-%{_libdir}/mysql/libz*
-
-%files -n MySQL-shared%{server_suffix}
-%defattr(-, root, root, 0755)
-# Shared libraries (omit for architectures that don't support them)
-%{_libdir}/*.so*
-
-
-%files -n MySQL-test%{server_suffix}
-%defattr(-, root, root, 0755)
-%{_datadir}/mysql-test
-%attr(755, root, root) %{_bindir}/mysql_client_test
-%attr(755, root, root) %{_bindir}/mysqltestmanager
-%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen
-%attr(755, root, root) %{_bindir}/mysqltestmanagerc
-%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
-%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
-
-# The spec file changelog only includes changes made to the spec file
-# itself - note that they must be ordered by date (important when
-# merging BK trees)
-%changelog
-* Mon Jul 07 2008 Jonathan Perkin <jperkin@sun.com>
-
-- Add 'classic' product.
-
-* Wed Jun 11 2008 Kent Boortz <kent@mysql.com>
-
-- Removed the Example storage engine, it is not to be in products
-
-* Mon Feb 18 2008 Timothy Smith <tim@mysql.com>
-
-- Require a manual upgrade if the alread-installed mysql-server is
- from another vendor, or is of a different major version.
-
-* Fri Dec 14 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the "%doc" directive for all man pages and other documentation;
- also, some re-ordering to reduce differences between spec files.
-
-* Wed Oct 31 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Explicitly handle InnoDB using its own variable and "--with"/"--without"
- options, because the "configure" default is "yes".
-
-* Tue Jul 17 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add the man page for "mysql-stress-test.pl" to the "test" RPM
- (consistency in fixing bug#21023, the script is handled by "Makefile.am")
-
-* Wed Jul 11 2007 Daniel Fischer <df@mysql.com>
-
-- Change the way broken SELinux policies on RHEL4 and CentOS 4
- are handled to be more likely to actually work
-
-* Thu Jun 05 2007 kent Boortz <kent@mysql.com>
-
-- Enabled the CSV engine in all builds
-
-* Thu May 3 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Spring cleanup
-
-* Thu Apr 19 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- If sbin/restorecon exists then run it
-
-* Wed Apr 18 2007 Kent Boortz <kent@mysql.com>
-
-- Packed unpacked files
-
- /usr/sbin/ndb_cpcd
- /usr/bin/mysql_upgrade_shell
- /usr/bin/innochecksum
- /usr/share/man/man1/ndb_cpcd.1.gz
- /usr/share/man/man1/innochecksum.1.gz
- /usr/share/man/man1/mysql_fix_extensions.1.gz
- /usr/share/man/man1/mysql_secure_installation.1.gz
- /usr/share/man/man1/mysql_tableinfo.1.gz
- /usr/share/man/man1/mysql_waitpid.1.gz
-
-- Commands currently not installed but that has man pages
-
- /usr/share/man/man1/make_win_bin_dist.1.gz
- /usr/share/man/man1/make_win_src_distribution.1.gz
- /usr/share/man/man1/mysql-stress-test.pl.1.gz
- /usr/share/man/man1/ndb_print_backup_file.1.gz
- /usr/share/man/man1/ndb_print_schema_file.1.gz
- /usr/share/man/man1/ndb_print_sys_file.1.gz
-
-* Thu Mar 22 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add "comment" options to the test runs, for better log analysis.
-
-* Wed Mar 21 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add even more man pages.
-
-* Fri Mar 16 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Build the server twice, once as "mysqld-debug" and once as "mysqld";
- test them both, and include them in the resulting file.
-- Consequences of the fix for bug#20166:
- Remove "mysql_create_system_tables",
- new "mysql_fix_privilege_tables.sql" is included implicitly.
-
-* Wed Mar 14 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options some more and change naming of community
- cluster RPMs to explicitly say 'cluster'.
-
-* Mon Mar 12 2007 Daniel Fischer <df@mysql.com>
-
-- Adjust compile options and other settings for 5.0 community builds.
-
-* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
-
-- Add several man pages which are now created.
-
-* Mon Jan 29 2007 Mads Martin Joergensen <mmj@mysql.com>
-
-- Make sure SELinux works correctly. Files from Colin Charles.
-
-* Fri Jan 05 2007 Kent Boortz <kent@mysql.com>
-
-- Add CFLAGS to gcc call with --print-libgcc-file, to make sure the
- correct "libgcc.a" path is returned for the 32/64 bit architecture.
-
-* Tue Dec 19 2006 Joerg Bruehe <joerg@mysql.com>
-
-- The man page for "mysqld" is now in section 8.
-
-* Thu Dec 14 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Include the new man pages for "my_print_defaults" and "mysql_tzinfo_to_sql"
- in the server RPM.
-- The "mysqlmanager" man page was relocated to section 8, reflect that.
-
-* Fri Nov 17 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Really fix obsoletes/provides for community -> this
-- Make it possible to not run test by setting
- MYSQL_RPMBUILD_TEST to "no"
-
-* Wed Nov 15 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Switch from "make test*" to explicit calls of the test suite,
- so that "report features" can be used.
-
-* Wed Nov 15 2006 Kent Boortz <kent@mysql.com>
-
-- Added "--with cluster" and "--define cluster{_gpl}"
-
-* Tue Oct 24 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Shared need to Provide/Obsolete mysql-shared
-
-* Mon Oct 23 2006 Mads Martin Joergensen <mmj@mysql.com>
-
-- Run sbin/restorecon after db init (Bug#12676)
-
-* Thu Jul 06 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Correct a typing error in my previous change.
-
-* Tue Jul 04 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Use the Perl script to run the tests, because it will automatically check
- whether the server is configured with SSL.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Revert all previous attempts to call "mysql_upgrade" during RPM upgrade,
- there are some more aspects which need to be solved before this is possible.
- For now, just ensure the binary "mysql_upgrade" is delivered and installed.
-
-* Wed Jun 28 2006 Joerg Bruehe <joerg@mysql.com>
-
-- Move "mysqldumpslow" from the client RPM to the server RPM (bug#20216).
-
-* Wed Jun 21 2006 Joerg Bruehe <joerg@mysql.com>
-
-- To run "mysql_upgrade", we need a running server;
- start it in isolation and skip password checks.
-
-* Sat May 23 2006 Kent Boortz <kent@mysql.com>
-
-- Always compile for PIC, position independent code.
-
-* Fri Apr 28 2006 Kent Boortz <kent@mysql.com>
-
-- Install and run "mysql_upgrade"
-
-* Sat Apr 01 2006 Kent Boortz <kent@mysql.com>
-
-- Allow to override $LDFLAGS
-
-* Fri Jan 06 2006 Lenz Grimmer <lenz@mysql.com>
-
-- added a MySQL-test subpackage (BUG#16070)
-
-* Tue Dec 27 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Some minor alignment with the 4.1 version
-
-* Wed Dec 14 2005 Rodrigo Novo <rodrigo@mysql.com>
-
-- Cosmetic changes: source code location & rpm packager
-- Protect "nm -D" against libtool weirdness
-- Add libz.a & libz.la to the list of files for subpackage -devel
-- moved --with-zlib-dir=bundled out of BuildMySQL, as it doesn't makes
- sense for the shared package
-
-* Tue Nov 22 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Extend the file existence check for "init.d/mysql" on un-install
- to also guard the call to "insserv"/"chkconfig".
-
-* Wed Nov 16 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_client_test to the "client" subpackage (BUG#14546)
-
-* Tue Nov 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- changed default definitions to build a standard GPL release when not
- defining anything else
-- install the shared libs more elegantly by using "make install"
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Made yaSSL support an option (off by default)
-
-* Wed Oct 19 2005 Kent Boortz <kent@mysql.com>
-
-- Enabled yaSSL support
-
-* Thu Oct 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- added a usermod call to assign a potential existing mysql user to the
- correct user group (BUG#12823)
-- added a separate macro "mysqld_group" to be able to define the
- user group of the mysql user seperately, if desired.
-
-* Fri Oct 1 2005 Kent Boortz <kent@mysql.com>
-
-- Copy the config.log file to location outside
- the build tree
-
-* Fri Sep 30 2005 Lenz Grimmer <lenz@mysql.com>
-
-- don't use install-strip to install the binaries (strip segfaults on
- icc-compiled binaries on IA64)
-
-* Thu Sep 22 2005 Lenz Grimmer <lenz@mysql.com>
-
-- allow overriding the CFLAGS (needed for Intel icc compiles)
-- replace the CPPFLAGS=-DBIG_TABLES with "--with-big-tables" configure option
-
-* Fri Aug 19 2005 Joerg Bruehe <joerg@mysql.com>
-
-- Protect against failing tests.
-
-* Thu Aug 04 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the creation of the mysql user group account in the postinstall
- section (BUG 12348)
-
-* Fri Jul 29 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed external RPM Requirements to better suit the target distribution
- (BUG 12233)
-
-* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
-
-- create a "mysql" user group and assign the mysql user account to that group
- in the server postinstall section. (BUG 10984)
-
-* Wed Jun 01 2005 Lenz Grimmer <lenz@mysql.com>
-
-- use "mysqldatadir" variable instead of hard-coding the path multiple times
-- use the "mysqld_user" variable on all occasions a user name is referenced
-- removed (incomplete) Brazilian translations
-- removed redundant release tags from the subpackage descriptions
-
-* Fri May 27 2005 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file list (removed libnisam.a and libmerge.a from the devel subpackage)
-- force running the test suite
-
-* Wed Apr 20 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Enabled the "blackhole" storage engine for the Max RPM
-
-* Wed Apr 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- removed the MySQL manual files (html/ps/texi) - they have been removed
- from the MySQL sources and are now available seperately.
-
-* Mon Apr 4 2005 Petr Chardin <petr@mysql.com>
-
-- old mysqlmanager, mysqlmanagerc and mysqlmanager-pwger renamed into
- mysqltestmanager, mysqltestmanager and mysqltestmanager-pwgen respectively
-
-* Fri Mar 18 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Disabled RAID in the Max binaries once and for all (it has finally been
- removed from the source tree)
-
-* Sun Feb 20 2005 Petr Chardin <petr@mysql.com>
-
-- Install MySQL Instance Manager together with mysqld, touch mysqlmanager
- password file
-
-* Mon Feb 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed the compilation comments and moved them into the separate build sections
- for Max and Standard
-
-* Mon Feb 7 2005 Tomas Ulin <tomas@mysql.com>
-
-- enabled the "Ndbcluster" storage engine for the max binary
-- added extra make install in ndb subdir after Max build to get ndb binaries
-- added packages for ndbcluster storage engine
-
-* Fri Jan 14 2005 Lenz Grimmer <lenz@mysql.com>
-
-- replaced obsoleted "BuildPrereq" with "BuildRequires" instead
-
-* Thu Jan 13 2005 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Federated" storage engine for the max binary
-
-* Tue Jan 04 2005 Petr Chardin <petr@mysql.com>
-
-- ISAM and merge storage engines were purged. As well as appropriate
- tools and manpages (isamchk and isamlog)
-
-* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
-
-- enabled the "Archive" storage engine for the max binary
-- enabled the "CSV" storage engine for the max binary
-- enabled the "Example" storage engine for the max binary
-
-* Thu Aug 26 2004 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL-server instead of MySQL (BUG 3860)
-
-* Fri Aug 20 2004 Lenz Grimmer <lenz@mysql.com>
-
-- do not link statically on IA64/AMD64 as these systems do not have
- a patched glibc installed
-
-* Tue Aug 10 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added libmygcc.a to the devel subpackage (required to link applications
- against the the embedded server libmysqld.a) (BUG 4921)
-
-* Mon Aug 09 2004 Lenz Grimmer <lenz@mysql.com>
-
-- Added EXCEPTIONS-CLIENT to the "devel" package
-
-* Thu Jul 29 2004 Lenz Grimmer <lenz@mysql.com>
-
-- disabled OpenSSL in the Max binaries again (the RPM packages were the
- only exception to this anyway) (BUG 1043)
-
-* Wed Jun 30 2004 Lenz Grimmer <lenz@mysql.com>
-
-- fixed server postinstall (mysql_install_db was called with the wrong
- parameter)
-
-* Thu Jun 24 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added mysql_tzinfo_to_sql to the server subpackage
-- run "make clean" instead of "make distclean"
-
-* Mon Apr 05 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added ncurses-devel to the build prerequisites (BUG 3377)
-
-* Thu Feb 12 2004 Lenz Grimmer <lenz@mysql.com>
-
-- when using gcc, _always_ use CXX=gcc
-- replaced Copyright with License field (Copyright is obsolete)
-
-* Tue Feb 03 2004 Lenz Grimmer <lenz@mysql.com>
-
-- added myisam_ftdump to the Server package
-
-* Tue Jan 13 2004 Lenz Grimmer <lenz@mysql.com>
-
-- link the mysql client against libreadline instead of libedit (BUG 2289)
-
-* Mon Dec 22 2003 Lenz Grimmer <lenz@mysql.com>
-
-- marked /etc/logrotate.d/mysql as a config file (BUG 2156)
-
-* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
-
-- fixed file permissions (BUG 1672)
-
-* Thu Dec 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- made testing for gcc3 a bit more robust
-
-* Fri Dec 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_create_system_tables to the server subpackage
-
-* Fri Nov 21 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed dependency on MySQL-client from the MySQL-devel subpackage
- as it is not really required. (BUG 1610)
-
-* Fri Aug 29 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 1162 (removed macro names from the changelog)
-- Really fixed BUG 998 (disable the checking for installed but
- unpackaged files)
-
-* Tue Aug 05 2003 Lenz Grimmer <lenz@mysql.com>
-
-- Fixed BUG 959 (libmysqld not being compiled properly)
-- Fixed BUG 998 (RPM build errors): added missing files to the
- distribution (mysql_fix_extensions, mysql_tableinfo, mysqldumpslow,
- mysql_fix_privilege_tables.1), removed "-n" from install section.
-
-* Wed Jul 09 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed the GIF Icon (file was not included in the sources anyway)
-- removed unused variable shared_lib_version
-- do not run automake before building the standard binary
- (should not be necessary)
-- add server suffix '-standard' to standard binary (to be in line
- with the binary tarball distributions)
-- Use more RPM macros (_exec_prefix, _sbindir, _libdir, _sysconfdir,
- _datadir, _includedir) throughout the spec file.
-- allow overriding CC and CXX (required when building with other compilers)
-
-* Fri May 16 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-enabled RAID again
-
-* Wed Apr 30 2003 Lenz Grimmer <lenz@mysql.com>
-
-- disabled MyISAM RAID (--with-raid) - it throws an assertion which
- needs to be investigated first.
-
-* Mon Mar 10 2003 Lenz Grimmer <lenz@mysql.com>
-
-- added missing file mysql_secure_installation to server subpackage
- (BUG 141)
-
-* Tue Feb 11 2003 Lenz Grimmer <lenz@mysql.com>
-
-- re-added missing pre- and post(un)install scripts to server subpackage
-- added config file /etc/my.cnf to the file list (just for completeness)
-- make sure to create the datadir with 755 permissions
-
-* Mon Jan 27 2003 Lenz Grimmer <lenz@mysql.com>
-
-- removed unused CC and CXX variables
-- CFLAGS and CXXFLAGS should honor RPM_OPT_FLAGS
-
-* Fri Jan 24 2003 Lenz Grimmer <lenz@mysql.com>
-
-- renamed package "MySQL" to "MySQL-server"
-- fixed Copyright tag
-- added mysql_waitpid to client subpackage (required for mysql-test-run)
-
-* Wed Nov 27 2002 Lenz Grimmer <lenz@mysql.com>
-
-- moved init script from /etc/rc.d/init.d to /etc/init.d (the majority of
- Linux distributions now support this scheme as proposed by the LSB either
- directly or via a compatibility symlink)
-- Use new "restart" init script action instead of starting and stopping
- separately
-- Be more flexible in activating the automatic bootup - use insserv (on
- older SuSE versions) or chkconfig (Red Hat, newer SuSE versions and
- others) to create the respective symlinks
-
-* Wed Sep 25 2002 Lenz Grimmer <lenz@mysql.com>
-
-- MySQL-Max now requires MySQL >= 4.0 to avoid version mismatches
- (mixing 3.23 and 4.0 packages)
-
-* Fri Aug 09 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Turn off OpenSSL in MySQL-Max for now until it works properly again
-- enable RAID for the Max binary instead
-- added compatibility link: safe_mysqld -> mysqld_safe to ease the
- transition from 3.23
-
-* Thu Jul 18 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Reworked the build steps a little bit: the Max binary is supposed
- to include OpenSSL, which cannot be linked statically, thus trying
- to statically link against a special glibc is futile anyway
-- because of this, it is not required to make yet another build run
- just to compile the shared libs (saves a lot of time)
-- updated package description of the Max subpackage
-- clean up the BuildRoot directory afterwards
-
-* Mon Jul 15 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Updated Packager information
-- Fixed the build options: the regular package is supposed to
- include InnoDB and linked statically, while the Max package
- should include BDB and SSL support
-
-* Fri May 03 2002 Lenz Grimmer <lenz@mysql.com>
-
-- Use more RPM macros (e.g. infodir, mandir) to make the spec
- file more portable
-- reorganized the installation of documentation files: let RPM
- take care of this
-- reorganized the file list: actually install man pages along
- with the binaries of the respective subpackage
-- do not include libmysqld.a in the devel subpackage as well, if we
- have a special "embedded" subpackage
-- reworked the package descriptions
-
-* Mon Oct 8 2001 Monty
-
-- Added embedded server as a separate RPM
-
-* Fri Apr 13 2001 Monty
-
-- Added mysqld-max to the distribution
-
-* Tue Jan 2 2001 Monty
-
-- Added mysql-test to the bench package
-
-* Fri Aug 18 2000 Tim Smith <tim@mysql.com>
-
-- Added separate libmysql_r directory; now both a threaded
- and non-threaded library is shipped.
-
-* Wed Sep 28 1999 David Axmark <davida@mysql.com>
-
-- Added the support-files/my-example.cnf to the docs directory.
-
-- Removed devel dependency on base since it is about client
- development.
-
-* Wed Sep 8 1999 David Axmark <davida@mysql.com>
-
-- Cleaned up some for 3.23.
-
-* Thu Jul 1 1999 David Axmark <davida@mysql.com>
-
-- Added support for shared libraries in a separate sub
- package. Original fix by David Fox (dsfox@cogsci.ucsd.edu)
-
-- The --enable-assembler switch is now automatically disables on
- platforms there assembler code is unavailable. This should allow
- building this RPM on non i386 systems.
-
-* Mon Feb 22 1999 David Axmark <david@detron.se>
-
-- Removed unportable cc switches from the spec file. The defaults can
- now be overridden with environment variables. This feature is used
- to compile the official RPM with optimal (but compiler version
- specific) switches.
-
-- Removed the repetitive description parts for the sub rpms. Maybe add
- again if RPM gets a multiline macro capability.
-
-- Added support for a pt_BR translation. Translation contributed by
- Jorge Godoy <jorge@bestway.com.br>.
-
-* Wed Nov 4 1998 David Axmark <david@detron.se>
-
-- A lot of changes in all the rpm and install scripts. This may even
- be a working RPM :-)
-
-* Sun Aug 16 1998 David Axmark <david@detron.se>
-
-- A developers changelog for MySQL is available in the source RPM. And
- there is a history of major user visible changed in the Reference
- Manual. Only RPM specific changes will be documented here.
diff --git a/percona/5.0.84-b18-20090811/mysql-test.patch b/percona/5.0.84-b18-20090811/mysql-test.patch
deleted file mode 100644
index 7fce8e0..0000000
--- a/percona/5.0.84-b18-20090811/mysql-test.patch
+++ /dev/null
@@ -1,108 +0,0 @@
---- a/mysql-test/r/information_schema.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/information_schema.result 2009-05-07 19:32:59.000000000 +0000
-@@ -60,6 +60,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- columns_priv
- db
- func
-@@ -743,7 +744,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--109
-+110
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -819,7 +820,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 24
-+information_schema 25
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1228,6 +1229,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1267,6 +1269,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1342,6 +1345,7 @@
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
---- a/mysql-test/r/information_schema_db.result 2009-05-07 19:31:27.000000000 +0000
-+++ b/mysql-test/r/information_schema_db.result 2009-05-07 19:35:01.000000000 +0000
-@@ -29,6 +29,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
---- a/mysql-test/r/mysqlshow.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/mysqlshow.result 2009-05-07 19:36:32.000000000 +0000
-@@ -103,6 +103,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -132,6 +133,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
---- a/mysql-test/r/profiling.result 2009-05-28 19:39:42.000000000 +0000
-+++ b/mysql-test/r/profiling.result 2009-05-28 19:40:14.000000000 +0000
-@@ -6,6 +6,8 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 15
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 0
-@@ -16,12 +18,16 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 100
-+profiling_server OFF
-+profiling_use_getrusage OFF
- set session profiling = ON;
- set session profiling_history_size=30;
- show session variables like 'profil%';
- Variable_name Value
- profiling ON
- profiling_history_size 30
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 1
diff --git a/percona/5.0.84-b18-20090811/mysqld_safe_syslog.patch b/percona/5.0.84-b18-20090811/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.84-b18-20090811/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.84-b18-20090811/profiling_slow.patch b/percona/5.0.84-b18-20090811/profiling_slow.patch
deleted file mode 100644
index 78d35a0..0000000
--- a/percona/5.0.84-b18-20090811/profiling_slow.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-diff -r 4636d2e0b0d0 patch_info/profiling_slow.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/profiling_slow.info Fri Jul 03 15:40:29 2009 -0700
-@@ -0,0 +1,9 @@
-+File=profiling_slow.info
-+Name=profiling from SHOW PROFILE to slow.log
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2009-05-18
-+Initial implementation
-diff -r 4636d2e0b0d0 sql/log.cc
---- a/sql/log.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/log.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -2402,6 +2402,11 @@
- tmp_errno=errno;
- }
- }
-+
-+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
-+ thd->profiling.print_current(&log_file);
-+#endif
-+
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
- if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
-diff -r 4636d2e0b0d0 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -5052,6 +5052,8 @@
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_PROFILING_SERVER,
-+ OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
-@@ -5675,6 +5677,16 @@
- (gptr*) &global_system_variables.profiling_history_size,
- (gptr*) &max_system_variables.profiling_history_size,
- 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
-+ {"profiling_server", OPT_PROFILING_SERVER,
-+ "Enable profiling of all threads",
-+ (gptr*) &global_system_variables.profiling_server,
-+ (gptr*) &max_system_variables.profiling_server, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
-+ {"profiling_use_getrusage", OPT_PROFILING_USE_GETRUSAGE,
-+ "Enable getrusage function call for profiling",
-+ (gptr*) &global_system_variables.profiling_use_getrusage,
-+ (gptr*) &max_system_variables.profiling_use_getrusage, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
- #endif
- {"relay-log", OPT_RELAY_LOG,
- "The location and name to use for relay logs.",
-diff -r 4636d2e0b0d0 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -592,6 +592,10 @@
- ulonglong(OPTION_PROFILING));
- static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
- &SV::profiling_history_size);
-+static sys_var_thd_bool sys_profiling_server("profiling_server",
-+ &SV::profiling_server);
-+static sys_var_thd_bool sys_profiling_use_getrusage("profiling_use_getrusage",
-+ &SV::profiling_use_getrusage);
- #endif
-
- /* Local state variables */
-@@ -764,6 +768,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- &sys_profiling,
- &sys_profiling_history_size,
-+ &sys_profiling_server,
-+ &sys_profiling_use_getrusage,
- #endif
- &sys_pseudo_thread_id,
- &sys_query_alloc_block_size,
-@@ -1094,6 +1100,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- {sys_profiling.name, (char*) &sys_profiling, SHOW_SYS},
- {sys_profiling_history_size.name, (char*) &sys_profiling_history_size, SHOW_SYS},
-+ {sys_profiling_server.name, (char*) &sys_profiling_server, SHOW_SYS},
-+ {sys_profiling_use_getrusage.name, (char*) &sys_profiling_use_getrusage, SHOW_SYS},
- #endif
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
-diff -r 4636d2e0b0d0 sql/sql_class.h
---- a/sql/sql_class.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_class.h Fri Jul 03 15:40:29 2009 -0700
-@@ -550,6 +550,8 @@
- ulong optimizer_search_depth;
- ulong preload_buff_size;
- ulong profiling_history_size;
-+ my_bool profiling_server;
-+ my_bool profiling_use_getrusage;
- ulong query_cache_type;
- ulong log_slow_rate_limit;
- ulong read_buff_size;
-diff -r 4636d2e0b0d0 sql/sql_profile.cc
---- a/sql/sql_profile.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -221,9 +221,22 @@
- */
- void PROF_MEASUREMENT::collect()
- {
-+ struct timespec tp;
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
- #ifdef HAVE_GETRUSAGE
-- getrusage(RUSAGE_SELF, &rusage);
-+ if ((profile->get_profiling())->enabled_getrusage())
-+ getrusage(RUSAGE_SELF, &rusage);
-+#endif
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ {
-+ cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
-+ }
-+ else
-+ {
-+ cpu_time_usecs= 0;
-+ }
- #endif
- }
-
-@@ -341,7 +354,7 @@
- finish_current_query();
- }
-
-- enabled= (((thd)->options & OPTION_PROFILING) != 0);
-+ enabled= (((thd)->options & OPTION_PROFILING) != 0) || ( thd->variables.profiling_server );
-
- if (! enabled) DBUG_VOID_RETURN;
-
-@@ -379,7 +392,8 @@
- status_change("ending", NULL, NULL, 0);
-
- if ((enabled) && /* ON at start? */
-- ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
-+ (((thd->options & OPTION_PROFILING) != 0) ||
-+ (thd->variables.profiling_server)) && /* and ON at end? */
- (current->query_source != NULL) &&
- (! current->entries.is_empty()))
- {
-@@ -480,6 +494,88 @@
- DBUG_VOID_RETURN;
- }
-
-+bool PROFILING::enabled_getrusage()
-+{
-+ return thd->variables.profiling_use_getrusage;
-+}
-+
-+/**
-+ Print output for current query to file
-+*/
-+
-+int PROFILING::print_current(IO_CACHE *log_file)
-+{
-+ DBUG_ENTER("PROFILING::print_current");
-+ ulonglong row_number= 0;
-+ char query_time_buff[22+7];
-+ char query_cpu_time_buff[22+7];
-+
-+ QUERY_PROFILE *query;
-+ /* Get current query */
-+ if (current == NULL)
-+ {
-+ DBUG_RETURN(0);
-+ }
-+
-+ query= current;
-+
-+ my_b_printf(log_file, "# PROFILE_VALUES ");
-+
-+ void *entry_iterator;
-+ PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
-+ /* ...and for each query, go through all its state-change steps. */
-+ for (entry_iterator= query->entries.new_iterator();
-+ entry_iterator != NULL;
-+ entry_iterator= query->entries.iterator_next(entry_iterator),
-+ previous=entry, row_number++)
-+ {
-+ entry= query->entries.iterator_value(entry_iterator);
-+
-+ /* Skip the first. We count spans of fence, not fence-posts. */
-+ if (previous == NULL) {first= entry; continue;}
-+
-+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
-+ {
-+ /*
-+ We got here via a SHOW command. That means that we stored
-+ information about the query we wish to show and that isn't
-+ in a WHERE clause at a higher level to filter out rows we
-+ wish to exclude.
-+
-+ Because that functionality isn't available in the server yet,
-+ we must filter here, at the wrong level. Once one can con-
-+ struct where and having conditions at the SQL layer, then this
-+ condition should be ripped out.
-+ */
-+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
-+ {
-+ if (query != last)
-+ continue;
-+ }
-+ else
-+ {
-+ if (thd->lex->profile_query_id != query->profiling_query_id)
-+ continue;
-+ }
-+ }
-+
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
-+
-+ }
-+
-+ my_b_printf(log_file, "\n");
-+ if ((entry != NULL) && (first != NULL))
-+ {
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /**
- Fill the information schema table, "query_profile", as defined in show.cc .
- There are two ways to get to this function: Selecting from the information
-diff -r 4636d2e0b0d0 sql/sql_profile.h
---- a/sql/sql_profile.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.h Fri Jul 03 15:40:29 2009 -0700
-@@ -193,6 +193,7 @@
- unsigned int line;
-
- double time_usecs;
-+ double cpu_time_usecs;
- char *allocated_status_memory;
-
- void set_label(const char *status_arg, const char *function_arg,
-@@ -243,6 +244,11 @@
-
- /* Show this profile. This is called by PROFILING. */
- bool show(uint options);
-+
-+public:
-+
-+ inline PROFILING * get_profiling() { return profiling; };
-+
- };
-
-
-@@ -288,9 +294,11 @@
-
- /* SHOW PROFILES */
- bool show_profiles();
-+ bool enabled_getrusage();
-
- /* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
-+ int print_current(IO_CACHE *log_file);
- };
-
- # endif /* HAVE_PROFILING */
diff --git a/percona/5.0.84-b18-20090811/series b/percona/5.0.84-b18-20090811/series
deleted file mode 100644
index d10f1af..0000000
--- a/percona/5.0.84-b18-20090811/series
+++ /dev/null
@@ -1,21 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-profiling_slow.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_show_hashed_memory.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-innodb_use_sys_malloc.patch
-innodb_recovery_patches.patch
-innodb_split_buf_pool_mutex.patch
-innodb_rw_lock.patch
-mysql-test.patch
diff --git a/percona/5.0.84-b18-20090811/show_patches.patch b/percona/5.0.84-b18-20090811/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.84-b18-20090811/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.84-b18-20090811/userstatv2.patch b/percona/5.0.84-b18-20090811/userstatv2.patch
deleted file mode 100644
index b81d6c5..0000000
--- a/percona/5.0.84-b18-20090811/userstatv2.patch
+++ /dev/null
@@ -1,4394 +0,0 @@
-diff -r 592f6c3641ba BUILD/Makefile.in
---- a/BUILD/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/BUILD/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Docs/Makefile.in
---- a/Docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Makefile.in
---- a/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba SSL/Makefile.in
---- a/SSL/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/SSL/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba client/Makefile.in
---- a/client/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/client/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba configure
---- a/configure Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure Wed Jul 29 13:34:11 2009 -0700
-@@ -35347,7 +35347,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38791,7 +38875,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 592f6c3641ba configure.in
---- a/configure.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure.in Wed Jul 29 13:34:11 2009 -0700
-@@ -2136,7 +2136,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2772,7 +2783,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 592f6c3641ba dbug/Makefile.in
---- a/dbug/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/dbug/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/Makefile.in
---- a/extra/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba heap/Makefile.in
---- a/heap/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/heap/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/Makefile.in
---- a/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 13:34:11 2009 -0700
-@@ -25,6 +25,7 @@
- #define USERNAME_LENGTH 16
- #define SERVER_VERSION_LENGTH 60
- #define SQLSTATE_LENGTH 5
-+#define LIST_PROCESS_HOST_LEN 64
-
- /*
- USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
-@@ -106,6 +107,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 592f6c3641ba libmysql/Makefile.in
---- a/libmysql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql_r/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba man/Makefile.in
---- a/man/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/man/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisam/Makefile.in
---- a/myisam/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisam/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisammrg/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 13:34:11 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
-diff -r 592f6c3641ba mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 13:34:11 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 592f6c3641ba mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 13:34:11 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 592f6c3641ba mysys/Makefile.in
---- a/mysys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/Makefile.in
---- a/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba netware/Makefile.in
---- a/netware/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/netware/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/Makefile.in
---- a/os2/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/Makefile.in
---- a/os2/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/sys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Wed Jul 29 13:34:11 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 592f6c3641ba pstack/Makefile.in
---- a/pstack/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/aout/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba regex/Makefile.in
---- a/regex/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/regex/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba scripts/Makefile.in
---- a/scripts/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/scripts/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/Makefile.in
---- a/server-tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/Makefile.in
---- a/sql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -3341,6 +3341,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3613,6 +3615,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3661,6 +3665,8 @@
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -4092,6 +4098,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 592f6c3641ba sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_myisam.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1521,13 +1523,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1538,6 +1544,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1548,6 +1561,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1558,6 +1578,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1568,6 +1595,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1578,6 +1612,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1588,6 +1629,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1598,6 +1646,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1614,6 +1669,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1631,6 +1693,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1645,6 +1708,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 592f6c3641ba sql/handler.cc
---- a/sql/handler.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 592f6c3641ba sql/handler.h
---- a/sql/handler.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.h Wed Jul 29 13:34:11 2009 -0700
-@@ -32,6 +32,10 @@
- #define USING_TRANSACTIONS
- #endif
-
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
-+#endif
-+
- // the following is for checking tables
-
- #define HA_ADMIN_ALREADY_DONE 1
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 592f6c3641ba sql/lex.h
---- a/sql/lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 592f6c3641ba sql/log.cc
---- a/sql/log.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/log.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 592f6c3641ba sql/mysql_priv.h
---- a/sql/mysql_priv.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysql_priv.h Wed Jul 29 13:34:11 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 592f6c3641ba sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 592f6c3641ba sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 592f6c3641ba sql/share/Makefile.in
---- a/sql/share/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/share/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/sql_base.cc
---- a/sql/sql_base.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_base.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 592f6c3641ba sql/sql_class.cc
---- a/sql/sql_class.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 592f6c3641ba sql/sql_class.h
---- a/sql/sql_class.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.h Wed Jul 29 13:34:11 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,8 +1943,14 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-
-+ char *get_client_host_port(THD *client);
-+
- public:
- /**
- Add an internal error handler to the thread execution context.
-@@ -1935,6 +1993,10 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 592f6c3641ba sql/sql_delete.cc
---- a/sql/sql_delete.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_delete.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -887,6 +888,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 592f6c3641ba sql/sql_insert.cc
---- a/sql/sql_insert.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_insert.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -990,6 +990,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3094,6 +3095,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 592f6c3641ba sql/sql_lex.h
---- a/sql/sql_lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 592f6c3641ba sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -146,6 +152,17 @@
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
- #endif
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,"%s",ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- (net->vio && net->error && net->report_error))
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4539,6 +4994,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4847,6 +5311,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5691,6 +6156,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5726,6 +6192,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5758,11 +6225,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5796,6 +6267,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5828,6 +6300,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5859,6 +6332,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5912,8 +6391,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5930,9 +6409,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6442,6 +6924,30 @@
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
- LEX *lex= thd->lex;
-@@ -6520,6 +7026,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7531,8 +8074,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 592f6c3641ba sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_prepare.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -81,6 +81,9 @@
- #include <mysql_com.h>
- #endif
-
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- /* A result class used to send cursor rows using the binary protocol. */
-
- class Select_fetch_protocol_prep: public select_send
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2503,6 +2717,43 @@
-
- send_ok(thd);
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-diff -r 592f6c3641ba sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,10 +4912,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 592f6c3641ba sql/sql_update.cc
---- a/sql/sql_update.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_update.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 592f6c3641ba sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 13:34:11 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 592f6c3641ba sql/structs.h
---- a/sql/structs.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/structs.h Wed Jul 29 13:34:11 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 592f6c3641ba sql/table.h
---- a/sql/table.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/table.h Wed Jul 29 13:34:11 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 592f6c3641ba strings/Makefile.in
---- a/strings/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/strings/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/Makefile.in
---- a/support-files/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tests/Makefile.in
---- a/tests/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tests/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tools/Makefile.in
---- a/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba vio/Makefile.in
---- a/vio/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/vio/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba win/Makefile.in
---- a/win/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/win/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba zlib/Makefile.in
---- a/zlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/zlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.87-b20-20091116/README-GENTOO b/percona/5.0.87-b20-20091116/README-GENTOO
deleted file mode 100644
index a4e2724..0000000
--- a/percona/5.0.87-b20-20091116/README-GENTOO
+++ /dev/null
@@ -1,8 +0,0 @@
-The following patches, while distributed by Percona, are NOT applied in their
-specfile. As such, we do not apply them in Gentoo either:
-=========
-innodb_extra_status.patch
-innodb_io_tune.patch
-innodb_rw_lock_old.patch
-innodb_show_hashed_memory_standalone.patch
-mirror_binlog.patch
diff --git a/percona/5.0.87-b20-20091116/innodb_check_fragmentation.patch b/percona/5.0.87-b20-20091116/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.87-b20-20091116/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.87-b20-20091116/innodb_dict_size_limit.patch b/percona/5.0.87-b20-20091116/innodb_dict_size_limit.patch
deleted file mode 100644
index ced1aec..0000000
--- a/percona/5.0.87-b20-20091116/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,633 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-08-27 18:43:11.000000000 +0900
-@@ -1077,6 +1077,124 @@
- }
-
- /************************************************************************
-+Drops a page hash index based on index */
-+
-+void
-+btr_search_drop_page_hash_index_on_index(
-+/*=====================================*/
-+ dict_index_t* index) /* in: record descriptor */
-+{
-+ page_t* page;
-+ hash_table_t* table;
-+ buf_block_t* block;
-+ ulint n_fields;
-+ ulint n_bytes;
-+ rec_t* rec;
-+ ulint fold;
-+ ulint prev_fold;
-+ dulint tree_id;
-+ ulint n_cached;
-+ ulint n_recs;
-+ ulint* folds;
-+ ulint i;
-+ mem_heap_t* heap = NULL;
-+ ulint* offsets;
-+
-+ rw_lock_x_lock(&btr_search_latch);
-+ mutex_enter(&buf_pool->mutex);
-+
-+ table = btr_search_sys->hash_index;
-+
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+
-+ while (block != NULL) {
-+ if (block->index == index && block->is_hashed) {
-+ page = block->frame;
-+
-+ /* from btr_search_drop_page_hash_index() */
-+ n_fields = block->curr_n_fields;
-+ n_bytes = block->curr_n_bytes;
-+
-+ ut_a(n_fields + n_bytes > 0);
-+
-+ n_recs = page_get_n_recs(page);
-+
-+ /* Calculate and cache fold values into an array for fast deletion
-+ from the hash index */
-+
-+ folds = mem_alloc(n_recs * sizeof(ulint));
-+
-+ n_cached = 0;
-+
-+ rec = page_get_infimum_rec(page);
-+ rec = page_rec_get_next(rec);
-+
-+ tree_id = btr_page_get_index_id(page);
-+
-+ ut_a(0 == ut_dulint_cmp(tree_id, index->id));
-+
-+ prev_fold = 0;
-+
-+ offsets = NULL;
-+
-+ while (!page_rec_is_supremum(rec)) {
-+ /* FIXME: in a mixed tree, not all records may have enough
-+ ordering fields: */
-+ offsets = rec_get_offsets(rec, index, offsets,
-+ n_fields + (n_bytes > 0), &heap);
-+ ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
-+ fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
-+
-+ if (fold == prev_fold && prev_fold != 0) {
-+
-+ goto next_rec;
-+ }
-+
-+ /* Remove all hash nodes pointing to this page from the
-+ hash chain */
-+
-+ folds[n_cached] = fold;
-+ n_cached++;
-+next_rec:
-+ rec = page_rec_get_next(rec);
-+ prev_fold = fold;
-+ }
-+
-+ for (i = 0; i < n_cached; i++) {
-+
-+ ha_remove_all_nodes_to_page(table, folds[i], page);
-+ }
-+
-+ ut_a(index->search_info->ref_count > 0);
-+ index->search_info->ref_count--;
-+
-+ block->is_hashed = FALSE;
-+ block->index = NULL;
-+
-+ if (UNIV_UNLIKELY(block->n_pointers)) {
-+ /* Corruption */
-+ ut_print_timestamp(stderr);
-+ fprintf(stderr,
-+" InnoDB: Corruption of adaptive hash index. After dropping\n"
-+"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n",
-+ index->name, (ulong) block->n_pointers);
-+ }
-+
-+ mem_free(folds);
-+ }
-+
-+ block = UT_LIST_GET_PREV(LRU, block);
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+ rw_lock_x_unlock(&btr_search_latch);
-+
-+ if (UNIV_LIKELY_NULL(heap)) {
-+ mem_heap_free(heap);
-+ }
-+}
-+
-+/************************************************************************
- Drops a page hash index when a page is freed from a fseg to the file system.
- Drops possible hash index if the page happens to be in the buffer pool. */
-
-diff -ruN a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c
---- a/innobase/dict/dict0boot.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0boot.c 2009-08-27 18:42:59.000000000 +0900
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -ruN a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
---- a/innobase/dict/dict0crea.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0crea.c 2009-08-27 18:42:59.000000000 +0900
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1267,6 +1270,11 @@
-
- trx->op_info = "";
-
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-diff -ruN a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
---- a/innobase/dict/dict0dict.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0dict.c 2009-08-27 18:43:11.000000000 +0900
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -787,6 +791,8 @@
- table->n_mysql_handles_opened++;
- }
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-
-- ut_error;
-+ //ut_error;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1342,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-@@ -1565,6 +1616,10 @@
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-+ /* remove all entry of the index from adaptive hash index,
-+ because removing from adaptive hash index needs dict_index */
-+ if (srv_use_adaptive_hash_indexes && srv_dict_size_limit)
-+ btr_search_drop_page_hash_index_on_index(index);
-
- /* We always create search info whether or not adaptive
- hash index is enabled or not. */
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:59.000000000 +0900
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -ruN a/innobase/include/btr0sea.h b/innobase/include/btr0sea.h
---- a/innobase/include/btr0sea.h 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/btr0sea.h 2009-08-27 18:43:11.000000000 +0900
-@@ -97,6 +97,13 @@
- /*============================*/
- page_t* page); /* in: index page, s- or x-latched */
- /************************************************************************
-+Drops a page hash index based on index */
-+
-+void
-+btr_search_drop_page_hash_index_on_index(
-+/*=====================================*/
-+ dict_index_t* index); /* in: record descriptor */
-+/************************************************************************
- Drops a page hash index when a page is freed from a fseg to the file system.
- Drops possible hash index if the page happens to be in the buffer pool. */
-
-diff -ruN a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h
---- a/innobase/include/dict0dict.h 2009-07-07 21:54:01.000000000 +0900
-+++ b/innobase/include/dict0dict.h 2009-08-27 18:42:59.000000000 +0900
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -ruN a/innobase/include/dict0dict.ic b/innobase/include/dict0dict.ic
---- a/innobase/include/dict0dict.ic 2009-07-07 21:54:01.000000000 +0900
-+++ b/innobase/include/dict0dict.ic 2009-08-27 18:42:59.000000000 +0900
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-08-27 18:42:59.000000000 +0900
-@@ -147,6 +147,8 @@
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-
-+extern ulint srv_dict_size_limit;
-+
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
- extern ulong srv_io_pattern_trace_running;
-@@ -552,6 +554,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-27 18:42:59.000000000 +0900
-@@ -353,6 +353,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-
-+ulint srv_dict_size_limit = 0;
-+
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
- ulint srv_io_pattern_trace_running = 0;
-@@ -1953,6 +1955,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -ruN a/mysql-test/r/innodb_dict_size_limit.result b/mysql-test/r/innodb_dict_size_limit.result
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/mysql-test/r/innodb_dict_size_limit.result 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -ruN a/mysql-test/t/innodb_dict_size_limit.test b/mysql-test/t/innodb_dict_size_limit.test
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/mysql-test/t/innodb_dict_size_limit.test 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -ruN a/patch_info/innodb_dict_size_limit.info b/patch_info/innodb_dict_size_limit.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_dict_size_limit.info 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-08-27 18:42:59.000000000 +0900
-@@ -243,6 +243,7 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/mysqld.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5464,6 +5465,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/set_var.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -540,6 +540,8 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -930,6 +932,7 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1084,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/innodb_extra_rseg.patch b/percona/5.0.87-b20-20091116/innodb_extra_rseg.patch
deleted file mode 100644
index cab3b26..0000000
--- a/percona/5.0.87-b20-20091116/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -r 85e7025cf2d1 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:47 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_extra_rsegments;
-
- extern ulint srv_dict_size_limit;
-
-diff -r 85e7025cf2d1 innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/trx0sys.h Fri Jul 03 15:41:47 2009 -0700
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -r 85e7025cf2d1 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:47 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-
- ulint srv_dict_size_limit = 0;
-
-diff -r 85e7025cf2d1 innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0start.c Fri Jul 03 15:41:47 2009 -0700
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -r 85e7025cf2d1 innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:47 2009 -0700
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -r 85e7025cf2d1 patch_info/innodb_extra_rseg.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_rseg.info Fri Jul 03 15:41:47 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -r 85e7025cf2d1 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1521,6 +1522,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -r 85e7025cf2d1 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:47 2009 -0700
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -r 85e7025cf2d1 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
-@@ -5465,6 +5466,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -r 85e7025cf2d1 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -1087,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -r 85e7025cf2d1 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4180,6 +4182,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4996,6 +5037,16 @@
- {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
- {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
- #endif
-@@ -5177,6 +5228,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.87-b20-20091116/innodb_extra_status.patch b/percona/5.0.87-b20-20091116/innodb_extra_status.patch
deleted file mode 100644
index adc1642..0000000
--- a/percona/5.0.87-b20-20091116/innodb_extra_status.patch
+++ /dev/null
@@ -1,747 +0,0 @@
-diff -r b059d02ec814 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -2353,6 +2353,7 @@
- "AWE: Database pages and free buffers mapped in frames %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
-+ if (file) {
- fprintf(file,
- "Buffer pool size %lu\n"
- "Free buffers %lu\n"
-@@ -2371,11 +2372,13 @@
- + buf_pool->init_flush[BUF_FLUSH_LIST],
- (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
-
-+ } // if (file)
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time,
- buf_pool->last_printout_time);
- buf_pool->last_printout_time = current_time;
-
-+ if (file) {
- fprintf(file,
- "Pages read %lu, created %lu, written %lu\n"
- "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
-@@ -2405,6 +2408,7 @@
- } else {
- fputs("No buffer pool page gets since the last printout\n",
- file);
-+ }
- }
-
- buf_pool->n_page_gets_old = buf_pool->n_page_gets;
-diff -r b059d02ec814 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -3519,9 +3519,15 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ inno_ibuf_size = 0;
-+ inno_ibuf_inserts = 0;
-+ inno_ibuf_merged_recs = 0;
-+ inno_ibuf_merges = 0;
-+
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
-+ if (file) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
-@@ -3542,6 +3548,12 @@
- }
- }
- #endif
-+ } // if (file)
-+ inno_ibuf_size += (ulong) data->size;
-+ inno_ibuf_inserts += (ulong) data->n_inserts;
-+ inno_ibuf_merged_recs += (ulong) data->n_merged_recs;
-+ inno_ibuf_merges += (ulong) data->n_merges;
-+
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
-diff -r b059d02ec814 innobase/include/lock0lock.h
---- a/innobase/include/lock0lock.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/lock0lock.h Mon Nov 03 05:09:34 2008 -0800
-@@ -24,6 +24,10 @@
- #endif /* UNIV_DEBUG */
- /* Buffer for storing information about the most recent deadlock error */
- extern FILE* lock_latest_err_file;
-+
-+/* number of deadlocks happened so far */
-+extern ulint innodb_deadlocks;
-+
-
- /*************************************************************************
- Gets the size of a lock struct. */
-diff -r b059d02ec814 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:09:34 2008 -0800
-@@ -261,6 +261,12 @@
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+extern ibool srv_long_lock_wait;
-+
-+/* variable to count the number long semaphore waits noticed */
-+extern ulint srv_long_lock_waits;
-+
- /* Number of IO operations read/write done for all threads */
- extern ulint os_aio_read_requests;
- extern ulint os_aio_write_requests;
-@@ -278,6 +284,26 @@
- extern ulint inno_pending_ibuf_aio_reads;
- extern ulint inno_pending_log_ios;
- extern ulint inno_pending_sync_ios;
-+
-+/* all 24 innodb status variables, exported to status */
-+extern ulint inno_transaction_count;
-+extern ulint inno_transaction_purge_count;
-+extern ulint inno_transaction_purge_lag;
-+extern ulint inno_num_active_transactions;
-+extern ulint inno_summed_transaction_age;
-+extern ulint inno_longest_transaction_age;
-+extern ulint inno_lock_wait_timeouts;
-+extern ulint inno_num_lock_waiters;
-+extern ulint inno_summed_lock_wait_time;
-+extern ulint inno_longest_lock_wait;
-+extern ulint inno_os_reads;
-+extern ulint inno_os_writes;
-+extern ulint inno_os_fsyncs;
-+extern ulint inno_ibuf_size;
-+extern ulint inno_ibuf_inserts;
-+extern ulint inno_ibuf_merged_recs;
-+extern ulint inno_ibuf_merges;
-+extern ulint inno_log_ios_done;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-@@ -552,6 +578,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_size;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-@@ -587,6 +614,43 @@
- ulint innodb_rows_inserted;
- ulint innodb_rows_updated;
- ulint innodb_rows_deleted;
-+ ibool innodb_long_lock_wait;
-+ ulint innodb_long_lock_waits;
-+
-+ ulint innodb_os_aio_read_requests;
-+ ulint innodb_os_aio_write_requests;
-+ ulint innodb_os_aio_pages_read;
-+ ulint innodb_os_aio_pages_written;
-+ ib_longlong innodb_os_aio_read_time;
-+ ib_longlong innodb_os_aio_write_time;
-+ ib_longlong innodb_os_aio_read_time_avg;
-+ ib_longlong innodb_os_aio_write_time_avg;
-+ ulint innodb_deadlocks;
-+
-+ // the following 24 variables are exported to "show status"
-+ ulint inno_transaction_count;
-+ ulint inno_transaction_purge_count;
-+ ulint inno_transaction_purge_lag;
-+ ulint inno_num_active_transactions;
-+ ulint inno_summed_transaction_age;
-+ ulint inno_longest_transaction_age;
-+ ulint inno_lock_wait_timeouts;
-+ ulint inno_num_lock_waiters;
-+ ulint inno_summed_lock_wait_time;
-+ ulint inno_longest_lock_wait;
-+ ulint inno_pending_normal_aio_reads;
-+ ulint inno_pending_normal_aio_writes;
-+ ulint inno_pending_ibuf_aio_reads;
-+ ulint inno_pending_log_ios;
-+ ulint inno_pending_sync_ios;
-+ ulint inno_os_reads;
-+ ulint inno_os_writes;
-+ ulint inno_os_fsyncs;
-+ ulint inno_ibuf_size;
-+ ulint inno_ibuf_inserts;
-+ ulint inno_ibuf_merged_recs;
-+ ulint inno_ibuf_merges;
-+ ulint inno_log_ios_done;
- };
-
- /* The server system struct */
-diff -r b059d02ec814 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Nov 03 05:09:34 2008 -0800
-@@ -360,6 +360,9 @@
- ibool lock_deadlock_found = FALSE;
- FILE* lock_latest_err_file;
-
-+/* number of deadlocks happened so far */
-+ulint innodb_deadlocks = 0;
-+
- /* Flags for recursive deadlock search */
- #define LOCK_VICTIM_IS_START 1
- #define LOCK_VICTIM_IS_OTHER 2
-@@ -3304,6 +3307,7 @@
-
- FILE* ef = lock_latest_err_file;
-
-+ innodb_deadlocks++;
- rewind(ef);
- ut_print_timestamp(ef);
-
-@@ -4238,6 +4242,7 @@
- innobase_mysql_prepare_print_arbitrary_thd();
- lock_mutex_enter_kernel();
-
-+ if (file) {
- if (lock_deadlock_found) {
- fputs(
- "------------------------\n"
-@@ -4269,6 +4274,12 @@
- fprintf(file,
- "Total number of lock structs in row lock hash table %lu\n",
- (ulong) lock_get_n_rec_locks());
-+ } // if (file)
-+ inno_transaction_purge_count =
-+ (ulong) ut_dulint_get_low(purge_sys->purge_trx_no);
-+ inno_transaction_count =
-+ (ulong) ut_dulint_get_low(trx_sys->max_trx_id);
-+ inno_transaction_purge_lag = (ulong) trx_sys->rseg_history_len;
- }
-
- /*************************************************************************
-@@ -4289,7 +4300,17 @@
- ulint i;
- mtr_t mtr;
- trx_t* trx;
--
-+ time_t current_time = time(NULL);
-+
-+ /* init all counters to be updated */
-+ inno_num_lock_waiters = 0;
-+ inno_summed_lock_wait_time = 0;
-+ inno_longest_lock_wait = 0;
-+ inno_num_active_transactions = 0;
-+ inno_summed_transaction_age = 0;
-+ inno_longest_transaction_age = 0;
-+
-+ if (file) {
- fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
-
- /* First print info on non-active transactions */
-@@ -4304,6 +4325,7 @@
-
- trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
- }
-+ } // if (file)
-
- loop:
- trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
-@@ -4330,6 +4352,7 @@
- }
-
- if (nth_lock == 0) {
-+ if (file) {
- fputs("---", file);
- trx_print(file, trx, 600);
-
-@@ -4341,11 +4364,27 @@
- (ulong) ut_dulint_get_high(trx->read_view->up_limit_id),
- (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
- }
-+ } // if (file)
-+
-+ if (trx->conc_state == TRX_ACTIVE) {
-+ ulong trx_age = (ulong)difftime(time(NULL), trx->start_time);
-+ inno_num_active_transactions++;
-+ inno_summed_transaction_age += trx_age;
-+ if (inno_longest_transaction_age > trx_age)
-+ inno_longest_transaction_age = trx_age;
-+ }
-
- if (trx->que_state == TRX_QUE_LOCK_WAIT) {
-+ ulong wait_time = (ulong)difftime(current_time,
-+ trx->wait_started);
-+ inno_num_lock_waiters++;
-+ inno_summed_lock_wait_time += wait_time;
-+ if (inno_longest_lock_wait < wait_time)
-+ inno_longest_lock_wait = wait_time;
-+ if (file) {
- fprintf(file,
- "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
-- (ulong)difftime(time(NULL), trx->wait_started));
-+ wait_time);
-
- if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(file, trx->wait_lock);
-@@ -4354,10 +4393,16 @@
- }
-
- fputs("------------------\n", file);
-- }
-- }
--
-- if (!srv_print_innodb_lock_monitor) {
-+ } // if (file)
-+ }
-+ }
-+
-+ /* don't print locks per transaction if either
-+ 1) srv_print_innodb_lock_monitor is NOT set,
-+ ie no magic table innodb_lock_monitor is created, or
-+ 2) file == NULL, ie, at counter updating stage from "show status"
-+ */
-+ if (!srv_print_innodb_lock_monitor || !file) {
- nth_trx++;
- goto loop;
- }
-diff -r b059d02ec814 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:09:34 2008 -0800
-@@ -267,6 +267,35 @@
- ulint inno_pending_log_ios = 0;
- ulint inno_pending_sync_ios = 0;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+ibool srv_long_lock_wait = FALSE;
-+
-+/* variable to count the number long semaphore waits noticed */
-+ulint srv_long_lock_waits = 0;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+extern long innobase_min_status_update_time_interval;
-+
-+/* all 24 innodb status variables, exported to status */
-+ulint inno_transaction_count = 0;
-+ulint inno_transaction_purge_count = 0;
-+ulint inno_transaction_purge_lag = 0;
-+ulint inno_num_active_transactions = 0;
-+ulint inno_summed_transaction_age = 0;
-+ulint inno_longest_transaction_age = 0;
-+ulint inno_lock_wait_timeouts = 0; /* Counts number of lock wait timeouts. */
-+ulint inno_num_lock_waiters = 0;
-+ulint inno_summed_lock_wait_time = 0;
-+ulint inno_longest_lock_wait = 0;
-+ulint inno_os_reads = 0;
-+ulint inno_os_writes = 0;
-+ulint inno_os_fsyncs = 0;
-+ulint inno_ibuf_size = 0;
-+ulint inno_ibuf_inserts = 0;
-+ulint inno_ibuf_merged_recs = 0;
-+ulint inno_ibuf_merges = 0;
-+ulint inno_log_ios_done = 0;
-+
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-
-@@ -419,6 +448,10 @@
- const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
-
- time_t srv_last_monitor_time;
-+
-+/* last time innodb status were updated thru show status */
-+time_t srv_last_innodb_status_time = 0;
-+
-
- mutex_t srv_innodb_monitor_mutex;
-
-@@ -677,6 +710,24 @@
-
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-+
-+/*************************************************************************
-+Prints counters for work done by srv_master_thread. */
-+
-+static
-+void
-+srv_print_extra(
-+/*===================*/
-+ FILE *file) /* in: output stream */
-+{
-+ fprintf(file, "srv_master_thread loops: %lu 1_second, %lu sleeps, "
-+ "%lu 10_second, %lu background, %lu flush\n",
-+ srv_main_1_second_loops, srv_main_sleeps,
-+ srv_main_10_second_loops, srv_main_background_loops,
-+ srv_main_flush_loops);
-+ fprintf(file, "srv_master_thread log flush: %lu sync, %lu async\n",
-+ srv_sync_flush, srv_async_flush);
-+}
-
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-@@ -1685,12 +1736,13 @@
- fputs("----------\n"
- "BACKGROUND THREAD\n"
- "----------\n", file);
-+ srv_print_extra(file);
- fil_print(file);
--
-
- fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
-+ fprintf(file, "Lock wait timeouts %lu\n", inno_lock_wait_timeouts);
- sync_print(file);
-
- /* Conceptually, srv_innodb_monitor_mutex has a very high latching
-@@ -1709,24 +1761,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1815,6 +1849,27 @@
- (srv_n_rows_read - srv_n_rows_read_old)
- / time_elapsed);
-
-+ /* Print open transaction details */
-+ lock_print_info_summary(file);
-+
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- srv_n_rows_inserted_old = srv_n_rows_inserted;
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
-@@ -1833,7 +1888,8 @@
- void
- srv_export_innodb_status(void)
- {
--
-+ long time_elapsed;
-+ time_t current_time;
- mutex_enter(&srv_innodb_monitor_mutex);
- export_vars.innodb_data_pending_reads= os_n_pending_reads;
- export_vars.innodb_data_pending_writes= os_n_pending_writes;
-@@ -1844,6 +1900,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_size= dict_sys->size;
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-@@ -1854,10 +1911,12 @@
- export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
- export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
- export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
-- export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
-+ /* This function uses too much CPU for large buffer caches. */
-+ export_vars.innodb_buffer_pool_pages_latched= 1; /* buf_get_latched_pages_number(); */
- export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
- export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
- UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
-+
- export_vars.innodb_page_size= UNIV_PAGE_SIZE;
- export_vars.innodb_log_waits= srv_log_waits;
- export_vars.innodb_os_log_written= srv_os_log_written;
-@@ -1885,6 +1944,103 @@
- export_vars.innodb_rows_inserted= srv_n_rows_inserted;
- export_vars.innodb_rows_updated= srv_n_rows_updated;
- export_vars.innodb_rows_deleted= srv_n_rows_deleted;
-+ export_vars.innodb_long_lock_wait = srv_long_lock_wait;
-+ export_vars.innodb_long_lock_waits = srv_long_lock_waits;
-+
-+ export_vars.innodb_os_aio_read_requests = os_aio_read_requests;
-+ export_vars.innodb_os_aio_write_requests = os_aio_write_requests;
-+
-+ export_vars.innodb_os_aio_pages_read = os_aio_pages_read;
-+ export_vars.innodb_os_aio_pages_written = os_aio_pages_written;
-+
-+ export_vars.innodb_os_aio_read_time = os_aio_read_time;
-+ export_vars.innodb_os_aio_write_time = os_aio_write_time;
-+
-+ if (os_aio_read_requests > 0 ) {
-+ export_vars.innodb_os_aio_read_time_avg
-+ = os_aio_read_time / os_aio_read_requests;
-+ } else {
-+ export_vars.innodb_os_aio_read_time_avg = 0;
-+ }
-+ if (os_aio_write_requests > 0 ) {
-+ export_vars.innodb_os_aio_write_time_avg
-+ = os_aio_write_time / os_aio_write_requests;
-+ } else {
-+ export_vars.innodb_os_aio_write_time_avg = 0;
-+ }
-+
-+ export_vars.innodb_deadlocks = innodb_deadlocks;
-+
-+ // simulate srv_printf_innodb_monitor, invoked by innodb_show_status
-+ // 0. direct printout inno_lock_wait_timeouts, declared in srv0srv.c
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_lock_wait_timeouts = inno_lock_wait_timeouts;
-+
-+ // *_print functions are allowed to be called once every
-+ // some seconds to prevent too frequent invocation.
-+ // the number is innobase_min_status_update_time_interval
-+ current_time = time(NULL);
-+ time_elapsed = difftime(current_time, srv_last_innodb_status_time);
-+ if (time_elapsed >= innobase_min_status_update_time_interval) {
-+ os_aio_print(NULL);
-+ ibuf_print(NULL);
-+ buf_print_io(NULL);
-+ lock_print_info_summary(NULL);
-+ lock_print_info_all_transactions(NULL);
-+
-+ srv_last_innodb_status_time = current_time;
-+ }
-+
-+ // 1. os_aio_print
-+ // the following were filled by calling os_aio_print
-+ // total # of variable(s) updated: 8
-+
-+ export_vars.inno_pending_normal_aio_reads =
-+ inno_pending_normal_aio_reads;
-+ export_vars.inno_pending_normal_aio_writes =
-+ inno_pending_normal_aio_writes;
-+ export_vars.inno_pending_ibuf_aio_reads = inno_pending_ibuf_aio_reads;
-+ export_vars.inno_pending_log_ios = inno_pending_log_ios;
-+ export_vars.inno_pending_sync_ios = inno_pending_sync_ios;
-+ export_vars.inno_os_reads = os_n_file_reads;
-+ export_vars.inno_os_writes = os_n_file_writes;
-+ export_vars.inno_os_fsyncs = os_n_fsyncs;
-+
-+ // 2. ibuf_print()
-+ // total # of variable(s) updated: 4
-+
-+ export_vars.inno_ibuf_size = inno_ibuf_size;
-+ export_vars.inno_ibuf_inserts = inno_ibuf_inserts;
-+ export_vars.inno_ibuf_merged_recs = inno_ibuf_merged_recs;
-+ export_vars.inno_ibuf_merges = inno_ibuf_merges;
-+
-+ // 3. log_print
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_log_ios_done = (ulong) log_sys->n_log_ios;
-+
-+ // 5. lock_print_info_summary
-+ // it enters the mutexes
-+ // 1) innobase_mysql_prepare_print_arbitrary_thd()
-+ // 2) lock_mutex_enter_kernel()
-+ // total # of variable(s) updated: 3
-+
-+ export_vars.inno_transaction_count = inno_transaction_count;
-+ export_vars.inno_transaction_purge_count =
-+ inno_transaction_purge_count;
-+ export_vars.inno_transaction_purge_lag = inno_transaction_purge_lag;
-+
-+ // 6. lock_print_info_all_transactions(NULL)
-+ // it exits two mutexes entered from lock_print_info_summary(NULL)
-+ // total # of variable(s) updated: 6
-+
-+ export_vars.inno_num_active_transactions = inno_num_active_transactions;
-+ export_vars.inno_summed_transaction_age = inno_summed_transaction_age;
-+ export_vars.inno_longest_transaction_age = inno_longest_transaction_age;
-+
-+ export_vars.inno_num_lock_waiters = inno_num_lock_waiters;
-+ export_vars.inno_summed_lock_wait_time = inno_summed_lock_wait_time;
-+ export_vars.inno_longest_lock_wait = inno_longest_lock_wait;
-+
- mutex_exit(&srv_innodb_monitor_mutex);
-
- }
-@@ -2026,6 +2182,7 @@
- if (thr_get_trx(slot->thr)->wait_lock) {
- lock_cancel_waiting_and_release(
- thr_get_trx(slot->thr)->wait_lock);
-+ ++inno_lock_wait_timeouts;
- }
- }
- }
-diff -r b059d02ec814 patch_info/innodb_extra_status.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_status.info Mon Nov 03 05:09:34 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_extra_status.patch
-+Name=Adds additional information of InnoDB counters into SHOW STATUS
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-03
-+VT: Initial porting
-diff -r b059d02ec814 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -299,12 +299,36 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_size",
-+ (char*) &export_vars.innodb_dict_size, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
- {"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
-+ {"long_lock_wait",
-+ (char*) &export_vars.innodb_long_lock_wait, SHOW_BOOL},
-+ {"long_lock_waits",
-+ (char*) &export_vars.innodb_long_lock_waits, SHOW_LONG},
-+
-+ {"os_read_requests",
-+ (char*) &export_vars.innodb_os_aio_read_requests, SHOW_LONG},
-+ {"os_write_requests",
-+ (char*) &export_vars.innodb_os_aio_write_requests, SHOW_LONG},
-+ {"os_pages_read",
-+ (char*) &export_vars.innodb_os_aio_pages_read, SHOW_LONG},
-+ {"os_pages_written",
-+ (char*) &export_vars.innodb_os_aio_pages_written, SHOW_LONG},
-+ {"os_read_time",
-+ (char*) &export_vars.innodb_os_aio_read_time, SHOW_LONGLONG},
-+ {"os_write_time",
-+ (char*) &export_vars.innodb_os_aio_write_time, SHOW_LONGLONG},
-+ {"time_per_read",
-+ (char*) &export_vars.innodb_os_aio_read_time_avg, SHOW_LONGLONG},
-+ {"time_per_write",
-+ (char*) &export_vars.innodb_os_aio_write_time_avg, SHOW_LONGLONG},
-+
- {"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
- {"os_log_pending_fsyncs",
-@@ -339,6 +363,56 @@
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
- {"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
-+ {"deadlocks",
-+ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
-+
-+ /* 24 innodb status variables exported to status */
-+ {"transaction_count",
-+ (char*) &export_vars.inno_transaction_count, SHOW_LONG},
-+ {"transaction_purge_count",
-+ (char*) &export_vars.inno_transaction_purge_count, SHOW_LONG},
-+ {"transaction_purge_lag",
-+ (char*) &export_vars.inno_transaction_purge_lag, SHOW_LONG},
-+ {"active_transactions",
-+ (char*) &export_vars.inno_num_active_transactions, SHOW_LONG},
-+ {"summed_transaction_age",
-+ (char*) &export_vars.inno_summed_transaction_age, SHOW_LONG},
-+ {"longest_transaction_age",
-+ (char*) &export_vars.inno_longest_transaction_age, SHOW_LONG},
-+ {"lock_wait_timeouts",
-+ (char*) &export_vars.inno_lock_wait_timeouts, SHOW_LONG},
-+ {"lock_waiters",
-+ (char*) &export_vars.inno_num_lock_waiters, SHOW_LONG},
-+ {"summed_lock_wait_time",
-+ (char*) &export_vars.inno_summed_lock_wait_time, SHOW_LONG},
-+ {"longest_lock_wait",
-+ (char*) &export_vars.inno_longest_lock_wait, SHOW_LONG},
-+ {"pending_normal_aio_reads",
-+ (char*) &export_vars.inno_pending_normal_aio_reads, SHOW_LONG},
-+ {"pending_normal_aio_writes",
-+ (char*) &export_vars.inno_pending_normal_aio_writes, SHOW_LONG},
-+ {"pending_ibuf_aio_reads",
-+ (char*) &export_vars.inno_pending_ibuf_aio_reads, SHOW_LONG},
-+ {"pending_log_ios",
-+ (char*) &export_vars.inno_pending_log_ios, SHOW_LONG},
-+ {"pending_sync_ios",
-+ (char*) &export_vars.inno_pending_sync_ios, SHOW_LONG},
-+ {"os_reads",
-+ (char*) &export_vars.inno_os_reads, SHOW_LONG},
-+ {"os_writes",
-+ (char*) &export_vars.inno_os_writes, SHOW_LONG},
-+ {"os_fsyncs",
-+ (char*) &export_vars.inno_os_fsyncs, SHOW_LONG},
-+ {"ibuf_inserts",
-+ (char*) &export_vars.inno_ibuf_size, SHOW_LONG},
-+ {"ibuf_size",
-+ (char*) &export_vars.inno_ibuf_inserts, SHOW_LONG},
-+ {"ibuf_merged_recs",
-+ (char*) &export_vars.inno_ibuf_merged_recs, SHOW_LONG},
-+ {"ibuf_merges",
-+ (char*) &export_vars.inno_ibuf_merges, SHOW_LONG},
-+ {"log_ios_done",
-+ (char*) &export_vars.inno_log_ios_done, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}};
-
- /* General functions */
-diff -r b059d02ec814 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:09:34 2008 -0800
-@@ -198,6 +198,7 @@
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
- extern long innobase_max_merged_io;
-+extern long innobase_min_status_update_time_interval;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-diff -r b059d02ec814 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -4950,6 +4950,7 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -6031,6 +6032,14 @@
- (gptr*) &srv_thread_sleep_delay,
- (gptr*) &srv_thread_sleep_delay,
- 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
-+ {"innodb_status_update_interval",
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
-+ "Minimum time interval in seconds before InnoDB status counters "
-+ "are updated during SHOW STATUS. "
-+ "InnoDB counters are always updated during SHOW INNODB STATUS.",
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ 0, GET_LONG, REQUIRED_ARG, 30, 0, 3600, 0, 1, 0},
- #endif /* HAVE_INNOBASE_DB */
- {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
- "The number of seconds the server waits for activity on an interactive connection before closing it.",
-diff -r b059d02ec814 sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -948,6 +948,8 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
- {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
-+ {"innodb_status_update_interval",
-+ (char*) &innobase_min_status_update_time_interval, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/innodb_fsync_source.patch b/percona/5.0.87-b20-20091116/innodb_fsync_source.patch
deleted file mode 100644
index 2961b78..0000000
--- a/percona/5.0.87-b20-20091116/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r ef44d8017b6b innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:32 2009 -0700
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r ef44d8017b6b innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/fil/fil0fil.c Fri Jul 03 15:41:32 2009 -0700
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4167,8 +4188,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4177,7 +4199,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4282,7 +4304,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4323,7 +4346,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r ef44d8017b6b innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/fil0fil.h Fri Jul 03 15:41:32 2009 -0700
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -625,14 +632,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -640,7 +659,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r ef44d8017b6b innobase/include/log0log.h
---- a/innobase/include/log0log.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/log0log.h Fri Jul 03 15:41:32 2009 -0700
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Flushes the log buffer. Forces it to disk depending on the value of
-@@ -751,6 +774,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r ef44d8017b6b innobase/log/log0log.c
---- a/innobase/log/log0log.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/log/log0log.c Fri Jul 03 15:41:32 2009 -0700
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1574,7 +1590,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1944,11 +1960,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1961,7 +1977,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2589,7 +2606,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2670,7 +2687,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3207,8 +3225,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3241,7 +3259,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3363,15 +3381,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r ef44d8017b6b innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:32 2009 -0700
-@@ -1698,6 +1698,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r ef44d8017b6b innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:32 2009 -0700
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r ef44d8017b6b innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0trx.c Fri Jul 03 15:41:32 2009 -0700
-@@ -942,19 +942,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1701,18 +1703,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1948,19 +1953,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r ef44d8017b6b patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Fri Jul 03 15:41:32 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.87-b20-20091116/innodb_io_patches.patch b/percona/5.0.87-b20-20091116/innodb_io_patches.patch
deleted file mode 100644
index aaef29a..0000000
--- a/percona/5.0.87-b20-20091116/innodb_io_patches.patch
+++ /dev/null
@@ -1,1379 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-05-08 06:12:03.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-07-02 16:44:49.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-07-02 16:44:49.000000000 +0900
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +190,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +401,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-05-08 06:12:04.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-07-02 16:44:49.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/log0log.h b/innobase/include/log0log.h
---- a/innobase/include/log0log.h 2009-05-08 06:12:06.000000000 +0900
-+++ b/innobase/include/log0log.h 2009-07-02 16:44:49.000000000 +0900
-@@ -169,6 +169,13 @@
- log_buffer_flush_to_disk(void);
- /*==========================*/
- /********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
-+/*=============================*/
-+/********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
- buffer pool and also may make a new checkpoint. NOTE: this function may only
- be called if the calling thread owns no synchronization objects! */
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-07-02 16:44:49.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-02 18:02:38.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1524,6 +1524,29 @@
- }
-
- /********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*=============================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
-+}
-+/********************************************************************
- Tries to establish a big enough margin of free space in the log buffer, such
- that a new log entry can be catenated without an immediate need for a flush. */
- static
-@@ -3326,6 +3349,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-07-02 16:44:49.000000000 +0900
-@@ -66,6 +66,28 @@
-
- ibool os_aio_print_debug = FALSE;
-
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-+
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-
-@@ -74,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -84,11 +108,11 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
-+// ibool io_already_done;/* used only in simulated aio:
-+// TRUE if the physical i/o already
-+// made and only the slot message
-+// needs to be passed to the caller
-+// of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -137,6 +161,13 @@
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-+
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
- static os_aio_array_t* os_aio_read_array = NULL;
-@@ -145,11 +176,17 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
- /* If the following is TRUE, read i/o handler threads try to
- wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -2878,8 +2915,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2889,6 +2928,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2896,14 +2937,17 @@
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-+ os_aio_first_write_segment = os_aio_first_read_segment + n_read_threads;
- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-
- srv_io_thread_function[0] = "insert buffer thread";
-@@ -2912,14 +2956,14 @@
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-+ os_aio_read_array = os_aio_array_create(n_per_seg,
- n_read_segs);
- for (i = 2; i < 2 + n_read_segs; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
- srv_io_thread_function[i] = "read thread";
- }
-
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-+ os_aio_write_array = os_aio_array_create(n_per_seg,
- n_write_segs);
- for (i = 2 + n_read_segs; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-@@ -3181,6 +3225,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3199,6 +3250,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3206,6 +3267,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-@@ -3228,7 +3290,8 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+// slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3281,6 +3344,7 @@
- ut_ad(slot->reserved);
-
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3317,16 +3381,18 @@
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
- os_mutex_enter(array->mutex);
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
- /* Found an i/o request */
-
- break;
-@@ -3336,7 +3402,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3347,8 +3431,6 @@
- os_aio_simulated_wake_handler_threads(void)
- /*=======================================*/
- {
-- ulint i;
--
- if (os_aio_use_native_aio) {
- /* We do not use simulated aio: do nothing */
-
-@@ -3357,9 +3439,10 @@
-
- os_aio_recommend_sleep_for_read_threads = FALSE;
-
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ os_aio_simulated_wake_handler_thread(0);
-+ os_aio_simulated_wake_handler_thread(1);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_read_segment);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_write_segment);
- }
-
- /**************************************************************************
-@@ -3640,7 +3723,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
-@@ -3648,12 +3731,12 @@
- } else {
- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-+ (array->native_events));
- }
-
- os_mutex_enter(array->mutex);
-
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3830,10 +3913,13 @@
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3841,6 +3927,7 @@
- ibool ret;
- ulint n;
- ulint i;
-+ time_t now;
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-@@ -3853,7 +3940,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
-@@ -3875,9 +3962,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved && slot->io_already_done) {
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3897,67 +3984,57 @@
- then pick the one at the lowest offset. */
-
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-
-+ /* Find the oldest request and the request with the smallest offset */
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-- lowest_offset = slot->offset;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
-
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3965,7 +4042,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3994,6 +4072,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -4001,7 +4081,14 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -4012,6 +4099,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -4081,16 +4171,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4100,6 +4187,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-02 18:36:54.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -330,6 +332,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2228,6 +2248,10 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-+ dulint lsn_old;
-+
-+ dulint oldest_lsn;
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
-@@ -2244,6 +2268,9 @@
-
- mutex_exit(&kernel_mutex);
-
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- os_event_set(srv_sys->operational);
- loop:
- /*****************************************************************/
-@@ -2279,6 +2306,18 @@
- if (!skip_sleep) {
-
- os_thread_sleep(1000000);
-+ /*
-+ mutex_enter(&(log_sys->mutex));
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ dulint lsn = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ if (!ut_dulint_is_zero(oldest_lsn))
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old));
-+ */
- }
-
- skip_sleep = FALSE;
-@@ -2317,13 +2356,14 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2332,7 +2372,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2341,6 +2381,140 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (srv_adaptive_checkpoint == 1) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+ } else if (srv_adaptive_checkpoint == 2) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* defence line (max_checkpoint_age * 1/2) */
-+ dulint lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ ib_longlong level, bpl;
-+ buf_block_t* bpage;
-+
-+ mutex_enter(&buf_pool->mutex);
-+
-+ level = 0;
-+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-+
-+ while (bpage != NULL) {
-+ dulint oldest_modification = bpage->oldest_modification;
-+ if (!ut_dulint_is_zero(oldest_modification)) {
-+ level += log_sys->max_checkpoint_age
-+ - ut_dulint_minus(lsn, oldest_modification);
-+ }
-+ bpage = UT_LIST_GET_NEXT(flush_list, bpage);
-+ }
-+
-+ if (level) {
-+ bpl = ((ib_longlong) UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * ut_dulint_minus(lsn, lsn_old)) / level;
-+ } else {
-+ bpl = 0;
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+
-+ if (!srv_use_doublewrite_buf) {
-+ /* flush is faster than when doublewrite */
-+ bpl = (bpl * 3) / 4;
-+ }
-+
-+ if(bpl) {
-+retry_flush_batch:
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ bpl,
-+ ut_dulint_add(oldest_lsn,
-+ ut_dulint_minus(lsn,
-+ lsn_old)));
-+ if (n_pages_flushed == ULINT_UNDEFINED) {
-+ os_thread_sleep(5000);
-+ goto retry_flush_batch;
-+ }
-+ }
-+
-+ lsn_old = lsn;
-+ /*
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu, blocks to flush:%llu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old), bpl);
-+ */
-+ } else {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
-+ } else {
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2367,23 +2541,25 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2422,14 +2598,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2518,7 +2694,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2535,7 +2711,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2557,7 +2733,14 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-08 06:12:12.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-07-02 16:44:49.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-02 16:44:49.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1417,6 +1418,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7330,6 +7333,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-02 18:10:51.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,15 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
-+
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
- running with the fix disabled because MySQL 5.1 is frozen for such
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-02 18:00:04.000000000 +0900
-@@ -5086,6 +5086,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5403,6 +5413,44 @@
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 200, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. ([none], reflex, estimate)",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7644,6 +7692,38 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
-+ case OPT_INNODB_ADAPTIVE_CHECKPOINT:
-+ if (argument == disabled_my_option)
-+ srv_adaptive_checkpoint = 0;
-+ else if (! argument)
-+ srv_adaptive_checkpoint = 0;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_adaptive_checkpoint_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_adaptive_checkpoint type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_adaptive_checkpoint = (uint) ((type - 1) % 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-02 17:45:29.000000000 +0900
-@@ -489,6 +489,57 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+
-+const char *innodb_adaptive_checkpoint_names[]=
-+{
-+ "none", /* 0 */
-+ "reflex", /* 1 */
-+ "estimate", /* 2 */
-+ /* For compatibility of the older patch */
-+ "0", /* 3 ("none" + 3) */
-+ "1", /* 4 ("reflex" + 3) */
-+ "2", /* 5 ("estimate" + 3) */
-+ NullS
-+};
-+TYPELIB innodb_adaptive_checkpoint_typelib=
-+{
-+ array_elements(innodb_adaptive_checkpoint_names) - 1, "innodb_adaptive_checkpoint_typelib",
-+ innodb_adaptive_checkpoint_names, NULL
-+};
-+sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint,
-+ &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -860,6 +911,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -997,6 +1055,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -1459,6 +1527,18 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+
-+extern void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type)
-+{
-+ srv_adaptive_checkpoint %= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.h 2009-07-02 17:35:17.000000000 +0900
-@@ -31,6 +31,11 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+extern TYPELIB innodb_adaptive_checkpoint_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1153,10 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.87-b20-20091116/innodb_io_pattern.patch b/percona/5.0.87-b20-20091116/innodb_io_pattern.patch
deleted file mode 100644
index d9e60e9..0000000
--- a/percona/5.0.87-b20-20091116/innodb_io_pattern.patch
+++ /dev/null
@@ -1,693 +0,0 @@
-diff -r d4826c0a98c2 include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 10:00:12 2009 -0700
-@@ -122,6 +122,9 @@
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-+
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
- #define CLIENT_LONG_FLAG 4 /* Get all column flags */
-diff -r d4826c0a98c2 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/buf/buf0buf.c Wed Jul 29 10:00:12 2009 -0700
-@@ -654,6 +654,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1967,6 +1970,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2068,6 +2074,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2083,6 +2109,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2657,3 +2703,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r d4826c0a98c2 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0buf.h Wed Jul 29 10:00:12 2009 -0700
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r d4826c0a98c2 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0types.h Wed Jul 29 10:00:12 2009 -0700
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r d4826c0a98c2 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/srv0srv.h Wed Jul 29 10:00:12 2009 -0700
-@@ -146,6 +146,11 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r d4826c0a98c2 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/srv/srv0srv.c Wed Jul 29 10:00:12 2009 -0700
-@@ -352,6 +352,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r d4826c0a98c2 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 10:00:12 2009 -0700
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r d4826c0a98c2 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 10:00:12 2009 -0700
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r d4826c0a98c2 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 10:00:12 2009 -0700
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r d4826c0a98c2 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Wed Jul 29 10:00:12 2009 -0700
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r d4826c0a98c2 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -1583,6 +1583,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6551,6 +6553,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r d4826c0a98c2 sql/ha_innodb.h
---- a/sql/ha_innodb.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.h Wed Jul 29 10:00:12 2009 -0700
-@@ -245,6 +245,9 @@
- extern uint srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-@@ -278,6 +281,9 @@
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-+
- void innobase_release_temporary_latches(THD *thd);
-
- void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
-diff -r d4826c0a98c2 sql/lex.h
---- a/sql/lex.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 10:00:12 2009 -0700
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r d4826c0a98c2 sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -5029,6 +5029,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5461,6 +5464,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r d4826c0a98c2 sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -546,6 +546,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -926,6 +932,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1075,6 +1084,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -3210,6 +3222,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r d4826c0a98c2 sql/set_var.h
---- a/sql/set_var.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.h Wed Jul 29 10:00:12 2009 -0700
-@@ -1012,6 +1012,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r d4826c0a98c2 sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -8104,6 +8104,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r d4826c0a98c2 sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -33,6 +33,17 @@
- #include "ha_innodb.h"
- #endif
-
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-+
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
- "select","insert","update","delete","create","drop","reload","shutdown",
-@@ -4108,6 +4119,72 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4914,6 +4986,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5089,6 +5174,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r d4826c0a98c2 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 10:00:12 2009 -0700
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8500,6 +8501,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9552,6 +9554,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.87-b20-20091116/innodb_io_tune.patch b/percona/5.0.87-b20-20091116/innodb_io_tune.patch
deleted file mode 100644
index 3953e1d..0000000
--- a/percona/5.0.87-b20-20091116/innodb_io_tune.patch
+++ /dev/null
@@ -1,1823 +0,0 @@
-diff -r 322370200e6a innobase/include/os0file.h
---- a/innobase/include/os0file.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/os0file.h Mon Nov 03 05:08:52 2008 -0800
-@@ -532,21 +532,16 @@
- FALSE otherwise */
- const char* path); /* in: path name */
- /****************************************************************************
--Initializes the asynchronous io system. Creates separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
-+Initializes the asynchronous io system. */
-
--void
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ /* out: number of AIO handler threads */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per IO array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -r 322370200e6a innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-@@ -87,6 +87,14 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-+
-+/* Number of IO operations per second the server can do */
-+extern ulint srv_io_capacity;
-+
-+/* Flush dirty pages when below max dirty percent */
-+extern ibool srv_extra_dirty_writes;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -252,6 +260,24 @@
-
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-+
-+/* Number of IO operations read/write done for all threads */
-+extern ulint os_aio_read_requests;
-+extern ulint os_aio_write_requests;
-+
-+/* Number of pages read/written done for all threads */
-+extern ulint os_aio_pages_read;
-+extern ulint os_aio_pages_written;
-+
-+/* time usec used to perform read/write for all threads */
-+extern ib_longlong os_aio_read_time;
-+extern ib_longlong os_aio_write_time;
-+
-+extern ulint inno_pending_normal_aio_reads;
-+extern ulint inno_pending_normal_aio_writes;
-+extern ulint inno_pending_ibuf_aio_reads;
-+extern ulint inno_pending_log_ios;
-+extern ulint inno_pending_sync_ios;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-diff -r 322370200e6a innobase/log/log0log.c
---- a/innobase/log/log0log.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/log/log0log.c Mon Nov 03 05:08:52 2008 -0800
-@@ -1537,6 +1537,30 @@
-
- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
- LOG_WRITE_FROM_BACKGROUND_SYNC);
-+}
-+
-+/********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*==========================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
- }
-
- /********************************************************************
-diff -r 322370200e6a innobase/os/os0file.c
---- a/innobase/os/os0file.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/os/os0file.c Mon Nov 03 05:08:52 2008 -0800
-@@ -22,6 +22,8 @@
- #include <errno.h>
- #endif /* UNIV_HOTBACKUP */
-
-+extern long innobase_max_merged_io;
-+
- #undef HAVE_FDATASYNC
-
- #ifdef POSIX_ASYNC_IO
-@@ -63,6 +65,28 @@
- ibool os_aio_use_native_aio = FALSE;
-
- ibool os_aio_print_debug = FALSE;
-+
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-@@ -72,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -82,11 +108,6 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -116,9 +137,6 @@
- in this array */
- ulint n_slots; /* Total number of slots in the aio array.
- This must be divisible by n_threads. */
-- ulint n_segments;/* Number of segments in the aio array of
-- pending aio requests. A thread can wait
-- separately for any one of the segments. */
- ulint n_reserved;/* Number of reserved slots in the
- aio array outside the ibuf segment */
- os_aio_slot_t* slots; /* Pointer to the slots in the array */
-@@ -134,6 +152,17 @@
-
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-+
-+/* Number of threads for reading and writing. */
-+ulint os_aio_read_threads = 0;
-+ulint os_aio_write_threads = 0;
-+
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
-@@ -143,11 +172,39 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
-+/* Count pages read and written per thread */
-+static ulint os_aio_thread_io_reads[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_io_writes[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO operations done. One request can be for N pages. */
-+static ulint os_aio_thread_io_requests[SRV_MAX_N_IO_THREADS];
-+
-+/* usecs spent blocked on an IO request */
-+static double os_aio_thread_io_wait[SRV_MAX_N_IO_THREADS];
-+/* max usecs spent blocked on an IO request */
-+static double os_aio_thread_max_io_wait[SRV_MAX_N_IO_THREADS];
-+
-+/* Number of IO global segments. An IO handler thread is created for each
-+global segment, except for the segment associated with os_aio_sync_array.
-+Several segments can be associated with os_aio_{read,write}_array. One
-+segment is created for each of the other arrays. This is also the number
-+of valid entries in srv_io_thread_reads, srv_io_thread_writes,
-+srv_io_thread_op_info, srv_io_thread_function and os_aio_segment_wait_events. */
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
--/* If the following is TRUE, read i/o handler threads try to
--wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+/* Set to TRUE to temporarily block reads from being scheduled while a batch
-+of read requests is added to allow them to be merged by the IO handler thread
-+if they are adjacent. Declared volatile because we don't want this to be
-+read from a register in a loop when another thread may change the value in
-+memory.
-+*/
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -166,6 +223,19 @@
- ulint os_file_n_pending_pwrites = 0;
- ulint os_n_pending_writes = 0;
- ulint os_n_pending_reads = 0;
-+
-+/* TODO -- does InnoDB provide a portable method for this? */
-+static double time_usecs() {
-+#ifdef __WIN__
-+ return 0.0;
-+#else
-+ struct timeval tv;
-+ if (gettimeofday(&tv, NULL))
-+ return 0;
-+ else
-+ return tv.tv_sec * 1000000.0 + tv.tv_usec;
-+#endif
-+}
-
- /***************************************************************************
- Gets the operating system version. Currently works only on Windows. */
-@@ -1351,6 +1421,8 @@
- /* We disable OS caching (O_DIRECT) only on data files */
- if (type != OS_LOG_FILE
- && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
-+
-+ fprintf(stderr, "Using O_DIRECT for file %s\n", name);
-
- os_file_set_nocache(file, name, mode_str);
- }
-@@ -1798,6 +1870,32 @@
- #endif /* __WIN__ */
- }
-
-+#ifndef __WIN__
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fsync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fsync(file);
-+}
-+
-+/***************************************************************************
-+Possibly flushes a given file to disk. */
-+
-+ibool
-+os_maybe_fdatasync(
-+/*==========*/
-+ /* out: 0 if success, error code otherwise */
-+ os_file_t file) /* in, own: handle to a file */
-+{
-+ return (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) ? 0 : fdatasync(file);
-+}
-+#endif
-+
- /***************************************************************************
- Flushes the write buffers of a given file to the disk. */
-
-@@ -1855,21 +1953,21 @@
- /* If we are not on an operating system that supports this,
- then fall back to a plain fsync. */
-
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- } else {
- ret = fcntl(file, F_FULLFSYNC, NULL);
-
- if (ret) {
- /* If we are not on a file system that supports this,
- then fall back to a plain fsync. */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- }
- }
- #elif HAVE_FDATASYNC
-- ret = fdatasync(file);
-+ ret = os_maybe_fdatasync(file);
- #else
- /* fprintf(stderr, "Flushing to file %p\n", file); */
-- ret = fsync(file);
-+ ret = os_maybe_fsync(file);
- #endif
- os_n_fsyncs++;
-
-@@ -2298,6 +2396,9 @@
-
- return(TRUE);
- }
-+ fprintf(stderr,
-+"InnoDB: error: os_file_pread wanted %lu and got %lu.\n",
-+ (ulint) n, (ulint) ret);
- #endif
- #ifdef __WIN__
- error_handling:
-@@ -2784,9 +2885,8 @@
- os_aio_array_create(
- /*================*/
- /* out, own: aio array */
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments) /* in: number of segments in the aio array */
-+ ulint n) /* in: maximum number of pending aio operations
-+ allowed */
- {
- os_aio_array_t* array;
- ulint i;
-@@ -2795,7 +2895,6 @@
- OVERLAPPED* over;
- #endif
- ut_a(n > 0);
-- ut_a(n_segments > 0);
-
- array = ut_malloc(sizeof(os_aio_array_t));
-
-@@ -2806,7 +2905,6 @@
- os_event_set(array->is_empty);
-
- array->n_slots = n;
-- array->n_segments = n_segments;
- array->n_reserved = 0;
- array->slots = ut_malloc(n * sizeof(os_aio_slot_t));
- #ifdef __WIN__
-@@ -2833,70 +2931,75 @@
-
- /****************************************************************************
- Initializes the asynchronous io system. Calls also os_io_init_simple.
--Creates a separate aio array for
--non-ibuf read and write, a third aio array for the ibuf i/o, with just one
--segment, two aio arrays for log reads and writes with one segment, and a
--synchronous aio array of the specified size. The combined number of segments
--in the three first aio arrays is the parameter n_segments given to the
--function. The caller must create an i/o handler thread for each segment in
--the four first arrays, but not for the sync aio array. */
--
--void
-+Creates an aio array for each of non-ibuf read, non-ibuf write, ibuf IO,
-+log IO, and synchronous IO. The caller must create i/o handler thread for all
-+but the synchronous aio array. Multiple threads can access the same array for
-+the non-ibuf read (prefetch) and write (flush dirty buffer pages) arrays.
-+Return the number of AIO handler threads. */
-+
-+ulint
- os_aio_init(
- /*========*/
-- ulint n, /* in: maximum number of pending aio operations
-- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+ ulint ios_per_array, /* in: maximum number of pending aio operations
-+ allowed per array */
-+ ulint n_read_threads, /* in: number of read threads */
-+ ulint n_write_threads, /* in: number of write threads */
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
-- ulint n_read_segs;
-- ulint n_write_segs;
-- ulint n_per_seg;
-- ulint i;
-+ ulint i;
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-- ut_ad(n % n_segments == 0);
-- ut_ad(n_segments >= 4);
-+ ut_a(ios_per_array >= OS_AIO_N_PENDING_IOS_PER_THREAD);
-+ ut_a(n_read_threads >= 1 && n_read_threads <= 64);
-+ ut_a(n_write_threads >= 1 && n_write_threads <= 64);
-+ ut_a(n_segments < SRV_MAX_N_IO_THREADS);
-
- os_io_init_simple();
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-- }
--
-- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
--
-- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
--
-- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_thread_io_reads[i] = 0;
-+ os_aio_thread_io_writes[i] = 0;
-+ os_aio_thread_io_requests[i] = 0;
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
-+ os_aio_thread_io_wait[i] = 0;
-+ os_aio_thread_max_io_wait[i] = 0;
-+ }
-+
-+ os_aio_read_threads = n_read_threads;
-+ os_aio_write_threads = n_write_threads;
-+ os_aio_first_write_segment = os_aio_first_read_segment + os_aio_read_threads;
-+
-+ fprintf(stderr,
-+ "InnoDB: ios_per_array %lu read threads %lu write threads %lu\n",
-+ ios_per_array, os_aio_read_threads, os_aio_write_threads);
-+
-+ os_aio_ibuf_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[0] = "insert buffer thread";
-
-- os_aio_log_array = os_aio_array_create(n_per_seg, 1);
-+ os_aio_log_array = os_aio_array_create(ios_per_array);
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-- n_read_segs);
-- for (i = 2; i < 2 + n_read_segs; i++) {
-+ os_aio_read_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_read_segment; i < os_aio_first_write_segment; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "read thread";
-- }
--
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-- n_write_segs);
-- for (i = 2 + n_read_segs; i < n_segments; i++) {
-+ srv_io_thread_function[i] = "read thread";
-+ }
-+
-+ os_aio_write_array = os_aio_array_create(ios_per_array);
-+ for (i = os_aio_first_write_segment; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-- srv_io_thread_function[i] = "write thread";
-- }
--
-- os_aio_sync_array = os_aio_array_create(n_slots_sync, 1);
--
-- os_aio_n_segments = n_segments;
-+ srv_io_thread_function[i] = "write thread";
-+ }
-+
-+ os_aio_sync_array = os_aio_array_create(n_slots_sync);
-+
-+ os_aio_n_segments = 2 + os_aio_read_threads + os_aio_write_threads;
-
- os_aio_validate();
-
-@@ -2924,6 +3027,7 @@
-
- pthread_sigmask(SIG_BLOCK, &sigset, NULL); */
- #endif
-+ return os_aio_n_segments;
- }
-
- #ifdef WIN_ASYNC_IO
-@@ -2981,77 +3085,32 @@
- os_event_wait(os_aio_write_array->is_empty);
- }
-
--/**************************************************************************
--Calculates segment number for a slot. */
--static
--ulint
--os_aio_get_segment_no_from_slot(
--/*============================*/
-- /* out: segment number (which is the number
-- used by, for example, i/o-handler threads) */
-- os_aio_array_t* array, /* in: aio wait array */
-- os_aio_slot_t* slot) /* in: slot in this array */
--{
-- ulint segment;
-- ulint seg_len;
--
-- if (array == os_aio_ibuf_array) {
-- segment = 0;
--
-- } else if (array == os_aio_log_array) {
-- segment = 1;
--
-- } else if (array == os_aio_read_array) {
-- seg_len = os_aio_read_array->n_slots /
-- os_aio_read_array->n_segments;
--
-- segment = 2 + slot->pos / seg_len;
-- } else {
-- ut_a(array == os_aio_write_array);
-- seg_len = os_aio_write_array->n_slots /
-- os_aio_write_array->n_segments;
--
-- segment = os_aio_read_array->n_segments + 2
-- + slot->pos / seg_len;
-- }
--
-- return(segment);
--}
--
--/**************************************************************************
--Calculates local segment number and aio array from global segment number. */
--static
--ulint
--os_aio_get_array_and_local_segment(
-+
-+/**************************************************************************
-+Calculates aio array from global segment number. */
-+static
-+os_aio_array_t*
-+os_aio_get_array(
- /*===============================*/
-- /* out: local segment number within
-- the aio array */
-- os_aio_array_t** array, /* out: aio wait array */
-+ /* out: aio wait array */
- ulint global_segment)/* in: global segment number */
- {
-- ulint segment;
-
- ut_a(global_segment < os_aio_n_segments);
-
- if (global_segment == 0) {
-- *array = os_aio_ibuf_array;
-- segment = 0;
-+ return os_aio_ibuf_array;
-
- } else if (global_segment == 1) {
-- *array = os_aio_log_array;
-- segment = 0;
--
-- } else if (global_segment < os_aio_read_array->n_segments + 2) {
-- *array = os_aio_read_array;
--
-- segment = global_segment - 2;
-- } else {
-- *array = os_aio_write_array;
--
-- segment = global_segment - (os_aio_read_array->n_segments + 2);
-- }
--
-- return(segment);
-+ return os_aio_log_array;
-+
-+ } else if (global_segment < os_aio_first_write_segment) {
-+ return os_aio_read_array;
-+
-+ } else {
-+ return os_aio_write_array;
-+
-+ }
- }
-
- /***********************************************************************
-@@ -3160,7 +3219,7 @@
-
- os_aio_simulated_wake_handler_threads();
- }
--
-+
- os_event_wait(array->not_full);
-
- goto loop;
-@@ -3173,7 +3232,7 @@
- break;
- }
- }
--
-+ ut_a(i < array->n_slots);
- array->n_reserved++;
-
- if (array->n_reserved == 1) {
-@@ -3195,7 +3254,7 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3246,8 +3305,9 @@
- os_mutex_enter(array->mutex);
-
- ut_ad(slot->reserved);
--
-+
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3266,36 +3326,40 @@
- }
-
- /**************************************************************************
--Wakes up a simulated aio i/o-handler thread if it has something to do. */
-+Wake up the simulated aio i/o-handler threads for a given array if there
-+is work to do. */
- static
- void
- os_aio_simulated_wake_handler_thread(
- /*=================================*/
-- ulint global_segment) /* in: the number of the segment in the aio
-- arrays */
--{
-- os_aio_array_t* array;
-- os_aio_slot_t* slot;
-- ulint segment;
-+ os_aio_array_t* array) /* in: aio array for which wakeup is done */
-+{
-+ os_aio_slot_t* slot;
- ulint n;
- ulint i;
-
- ut_ad(!os_aio_use_native_aio);
-
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
--
-- os_mutex_enter(array->mutex);
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- /* Found an i/o request */
--
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-+
-+ os_mutex_enter(array->mutex);
-+
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i );
-+
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
-+ /* Found an i/o request
-+ /* OS_AIO_NOT_ISSUED means the read or write request has
-+ * yet to be done. OS_AIO_DONE means the request has been
-+ * done but it was part of a set of requests merged into
-+ * one read or write call and was not the first block in
-+ * the request, so the handling of the IO completion for
-+ * that block has not been done. */
-+
- break;
- }
- }
-@@ -3303,7 +3367,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3320,13 +3402,14 @@
- /* We do not use simulated aio: do nothing */
-
- return;
-- }
--
-- os_aio_recommend_sleep_for_read_threads = FALSE;
--
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ }
-+
-+ os_aio_recommend_sleep_for_read_threads = FALSE;
-+
-+ os_aio_simulated_wake_handler_thread(os_aio_ibuf_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_log_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_read_array);
-+ os_aio_simulated_wake_handler_thread(os_aio_write_array);
- }
-
- /**************************************************************************
-@@ -3339,18 +3422,13 @@
- os_aio_simulated_put_read_threads_to_sleep(void)
- /*============================================*/
- {
-- os_aio_array_t* array;
- ulint g;
-
-+ /* TODO(mcallaghan): provide similar function for write? */
- os_aio_recommend_sleep_for_read_threads = TRUE;
-
-- for (g = 0; g < os_aio_n_segments; g++) {
-- os_aio_get_array_and_local_segment(&array, g);
--
-- if (array == os_aio_read_array) {
--
-- os_event_reset(os_aio_segment_wait_events[g]);
-- }
-+ for (g = os_aio_first_read_segment; g < os_aio_first_write_segment; g++) {
-+ os_event_reset(os_aio_segment_wait_events[g]);
- }
- }
-
-@@ -3480,8 +3558,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else if (type == OS_FILE_WRITE) {
-@@ -3497,8 +3574,7 @@
- #endif
- } else {
- if (!wake_later) {
-- os_aio_simulated_wake_handler_thread(
-- os_aio_get_segment_no_from_slot(array, slot));
-+ os_aio_simulated_wake_handler_thread(array);
- }
- }
- } else {
-@@ -3561,7 +3637,7 @@
- os_aio_windows_handle(
- /*==================*/
- /* out: TRUE if the aio operation succeeded */
-- ulint segment, /* in: the number of the segment in the aio
-+ ulint global_segment, /* in: the number of the segment in the aio
- arrays to wait for; segment 0 is the ibuf
- i/o thread, segment 1 the log i/o thread,
- then follow the non-ibuf read threads, and as
-@@ -3579,7 +3655,6 @@
- void** message2,
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
-- ulint orig_seg = segment;
- os_aio_array_t* array;
- os_aio_slot_t* slot;
- ulint n;
-@@ -3588,33 +3663,30 @@
- BOOL ret;
- DWORD len;
-
-- if (segment == ULINT_UNDEFINED) {
-+ if (global_segment == ULINT_UNDEFINED) {
- array = os_aio_sync_array;
-- segment = 0;
-- } else {
-- segment = os_aio_get_array_and_local_segment(&array, segment);
-+ } else {
-+ array = os_aio_get_array(global_segment);
- }
-
- /* NOTE! We only access constant fields in os_aio_array. Therefore
- we do not have to acquire the protecting mutex yet */
-
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
-+
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
- i = pos;
- } else {
-- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
-- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-- }
--
-- os_mutex_enter(array->mutex);
--
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ srv_set_io_thread_op_info(global_segment, "wait Windows aio");
-+ i = os_event_wait_multiple(n, (array->native_events));
-+ }
-+
-+ os_mutex_enter(array->mutex);
-+
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3787,14 +3859,16 @@
- ulint* type) /* out: OS_FILE_WRITE or ..._READ */
- {
- os_aio_array_t* array;
-- ulint segment;
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3802,8 +3876,10 @@
- ibool ret;
- ulint n;
- ulint i;
--
-- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-+
-+ double start_usecs, stop_usecs, elapsed_usecs;
-+ time_t now;
-+ array = os_aio_get_array(global_segment);
-
- restart:
- /* NOTE! We only access constant fields in os_aio_array. Therefore
-@@ -3812,11 +3888,10 @@
- srv_set_io_thread_op_info(global_segment,
- "looking for i/o requests (a)");
- ut_ad(os_aio_validate());
-- ut_ad(segment < array->n_segments);
--
-- n = array->n_slots / array->n_segments;
--
-- /* Look through n slots after the segment * n'th slot */
-+
-+ n = array->n_slots;
-+
-+ /* Look through n slots */
-
- if (array == os_aio_read_array
- && os_aio_recommend_sleep_for_read_threads) {
-@@ -3836,9 +3911,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved && slot->io_already_done) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3846,79 +3921,66 @@
- }
-
- ret = TRUE;
--
-+
- goto slot_io_done;
- }
- }
-
-- n_consecutive = 0;
--
-- /* If there are at least 2 seconds old requests, then pick the oldest
-- one to prevent starvation. If several requests have the same age,
-- then pick the one at the lowest offset. */
--
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
--
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
--
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-+
-+ /* Find the oldest request and the request with the smallest offset */
-+ for (i = 0; i < n; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-+
-+ /* If there are at least 2 seconds old requests, then pick the oldest
-+ one to prevent starvation. If several requests have the same age,
-+ then pick the one at the lowest offset. */
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
-+ }
-+
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
-+ /* Found an i/o request */
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
--
-- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-- lowest_offset = slot->offset;
-- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3926,7 +3988,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3935,7 +3998,8 @@
-
- slot = slot2;
-
-- if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE) {
-+ if (n_consecutive < OS_AIO_MERGE_N_CONSECUTIVE
-+ && n_consecutive < innobase_max_merged_io) {
-
- goto consecutive_loop;
- } else {
-@@ -3955,6 +4019,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -3962,7 +4028,16 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -3973,6 +4048,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -3998,6 +4076,7 @@
-
- /* Do the i/o with ordinary, synchronous i/o functions: */
- if (slot->type == OS_FILE_WRITE) {
-+ os_aio_thread_io_writes[global_segment] += n_consecutive;
- if (array == os_aio_write_array) {
- if ((total_len % UNIV_PAGE_SIZE != 0)
- || (slot->offset % UNIV_PAGE_SIZE != 0)) {
-@@ -4012,16 +4091,34 @@
- os_file_check_page_trailers(combined_buf, total_len);
- }
-
-+ start_usecs = time_usecs();
- ret = os_file_write(slot->name, slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
--
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
- if (array == os_aio_write_array) {
- os_file_check_page_trailers(combined_buf, total_len);
- }
-- } else {
-+ os_aio_write_requests++;
-+ os_aio_pages_written += n_consecutive;
-+ os_aio_write_time += (ib_longlong)elapsed_usecs;
-+ } else {
-+ start_usecs = time_usecs();
-+ os_aio_thread_io_reads[global_segment] += n_consecutive;
- ret = os_file_read(slot->file, combined_buf,
- slot->offset, slot->offset_high, total_len);
-- }
-+ stop_usecs = time_usecs();
-+ elapsed_usecs = stop_usecs - start_usecs;
-+ if (elapsed_usecs < 0) elapsed_usecs = 0;
-+ os_aio_read_requests++;
-+ os_aio_pages_read += n_consecutive;
-+ os_aio_read_time += (ib_longlong)elapsed_usecs;
-+ }
-+ if (elapsed_usecs > os_aio_thread_max_io_wait[global_segment])
-+ os_aio_thread_max_io_wait[global_segment] = elapsed_usecs;
-+ os_aio_thread_io_wait[global_segment] += elapsed_usecs;
-+ os_aio_thread_io_requests[global_segment]++;
-
- ut_a(ret);
- srv_set_io_thread_op_info(global_segment, "file i/o done");
-@@ -4042,16 +4139,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4061,6 +4155,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-@@ -4070,7 +4166,8 @@
- os_mutex_exit(array->mutex);
-
- os_aio_array_free_slot(array, slot);
--
-+ srv_set_io_thread_op_info(global_segment, "exited handler");
-+
- return(ret);
-
- wait_for_io:
-@@ -4115,7 +4212,6 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-@@ -4165,11 +4261,20 @@
- double time_elapsed;
- double avg_bytes_read;
- ulint i;
--
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-- fprintf(file, "I/O thread %lu state: %s (%s)", (ulong) i,
-- srv_io_thread_op_info[i],
-- srv_io_thread_function[i]);
-+ ulint num_issued, num_done, num_claimed;
-+
-+ if (file) {
-+ for (i = 0; i < os_aio_n_segments; i++) {
-+ fprintf(file,
-+ "I/O thread %lu state: %s (%s) reads %lu writes %lu "
-+ "requests %lu io secs %lf io msecs/request %lf max_io_wait %lf",
-+ i, srv_io_thread_op_info[i], srv_io_thread_function[i],
-+ os_aio_thread_io_reads[i], os_aio_thread_io_writes[i],
-+ os_aio_thread_io_requests[i],
-+ os_aio_thread_io_wait[i] / 1000000.0,
-+ os_aio_thread_io_requests[i] ?
-+ os_aio_thread_io_wait[i] / os_aio_thread_io_requests[i] / 1000.0 : 0.0,
-+ os_aio_thread_max_io_wait[i] / 1000.0);
-
- #ifndef __WIN__
- if (os_aio_segment_wait_events[i]->is_set) {
-@@ -4181,6 +4286,7 @@
- }
-
- fputs("Pending normal aio reads:", file);
-+ } // if (file)
-
- array = os_aio_read_array;
- loop:
-@@ -4189,14 +4295,23 @@
- os_mutex_enter(array->mutex);
-
- ut_a(array->n_slots > 0);
-- ut_a(array->n_segments > 0);
-
- n_reserved = 0;
-+ num_done = num_issued = num_claimed = 0;
-
- for (i = 0; i < array->n_slots; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
- if (slot->reserved) {
-+ if (slot->status == OS_AIO_ISSUED)
-+ num_issued++;
-+ else if (slot->status == OS_AIO_DONE)
-+ num_done++;
-+ else {
-+ ut_ad(slot->status == OS_AIO_CLAIMED);
-+ num_claimed++;
-+ }
-+
- n_reserved++;
- /* fprintf(stderr, "Reserved slot, messages %p %p\n",
- slot->message1, slot->message2); */
-@@ -4206,42 +4321,56 @@
-
- ut_a(array->n_reserved == n_reserved);
-
-- fprintf(file, " %lu", (ulong) n_reserved);
--
-+ if (file) fprintf(file, " %lu", (ulong) n_reserved);
-+
- os_mutex_exit(array->mutex);
-
- if (array == os_aio_read_array) {
-- fputs(", aio writes:", file);
--
-+ inno_pending_normal_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", aio writes:", file);
- array = os_aio_write_array;
-
- goto loop;
- }
-
- if (array == os_aio_write_array) {
-- fputs(",\n ibuf aio reads:", file);
-+ inno_pending_normal_aio_writes = (ulong) n_reserved;
-+ if (file) fputs(",\n ibuf aio reads:", file);
- array = os_aio_ibuf_array;
-
- goto loop;
- }
-
- if (array == os_aio_ibuf_array) {
-- fputs(", log i/o's:", file);
-+ inno_pending_ibuf_aio_reads = (ulong) n_reserved;
-+ if (file) fputs(", log i/o's:", file);
- array = os_aio_log_array;
-
- goto loop;
- }
-
- if (array == os_aio_log_array) {
-- fputs(", sync i/o's:", file);
-+ inno_pending_log_ios = (ulong) n_reserved;
-+ if (file) fputs(", sync i/o's:", file);
- array = os_aio_sync_array;
-
- goto loop;
- }
-
-- putc('\n', file);
-+ if (array == os_aio_sync_array) {
-+ inno_pending_sync_ios = (ulong) n_reserved;
-+ }
-+
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time, os_last_printout);
-+
-+ if (file) {
-+ putc('\n', file);
-+ fprintf(file,
-+ "Summary of background IO slot status: %lu issued, "
-+ "%lu done, %lu claimed, sleep set %d\n",
-+ num_issued, num_done, num_claimed,
-+ os_aio_recommend_sleep_for_read_threads);
-
- fprintf(file,
- "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
-@@ -4274,6 +4403,7 @@
- / time_elapsed,
- (os_n_fsyncs - os_n_fsyncs_old)
- / time_elapsed);
-+ } // if (file)
-
- os_n_file_reads_old = os_n_file_reads;
- os_n_file_writes_old = os_n_file_writes;
-diff -r 322370200e6a innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-@@ -164,7 +164,17 @@
- ulint srv_mem_pool_size = ULINT_MAX; /* size in bytes */
- ulint srv_lock_table_size = ULINT_MAX;
-
-+ulint srv_io_capacity = ULINT_MAX; /* Number of IO operations per
-+ second the server can do */
-+
-+ibool srv_extra_dirty_writes = TRUE; /* Write dirty pages to disk when pct
-+ dirty < max dirty pct */
-+
-+/* Deprecated by srv_n_{read,write}_io_threads */
- ulint srv_n_file_io_threads = ULINT_MAX;
-+/* Number of background IO threads for read and write requests */
-+ulint srv_n_read_io_threads = ULINT_MAX;
-+ulint srv_n_write_io_threads = ULINT_MAX;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -238,6 +248,24 @@
-
- /* variable to count the number of random read-aheads */
- ulint srv_read_ahead_rnd = 0;
-+
-+/* Number of IO operations read/write done for all threads */
-+ulint os_aio_read_requests = 0;
-+ulint os_aio_write_requests = 0;
-+
-+/* Number of pages read/written done for all threads */
-+ulint os_aio_pages_read = 0;
-+ulint os_aio_pages_written = 0;
-+
-+/* time usec used to perform read/write for all threads */
-+ib_longlong os_aio_read_time = 0;
-+ib_longlong os_aio_write_time = 0;
-+
-+ulint inno_pending_normal_aio_reads = 0;
-+ulint inno_pending_normal_aio_writes = 0;
-+ulint inno_pending_ibuf_aio_reads = 0;
-+ulint inno_pending_log_ios = 0;
-+ulint inno_pending_sync_ios = 0;
-
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-@@ -413,6 +441,23 @@
-
- ulint srv_main_thread_process_no = 0;
- ulint srv_main_thread_id = 0;
-+
-+// The following count work done by srv_master_thread.
-+
-+// Iterations by the 'once per second' loop.
-+ulint srv_main_1_second_loops = 0;
-+// Calls to sleep by the 'once per second' loop.
-+ulint srv_main_sleeps = 0;
-+// Iterations by the 'once per 10 seconds' loop.
-+ulint srv_main_10_second_loops = 0;
-+// Iterations of the loop bounded by the 'background_loop' label.
-+ulint srv_main_background_loops = 0;
-+// Iterations of the loop bounded by the 'flush_loop' label.
-+ulint srv_main_flush_loops = 0;
-+// Calls to log_buffer_flush_to_disk.
-+ulint srv_sync_flush = 0;
-+// Calls to log_buffer_flush_maybe_sync.
-+ulint srv_async_flush = 0;
-
- /*
- IMPLEMENTATION OF THE SERVER MAIN PROGRAM
-@@ -2170,7 +2215,12 @@
- }
-
- /*************************************************************************
--The master thread controlling the server. */
-+Returns the number of IO operations that is X percent of the capacity.
-+
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity.
-+*/
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-
- #ifndef __WIN__
- void*
-@@ -2199,11 +2249,15 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
- os_thread_pf(os_thread_get_curr_id()));
- #endif
-+ fprintf(stderr, "InnoDB master thread running with io_capacity %lu\n",
-+ srv_io_capacity);
-+
- srv_main_thread_process_no = os_proc_get_number();
- srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
-
-@@ -2275,26 +2329,28 @@
-
- srv_main_thread_op_info = "flushing log";
- log_buffer_flush_to_disk();
-+ srv_sync_flush++;
-
- srv_main_thread_op_info = "making checkpoint";
- log_free_check();
-
-- /* If there were less than 5 i/os during the
-- one second sleep, we assume that there is free
-- disk i/o capacity available, and it makes sense to
-- do an insert buffer merge. */
-+ /* If i/os during one second sleep were less than 5% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to do an insert buffer merge. */
-
- n_pend_ios = buf_get_n_pending_ios()
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2303,7 +2359,8 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2325,36 +2382,47 @@
-
- /* ---- We perform the following code approximately once per
- 10 seconds when there is database activity */
-+ srv_main_10_second_loops++;
-
- #ifdef MEM_PERIODIC_CHECK
- /* Check magic numbers of every allocated mem block once in 10
- seconds */
- mem_validate_all_blocks();
- #endif
-- /* If there were less than 200 i/os during the 10 second period,
-- we assume that there is free disk i/o capacity available, and it
-- makes sense to flush 100 pages. */
-+ /* If i/os during the 10 second period were less than 200% of
-+ capacity, we assume that there is free disk i/o capacity
-+ available, and it makes sense to flush srv_io_capacity pages.
-+
-+ Note that this is done regardless of the fraction of dirty
-+ pages relative to the max requested by the user. The one second
-+ loop above requests writes for that case. The writes done here
-+ are not required, and may be disabled. */
-
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (srv_extra_dirty_writes &&
-+ n_pend_ios < PCT_IO(3) && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2378,8 +2446,9 @@
- if (difftime(current_time, last_flush_time) > 1) {
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2393,14 +2462,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2434,7 +2503,7 @@
-
- /* The server has been quiet for a while: start running background
- operations */
--
-+ srv_main_background_loops++;
- srv_main_thread_op_info = "doing background drop tables";
-
- n_tables_to_drop = row_drop_tables_for_mysql_in_background();
-@@ -2472,6 +2541,7 @@
-
- log_buffer_flush_to_disk();
- last_flush_time = current_time;
-+ srv_sync_flush++;
- }
- }
-
-@@ -2487,9 +2557,13 @@
- srv_main_thread_op_info = "doing insert buffer merge";
-
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
-- n_bytes_merged = 0;
-+ n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ /* This should do an amount of IO similar to the number of
-+ * dirty pages that will be flushed in the call to
-+ * buf_flush_batch below. Otherwise, the system favors
-+ * clean pages over cleanup throughput. */
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2503,10 +2577,11 @@
-
- flush_loop:
- srv_main_thread_op_info = "flushing buffer pool pages";
-+ srv_main_flush_loops++;
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2528,7 +2603,17 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ srv_main_thread_op_info = (char*) "flushing log";
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ srv_sync_flush++;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ srv_async_flush++;
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -r 322370200e6a innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Mon Nov 03 05:07:57 2008 -0800
-+++ b/innobase/srv/srv0start.c Mon Nov 03 05:08:52 2008 -0800
-@@ -973,6 +973,7 @@
- ulint i;
- ibool srv_file_per_table_original_value = srv_file_per_table;
- mtr_t mtr;
-+ ulint n_threads;
- #ifdef HAVE_DARWIN_THREADS
- # ifdef F_FULLFSYNC
- /* This executable has been compiled on Mac OS X 10.3 or later.
-@@ -1206,24 +1207,32 @@
- }
-
- /* Restrict the maximum number of file i/o threads */
-- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
--
-- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ if ((srv_n_read_io_threads + srv_n_write_io_threads) > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many read(%d) or write(%d) IO threads, max is %d\n",
-+ srv_n_read_io_threads, srv_n_write_io_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- if (!os_aio_use_native_aio) {
-- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /* More than 4 threads are now supported. */
-+ n_threads = os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ } else {
-+ /* Might need more slots here. Alas, I don't do windows. */
-+ n_threads = os_aio_init(SRV_N_PENDING_IOS_PER_THREAD,
-+ srv_n_read_io_threads,
-+ srv_n_write_io_threads,
-+ SRV_MAX_N_PENDING_SYNC_IOS);
-+ }
-
-- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-- } else {
-- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
-- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-- SRV_MAX_N_PENDING_SYNC_IOS);
-+ if (n_threads > SRV_MAX_N_IO_THREADS) {
-+ fprintf(stderr,
-+ "InnoDB: requested too many IO threads(%d), max is %d\n",
-+ n_threads, SRV_MAX_N_IO_THREADS);
-+ return(DB_ERROR);
- }
-
- fil_init(srv_max_n_open_files);
-@@ -1259,11 +1268,11 @@
-
- /* Create i/o-handler threads: */
-
-- for (i = 0; i < srv_n_file_io_threads; i++) {
-+ for (i = 0; i < n_threads; i++) {
- n[i] = i;
-
- os_thread_create(io_handler_thread, n + i, thread_ids + i);
-- }
-+ }
-
- #ifdef UNIV_LOG_ARCHIVE
- if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
-diff -r 322370200e6a patch_info/innodb_io_tune.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_tune.info Mon Nov 03 05:08:52 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_io_tune.patch
-+Name=Tune InnoDB IO settings
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
-diff -r 322370200e6a sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -147,7 +147,7 @@
- innobase_additional_mem_pool_size, innobase_file_io_threads,
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
--
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -175,6 +175,23 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+
-+/* Max number of IO requests merged to perform large IO in background
-+ IO threads.
-+*/
-+long innobase_max_merged_io = 64;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+long innobase_min_status_update_time_interval = 30;
-+
-+
-+/* Default number of IO per second supported by server. Tunes background
-+ IO rate
-+*/
-+long innobase_io_capacity = 100;
-+
-+/* Write dirty pages when pct dirty is less than max pct dirty */
-+my_bool innobase_extra_dirty_writes = TRUE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1372,7 +1389,11 @@
-
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
-+ srv_io_capacity = (ulint) innobase_io_capacity;
-+ srv_extra_dirty_writes = (ibool) innobase_extra_dirty_writes;
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-diff -r 322370200e6a sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-@@ -197,6 +197,7 @@
-
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
-+extern long innobase_max_merged_io;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -205,10 +206,14 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_force_recovery;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
- extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
- extern char *innobase_unix_file_flush_method;
-+extern long innobase_io_capacity;
-+extern my_bool innobase_extra_dirty_writes;
-+
- /* The following variables have to be my_bool for SHOW VARIABLES to work */
- extern my_bool innobase_log_archive,
- innobase_use_doublewrite,
-diff -r 322370200e6a sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -4932,6 +4932,11 @@
- OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_MAX_MERGED_IO,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_EXTRA_DIRTY_WRITES,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
-@@ -5302,6 +5307,25 @@
- (gptr*) &global_system_variables.innodb_table_locks,
- (gptr*) &global_system_variables.innodb_table_locks,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_max_merged_io", OPT_INNODB_MAX_MERGED_IO,
-+ "Max number of IO requests merged to issue large IO from background IO threads.",
-+ (gptr*) &innobase_max_merged_io,
-+ (gptr*) &innobase_max_merged_io, 0, GET_LONG, REQUIRED_ARG, 64, 1, 64, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.", (gptr*) &innobase_read_io_threads,
-+ (gptr*) &innobase_read_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.", (gptr*) &innobase_write_io_threads,
-+ (gptr*) &innobase_write_io_threads, 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 1, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &innobase_io_capacity,
-+ (gptr*) &innobase_io_capacity, 0, GET_LONG,
-+ REQUIRED_ARG, 100, 100, 999999999, 0, 1, 0},
-+ {"innodb_extra_dirty_writes", OPT_INNODB_EXTRA_DIRTY_WRITES,
-+ "When set, flush dirty buffer pages when dirty pct is less than max dirty pct. ",
-+ (gptr*) &innobase_extra_dirty_writes, (gptr*) &innobase_extra_dirty_writes,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r 322370200e6a sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:07:57 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-@@ -919,12 +919,14 @@
- {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
- {"innodb_adaptive_hash_index", (char*) &innobase_adaptive_hash_index, SHOW_MY_BOOL},
- {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
-+ {"innodb_extra_dirty_writes", (char*) &innobase_extra_dirty_writes, SHOW_MY_BOOL},
- {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
-+ {"innodb_io_capacity", (char*) &innobase_io_capacity, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
- {"innodb_locks_unsafe_for_binlog", (char*) &innobase_locks_unsafe_for_binlog, SHOW_MY_BOOL},
- {"innodb_log_arch_dir", (char*) &innobase_log_arch_dir, SHOW_CHAR_PTR},
-@@ -943,6 +945,9 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
-+ {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/innodb_locks_held.patch b/percona/5.0.87-b20-20091116/innodb_locks_held.patch
deleted file mode 100644
index 062fa47..0000000
--- a/percona/5.0.87-b20-20091116/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1711,24 +1713,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1822,6 +1806,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r e9fb5b8bcf78 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -825,6 +825,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -942,6 +944,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r e9fb5b8bcf78 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
-@@ -243,6 +243,8 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-diff -r e9fb5b8bcf78 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -5016,6 +5016,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5364,6 +5366,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r e9fb5b8bcf78 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -527,6 +527,12 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -906,6 +912,8 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1023,6 +1031,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.87-b20-20091116/innodb_misc_patch.patch b/percona/5.0.87-b20-20091116/innodb_misc_patch.patch
deleted file mode 100644
index 4f4faf3..0000000
--- a/percona/5.0.87-b20-20091116/innodb_misc_patch.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-diff -ru mysql-5.0.84_p_orig/innobase/row/row0sel.c mysql-5.0.84/innobase/row/row0sel.c
---- mysql-5.0.84_p_orig/innobase/row/row0sel.c 2009-07-07 21:54:10.000000000 +0900
-+++ mysql-5.0.84/innobase/row/row0sel.c 2009-08-28 09:28:56.000000000 +0900
-@@ -2988,6 +2988,15 @@
- return(SEL_FOUND);
- }
-
-+/**********************************************************************
-+Returns true if the thread is executing a SELECT statement.
-+(Prototype for global functions in ha_innodb.cc) */
-+ibool
-+thd_is_select(
-+/*==========*/
-+ /* out: true if thd is executing SELECT */
-+ const void* thd); /* in: thread handle (THD*) */
-+
- /************************************************************************
- Searches for rows in the database. This is used in the interface to
- MySQL. This function opens a cursor, and also implements fetch next
-@@ -3361,20 +3370,12 @@
-
- if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
- && prebuilt->select_lock_type != LOCK_NONE
-- && trx->mysql_query_str) {
--
-- /* Scan the MySQL query string; check if SELECT is the first
-- word there */
-- ibool success;
--
-- dict_accept(*trx->mysql_query_str, "SELECT", &success);
--
-- if (success) {
-+ && trx->mysql_thd != NULL
-+ && thd_is_select(trx->mysql_thd)) {
- /* It is a plain locking SELECT and the isolation
- level is low: do not lock gaps */
-
- set_also_gap_locks = FALSE;
-- }
- }
-
- /* Note that if the search mode was GE or G, then the cursor
-diff -ru mysql-5.0.84_p_orig/sql/ha_innodb.cc mysql-5.0.84/sql/ha_innodb.cc
---- mysql-5.0.84_p_orig/sql/ha_innodb.cc 2009-08-27 16:06:21.000000000 +0900
-+++ mysql-5.0.84/sql/ha_innodb.cc 2009-08-28 09:33:38.000000000 +0900
-@@ -394,6 +394,18 @@
- }
- }
-
-+/**********************************************************************
-+Returns true if the thread is executing a SELECT statement. */
-+extern "C"
-+ibool
-+thd_is_select(
-+/*==========*/
-+ /* out: true if thd is executing SELECT */
-+ const void* thd) /* in: thread handle (THD*) */
-+{
-+ return(((const THD*) thd)->lex->sql_command == SQLCOM_SELECT);
-+}
-+
- /************************************************************************
- Call this function when mysqld passes control to the client. That is to
- avoid deadlocks on the adaptive hash S-latch possibly held by thd. For more
diff --git a/percona/5.0.87-b20-20091116/innodb_recovery_patches.patch b/percona/5.0.87-b20-20091116/innodb_recovery_patches.patch
deleted file mode 100644
index 3d3e567..0000000
--- a/percona/5.0.87-b20-20091116/innodb_recovery_patches.patch
+++ /dev/null
@@ -1,217 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-08-04 17:02:36.000000000 +0900
-@@ -85,6 +85,22 @@
- prev_b = NULL;
- b = UT_LIST_GET_FIRST(buf_pool->flush_list);
-
-+ if (srv_fast_recovery) {
-+ /* speed hack */
-+ if (b == NULL || (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0)) {
-+ UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
-+ } else {
-+ b = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ if (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0) {
-+ /* align oldest_modification not to sort */
-+ block->oldest_modification = b->oldest_modification;
-+ }
-+ UT_LIST_ADD_LAST(flush_list, buf_pool->flush_list, block);
-+ }
-+ } else {
-+ /* normal */
- while (b && (ut_dulint_cmp(b->oldest_modification,
- block->oldest_modification) > 0)) {
- prev_b = b;
-@@ -97,6 +113,7 @@
- UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b,
- block);
- }
-+ }
-
- ut_ad(buf_flush_validate_low());
- }
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-08-04 17:11:41.000000000 +0900
-@@ -127,6 +127,46 @@
- block = buf_page_init_for_read(err, mode, space, tablespace_version,
- offset);
- if (block == NULL) {
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=43948 */
-+ if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
-+ /* hashed log recs must be treated here */
-+ recv_addr_t* recv_addr;
-+
-+ mutex_enter(&(recv_sys->mutex));
-+
-+ if (recv_sys->apply_log_recs == FALSE) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ /* recv_get_fil_addr_struct() */
-+ recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
-+ hash_calc_hash(ut_fold_ulint_pair(space, offset),
-+ recv_sys->addr_hash));
-+ while (recv_addr) {
-+ if ((recv_addr->space == space)
-+ && (recv_addr->page_no == offset)) {
-+ break;
-+ }
-+ recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
-+ }
-+
-+ if ((recv_addr == NULL)
-+ || (recv_addr->state == RECV_BEING_PROCESSED)
-+ || (recv_addr->state == RECV_PROCESSED)) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ fprintf(stderr, " (space:%lu is deleted)", space);
-+ recv_addr->state = RECV_PROCESSED;
-+
-+ ut_a(recv_sys->n_addrs);
-+ recv_sys->n_addrs--;
-+
-+ mutex_exit(&(recv_sys->mutex));
-+ }
-+not_to_recover:
-
- return(0);
- }
-@@ -697,11 +737,11 @@
- while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
-
- os_aio_simulated_wake_handler_threads();
-- os_thread_sleep(500000);
-+ os_thread_sleep(10000);
-
- count++;
-
-- if (count > 100) {
-+ if (count > 5000) {
- fprintf(stderr,
- "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
- "InnoDB: reads to the buffer pool to be finished.\n"
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-08-04 17:39:51.000000000 +0900
-@@ -59,6 +59,8 @@
- extern ibool srv_file_per_table;
- extern ibool srv_locks_unsafe_for_binlog;
-
-+extern ibool srv_fast_recovery;
-+
- extern ulint srv_n_data_files;
- extern char** srv_data_file_names;
- extern ulint* srv_data_file_sizes;
-diff -ruN a/innobase/log/log0recv.c b/innobase/log/log0recv.c
---- a/innobase/log/log0recv.c 2009-07-07 21:54:08.000000000 +0900
-+++ b/innobase/log/log0recv.c 2009-08-04 17:15:15.000000000 +0900
-@@ -101,7 +101,7 @@
- use these free frames to read in pages when we start applying the
- log records to the database. */
-
--ulint recv_n_pool_free_frames = 256;
-+ulint recv_n_pool_free_frames = 1024;
-
- /* The maximum lsn we see for a page during the recovery process. If this
- is bigger than the lsn we are able to scan up to, that is an indication that
-@@ -1135,6 +1135,8 @@
- recv_addr = recv_get_fil_addr_struct(space, page_no);
-
- if ((recv_addr == NULL)
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=44140 */
-+ || (recv_addr->state == RECV_BEING_READ && !just_read_in)
- || (recv_addr->state == RECV_BEING_PROCESSED)
- || (recv_addr->state == RECV_PROCESSED)) {
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-04 17:41:05.000000000 +0900
-@@ -88,6 +88,8 @@
- i.e. do not use next-key locking
- except on duplicate key checking and
- foreign key checking */
-+ibool srv_fast_recovery = FALSE;
-+
- ulint srv_n_data_files = 0;
- char** srv_data_file_names = NULL;
- ulint* srv_data_file_sizes = NULL; /* size in database pages */
-diff -ruN a/patch_info/innodb_recovery_patches.info b/patch_info/innodb_recovery_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_recovery_patches.info 2009-08-04 16:58:07.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_recovery_patches.patch
-+Name=Bugfixes and adjustments about recovery process
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-04 17:35:44.000000000 +0900
-@@ -182,6 +182,7 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+my_bool innobase_fast_recovery = FALSE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1534,6 +1535,8 @@
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-+ srv_fast_recovery = (ibool) innobase_fast_recovery;
-+
- srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
- srv_use_checksums = (ibool) innobase_use_checksums;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-08-04 17:37:18.000000000 +0900
-@@ -220,6 +220,7 @@
- innobase_use_large_pages,
- innobase_use_native_aio,
- innobase_file_per_table, innobase_locks_unsafe_for_binlog,
-+ innobase_fast_recovery,
- innobase_rollback_on_timeout,
- innobase_create_status_file,
- innobase_adaptive_hash_index;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/mysqld.cc 2009-08-04 17:48:25.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_USE_SYS_MALLOC,
-+ OPT_INNODB_FAST_RECOVERY,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5347,6 +5348,10 @@
- {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \
- Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
- (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_fast_recovery", OPT_INNODB_FAST_RECOVERY,
-+ "Enable to use speed hack of recovery avoiding flush list sorting.",
-+ (gptr*) &innobase_fast_recovery, (gptr*) &innobase_fast_recovery,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
- "Speeds up the shutdown process of the InnoDB storage engine. Possible "
- "values are 0, 1 (faster)"
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/set_var.cc 2009-08-04 17:51:49.000000000 +0900
-@@ -1088,6 +1088,7 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
-+ {"innodb_fast_recovery", (char*) &innobase_fast_recovery, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/innodb_rw_lock.patch b/percona/5.0.87-b20-20091116/innodb_rw_lock.patch
deleted file mode 100644
index a509f70..0000000
--- a/percona/5.0.87-b20-20091116/innodb_rw_lock.patch
+++ /dev/null
@@ -1,2480 +0,0 @@
-diff -ruN a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/btr/btr0cur.c 2009-10-22 15:18:44.000000000 +0900
-@@ -313,7 +313,7 @@
- #ifdef UNIV_SEARCH_PERF_STAT
- info->n_searches++;
- #endif
-- if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
-+ if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED
- && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
- && !estimate
- #ifdef PAGE_CUR_LE_OR_EXTENDS
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-10-22 15:18:44.000000000 +0900
-@@ -773,8 +773,8 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-- ut_ad(btr_search_latch.reader_count > 0);
-+ ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
-+ ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-
-diff -ruN a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/buf/buf0buf.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1292,7 +1292,7 @@
-
- if (mode == BUF_GET_NOWAIT) {
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-@@ -1442,7 +1442,7 @@
- ut_ad(!ibuf_inside() || ibuf_page(block->space, block->offset));
-
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-@@ -1596,7 +1596,7 @@
- ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
-
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-diff -ruN a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/include/buf0buf.ic 2009-10-22 16:12:25.000000000 +0900
-@@ -523,7 +523,7 @@
- #ifdef UNIV_SYNC_DEBUG
- ibool ret;
-
-- ret = rw_lock_s_lock_func_nowait(&(block->debug_latch), file, line);
-+ ret = rw_lock_s_lock_nowait(&(block->debug_latch), file, line);
-
- ut_ad(ret == TRUE);
- ut_ad(mutex_own(&block->mutex));
-diff -ruN a/innobase/include/os0sync.h b/innobase/include/os0sync.h
---- a/innobase/include/os0sync.h 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/os0sync.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,11 +1,35 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The interface to the operating system
- synchronization primitives.
-
--(c) 1995 Innobase Oy
--
- Created 9/6/1995 Heikki Tuuri
- *******************************************************/
-+
- #ifndef os0sync_h
- #define os0sync_h
-
-@@ -261,6 +285,23 @@
- /*===============*/
- os_fast_mutex_t* fast_mutex); /* in: mutex to free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/**************************************************************
-+Atomic compare-and-swap for InnoDB. Currently requires GCC atomic builtins.
-+Returns true if swapped, ptr is pointer to target, old_val is value to
-+compare to, new_val is the value to swap in. */
-+#define os_compare_and_swap(ptr, old_val, new_val) \
-+ __sync_bool_compare_and_swap(ptr, old_val, new_val)
-+
-+/**************************************************************
-+Atomic increment for InnoDB. Currently requires GCC atomic builtins.
-+Returns the resulting value, ptr is pointer to target, amount is the
-+amount of increment. */
-+#define os_atomic_increment(ptr, amount) \
-+ __sync_add_and_fetch(ptr, amount)
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
- #ifndef UNIV_NONINL
- #include "os0sync.ic"
- #endif
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for threads, not for database transactions)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -24,6 +47,12 @@
- #define RW_X_LATCH 2
- #define RW_NO_LATCH 3
-
-+/* We decrement lock_word by this amount for each x_lock. It is also the
-+start value for the lock_word, meaning that it limits the maximum number
-+of concurrent read locks before the rw_lock breaks. The current value of
-+0x00100000 allows 1,048,575 concurrent readers and 2047 recursive writers.*/
-+#define X_LOCK_DECR 0x00100000
-+
- typedef struct rw_lock_struct rw_lock_t;
- #ifdef UNIV_SYNC_DEBUG
- typedef struct rw_lock_debug_struct rw_lock_debug_t;
-@@ -47,14 +76,14 @@
- there may be waiters for the event */
- #endif /* UNIV_SYNC_DEBUG */
-
--extern ulint rw_s_system_call_count;
--extern ulint rw_s_spin_wait_count;
--extern ulint rw_s_exit_count;
--extern ulint rw_s_os_wait_count;
--extern ulint rw_x_system_call_count;
--extern ulint rw_x_spin_wait_count;
--extern ulint rw_x_os_wait_count;
--extern ulint rw_x_exit_count;
-+extern ib_longlong rw_s_spin_wait_count;
-+extern ib_longlong rw_s_spin_round_count;
-+extern ib_longlong rw_s_exit_count;
-+extern ib_longlong rw_s_os_wait_count;
-+extern ib_longlong rw_x_spin_wait_count;
-+extern ib_longlong rw_x_spin_round_count;
-+extern ib_longlong rw_x_os_wait_count;
-+extern ib_longlong rw_x_exit_count;
-
- /**********************************************************************
- Creates, or rather, initializes an rw-lock object in a specified memory
-@@ -116,8 +145,22 @@
- NOTE! The following macros should be used in rw s-locking, not the
- corresponding function. */
-
--#define rw_lock_s_lock_nowait(M) rw_lock_s_lock_func_nowait(\
-- (M), __FILE__, __LINE__)
-+#define rw_lock_s_lock_nowait(M, F, L) rw_lock_s_lock_low(\
-+ (M), 0, (F), (L))
-+/**********************************************************************
-+Low-level function which tries to lock an rw-lock in s-mode. Performs no
-+spinning. */
-+UNIV_INLINE
-+ibool
-+rw_lock_s_lock_low(
-+/*===============*/
-+ /* out: TRUE if success */
-+ rw_lock_t* lock, /* in: pointer to rw-lock */
-+ ulint pass __attribute__((unused)),
-+ /* in: pass value; != 0, if the lock will be
-+ passed to another thread to unlock */
-+ const char* file_name, /* in: file name where lock requested */
-+ ulint line); /* in: line where requested */
- /**********************************************************************
- NOTE! Use the corresponding macro, not directly this function, except if
- you supply the file name and line number. Lock an rw-lock in shared mode
-@@ -135,18 +178,6 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line); /* in: line where requested */
- /**********************************************************************
--NOTE! Use the corresponding macro, not directly this function, except if
--you supply the file name and line number. Lock an rw-lock in shared mode
--for the current thread if the lock can be acquired immediately. */
--UNIV_INLINE
--ibool
--rw_lock_s_lock_func_nowait(
--/*=======================*/
-- /* out: TRUE if success */
-- rw_lock_t* lock, /* in: pointer to rw-lock */
-- const char* file_name,/* in: file name where lock requested */
-- ulint line); /* in: line where requested */
--/**********************************************************************
- NOTE! Use the corresponding macro, not directly this function! Lock an
- rw-lock in exclusive mode for the current thread if the lock can be
- obtained immediately. */
-@@ -338,6 +369,41 @@
- rw_lock_get_reader_count(
- /*=====================*/
- rw_lock_t* lock);
-+/**********************************************************************
-+Decrements lock_word the specified amount if it is greater than 0.
-+This is used by both s_lock and x_lock operations. */
-+UNIV_INLINE
-+ibool
-+rw_lock_lock_word_decr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount); /* in: amount to decrement */
-+/**********************************************************************
-+Increments lock_word the specified amount and returns new value. */
-+UNIV_INLINE
-+lint
-+rw_lock_lock_word_incr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock,
-+ ulint amount); /* in: rw-lock */
-+/**********************************************************************
-+This function sets the lock->writer_thread and lock->recursive fields.
-+For platforms where we are using atomic builtins instead of lock->mutex
-+it sets the lock->writer_thread field using atomics to ensure memory
-+ordering. Note that it is assumed that the caller of this function
-+effectively owns the lock i.e.: nobody else is allowed to modify
-+lock->writer_thread at this point in time.
-+The protocol is that lock->writer_thread MUST be updated BEFORE the
-+lock->recursive flag is set. */
-+UNIV_INLINE
-+void
-+rw_lock_set_writer_id_and_recursion_flag(
-+/*=====================================*/
-+ rw_lock_t* lock, /* in/out: lock to work on */
-+ ibool recursive); /* in: TRUE if recursion
-+ allowed */
- #ifdef UNIV_SYNC_DEBUG
- /**********************************************************************
- Checks if the thread has locked the rw-lock in the specified mode, with
-@@ -417,47 +483,33 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-+ volatile lint lock_word;
-+ /* Holds the state of the lock. */
-+ volatile ulint waiters;/* 1: there are waiters */
-+ volatile ibool recursive;/* Default value FALSE which means the lock
-+ is non-recursive. The value is typically set
-+ to TRUE making normal rw_locks recursive. In
-+ case of asynchronous IO, when a non-zero
-+ value of 'pass' is passed then we keep the
-+ lock non-recursive.
-+ This flag also tells us about the state of
-+ writer_thread field. If this flag is set
-+ then writer_thread MUST contain the thread
-+ id of the current x-holder or wait-x thread.
-+ This flag must be reset in x_unlock
-+ functions before incrementing the lock_word */
-+ volatile os_thread_id_t writer_thread;
-+ /* Thread id of writer thread. Is only
-+ guaranteed to have sane and non-stale
-+ value iff recursive flag is set. */
- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-- os_event_t wait_ex_event; /* This windows specific event is
-- used by the thread which has set the
-- lock state to RW_LOCK_WAIT_EX. The
-- rw_lock design guarantees that this
-- thread will be the next one to proceed
-- once the current the event gets
-- signalled. See LEMMA 2 in sync0sync.c */
--#endif
--
-- ulint reader_count; /* Number of readers who have locked this
-- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-- is a writer owning the lock (in exclusive
-- mode), RW_LOCK_WAIT_EX if a writer is
-- queueing for the lock, and
-- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-- recursively locked the lock in the exclusive
-- mode */
-+ os_event_t wait_ex_event;
-+ /* Event for next-writer to wait on. A thread
-+ must decrement lock_word before waiting. */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-- ulint pass; /* Default value 0. This is set to some
-- value != 0 given by the caller of an x-lock
-- operation, if the x-lock is to be passed to
-- another thread to unlock (which happens in
-- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-- /* This is TRUE if the writer field is
-- RW_LOCK_WAIT_EX; this field is located far
-- from the memory update hotspot fields which
-- are at the start of this struct, thus we can
-- peek this field without causing much memory
-- bus traffic */
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
- UT_LIST_NODE_T(rw_lock_t) list;
- /* All allocated rw locks are put into a
- list */
-@@ -465,15 +517,23 @@
- UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list;
- /* In the debug version: pointer to the debug
- info list of the lock */
-+ ulint level; /* Level in the global latching order. */
- #endif /* UNIV_SYNC_DEBUG */
-- ulint level; /* Level in the global latching
-- order; default SYNC_LEVEL_NONE */
-+ ulint count_os_wait; /* Count of os_waits. May not be accurate */
- const char* cfile_name;/* File name where lock created */
-- ulint cline; /* Line where created */
-+ /* last s-lock file/line is not guaranteed to be correct */
- const char* last_s_file_name;/* File name where last s-locked */
- const char* last_x_file_name;/* File name where last x-locked */
-- ulint last_s_line; /* Line number where last time s-locked */
-- ulint last_x_line; /* Line number where last time x-locked */
-+ ibool writer_is_wait_ex;
-+ /* This is TRUE if the writer field is
-+ RW_LOCK_WAIT_EX; this field is located far
-+ from the memory update hotspot fields which
-+ are at the start of this struct, thus we can
-+ peek this field without causing much memory
-+ bus traffic */
-+ unsigned cline:14; /* Line where created */
-+ unsigned last_s_line:14; /* Line number where last time s-locked */
-+ unsigned last_x_line:14; /* Line number where last time x-locked */
- ulint magic_n;
- };
-
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for threads)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -49,53 +72,88 @@
- ulint
- rw_lock_get_waiters(
- /*================*/
-- rw_lock_t* lock)
-+ /* out: 1 if waiters, 0 otherwise */
-+ rw_lock_t* lock) /* in: rw-lock */
- {
- return(lock->waiters);
- }
-+
-+/************************************************************************
-+Sets lock->waiters to 1. It is not an error if lock->waiters is already
-+1. On platforms where ATOMIC builtins are used this function enforces a
-+memory barrier. */
- UNIV_INLINE
- void
--rw_lock_set_waiters(
--/*================*/
-- rw_lock_t* lock,
-- ulint flag)
-+rw_lock_set_waiter_flag(
-+/*====================*/
-+ rw_lock_t* lock) /* in: rw-lock */
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_compare_and_swap(&lock->waiters, 0, 1);
-+#else /* HAVE_ATOMIC_BUILTINS */
-+ lock->waiters = 1;
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-+
-+/************************************************************************
-+Resets lock->waiters to 0. It is not an error if lock->waiters is already
-+0. On platforms where ATOMIC builtins are used this function enforces a
-+memory barrier. */
- UNIV_INLINE
--ulint
--rw_lock_get_writer(
--/*===============*/
-- rw_lock_t* lock)
-+void
-+rw_lock_reset_waiter_flag(
-+/*======================*/
-+ rw_lock_t* lock) /* in: rw-lock */
- {
-- return(lock->writer);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_compare_and_swap(&lock->waiters, 1, 0);
-+#else /* HAVE_ATOMIC_BUILTINS */
-+ lock->waiters = 0;
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-+
-+/**********************************************************************
-+Returns the write-status of the lock - this function made more sense
-+with the old rw_lock implementation. */
- UNIV_INLINE
--void
--rw_lock_set_writer(
-+ulint
-+rw_lock_get_writer(
- /*===============*/
-- rw_lock_t* lock,
-- ulint flag)
-+ rw_lock_t* lock)
- {
-- lock->writer = flag;
-+ lint lock_word = lock->lock_word;
-+ if(lock_word > 0) {
-+ /* return NOT_LOCKED in s-lock state, like the writer
-+ member of the old lock implementation. */
-+ return(RW_LOCK_NOT_LOCKED);
-+ } else if (((-lock_word) % X_LOCK_DECR) == 0) {
-+ return(RW_LOCK_EX);
-+ } else {
-+ ut_ad(lock_word > -X_LOCK_DECR);
-+ return(RW_LOCK_WAIT_EX);
-+ }
- }
-+
-+/**********************************************************************
-+Returns number of readers. */
- UNIV_INLINE
- ulint
- rw_lock_get_reader_count(
- /*=====================*/
- rw_lock_t* lock)
- {
-- return(lock->reader_count);
--}
--UNIV_INLINE
--void
--rw_lock_set_reader_count(
--/*=====================*/
-- rw_lock_t* lock,
-- ulint count)
--{
-- lock->reader_count = count;
-+ lint lock_word = lock->lock_word;
-+ if(lock_word > 0) {
-+ /* s-locked, no x-waiters */
-+ return(X_LOCK_DECR - lock_word);
-+ } else if (lock_word < 0 && lock_word > -X_LOCK_DECR) {
-+ /* s-locked, with x-waiters */
-+ return((ulint)(-lock_word));
-+ }
-+ return(0);
- }
-+
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +162,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -115,7 +174,126 @@
- /* out: value of writer_count */
- rw_lock_t* lock) /* in: rw-lock */
- {
-- return(lock->writer_count);
-+ lint lock_copy = lock->lock_word;
-+ /* If there is a reader, lock_word is not divisible by X_LOCK_DECR */
-+ if(lock_copy > 0 || (-lock_copy) % X_LOCK_DECR != 0) {
-+ return(0);
-+ }
-+ return(((-lock_copy) / X_LOCK_DECR) + 1);
-+}
-+
-+/**********************************************************************
-+Two different implementations for decrementing the lock_word of a rw_lock:
-+one for systems supporting atomic operations, one for others. This does
-+does not support recusive x-locks: they should be handled by the caller and
-+need not be atomic since they are performed by the current lock holder.
-+Returns true if the decrement was made, false if not. */
-+UNIV_INLINE
-+ibool
-+rw_lock_lock_word_decr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount) /* in: amount of decrement */
-+{
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+
-+ lint local_lock_word = lock->lock_word;
-+ while (local_lock_word > 0) {
-+ if(os_compare_and_swap(&(lock->lock_word),
-+ local_lock_word,
-+ local_lock_word - amount)) {
-+ return(TRUE);
-+ }
-+ local_lock_word = lock->lock_word;
-+ }
-+ return(FALSE);
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ ibool success = FALSE;
-+ mutex_enter(&(lock->mutex));
-+ if(lock->lock_word > 0) {
-+ lock->lock_word -= amount;
-+ success = TRUE;
-+ }
-+ mutex_exit(&(lock->mutex));
-+ return(success);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+}
-+
-+/**********************************************************************
-+Two different implementations for incrementing the lock_word of a rw_lock:
-+one for systems supporting atomic operations, one for others.
-+Returns the value of lock_word after increment. */
-+UNIV_INLINE
-+lint
-+rw_lock_lock_word_incr(
-+/*===================*/
-+ /* out: lock->lock_word after increment */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount) /* in: amount of increment */
-+{
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+
-+ return(os_atomic_increment(&(lock->lock_word), amount));
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ lint local_lock_word;
-+
-+ mutex_enter(&(lock->mutex));
-+
-+ lock->lock_word += amount;
-+ local_lock_word = lock->lock_word;
-+
-+ mutex_exit(&(lock->mutex));
-+
-+ return(local_lock_word);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+}
-+
-+/**********************************************************************
-+This function sets the lock->writer_thread and lock->recursive fields.
-+For platforms where we are using atomic builtins instead of lock->mutex
-+it sets the lock->writer_thread field using atomics to ensure memory
-+ordering. Note that it is assumed that the caller of this function
-+effectively owns the lock i.e.: nobody else is allowed to modify
-+lock->writer_thread at this point in time.
-+The protocol is that lock->writer_thread MUST be updated BEFORE the
-+lock->recursive flag is set. */
-+UNIV_INLINE
-+void
-+rw_lock_set_writer_id_and_recursion_flag(
-+/*=====================================*/
-+ rw_lock_t* lock, /* in/out: lock to work on */
-+ ibool recursive) /* in: TRUE if recursion
-+ allowed */
-+{
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t local_thread;
-+ ibool success;
-+
-+ local_thread = lock->writer_thread;
-+ success = os_compare_and_swap(&lock->writer_thread,
-+ local_thread, curr_thread);
-+ ut_a(success);
-+ lock->recursive = recursive;
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ mutex_enter(&lock->mutex);
-+ lock->writer_thread = curr_thread;
-+ lock->recursive = recursive;
-+ mutex_exit(&lock->mutex);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-
- /**********************************************************************
-@@ -133,26 +311,21 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
--#endif /* UNIV_SYNC_DEBUG */
-- /* Check if the writer field is free */
--
-- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
-+ if (!rw_lock_lock_word_decr(lock, 1)) {
-+ /* Locking did not succeed */
-+ return(FALSE);
-+ }
-
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-- line);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, line);
- #endif
-- lock->last_s_file_name = file_name;
-- lock->last_s_line = line;
--
-- return(TRUE); /* locking succeeded */
-- }
-+ /* These debugging values are not set safely: they may be incorrect
-+ or even refer to a line that is invalid for the file name. */
-+ lock->last_s_file_name = file_name;
-+ lock->last_s_line = line;
-
-- return(FALSE); /* locking did not succeed */
-+ return(TRUE); /* locking succeeded */
- }
-
- /**********************************************************************
-@@ -167,11 +340,10 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-- ut_ad(rw_lock_get_reader_count(lock) == 0);
-+ ut_ad(lock->lock_word == X_LOCK_DECR);
-
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ /* Indicate there is a new reader by decrementing lock_word */
-+ lock->lock_word--;
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -194,13 +366,11 @@
- ulint line) /* in: line where lock requested */
- {
- ut_ad(rw_lock_validate(lock));
-- ut_ad(rw_lock_get_reader_count(lock) == 0);
-- ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-+ ut_ad(lock->lock_word == X_LOCK_DECR);
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-+ lock->lock_word -= X_LOCK_DECR;
- lock->writer_thread = os_thread_get_curr_id();
-- lock->writer_count++;
-- lock->pass = 0;
-+ lock->recursive = TRUE;
-
- lock->last_x_file_name = file_name;
- lock->last_x_line = line;
-@@ -241,15 +411,12 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
-+ if (rw_lock_s_lock_low(lock, pass, file_name, line)) {
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-- mutex_exit(rw_lock_get_mutex(lock));
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -259,86 +426,60 @@
-
- /**********************************************************************
- NOTE! Use the corresponding macro, not directly this function! Lock an
--rw-lock in shared mode for the current thread if the lock can be acquired
--immediately. */
-+rw-lock in exclusive mode for the current thread if the lock can be
-+obtained immediately. */
- UNIV_INLINE
- ibool
--rw_lock_s_lock_func_nowait(
-+rw_lock_x_lock_func_nowait(
- /*=======================*/
- /* out: TRUE if success */
- rw_lock_t* lock, /* in: pointer to rw-lock */
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-- ibool success = FALSE;
--
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- if (lock->writer == RW_LOCK_NOT_LOCKED) {
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-
--#ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-- line);
--#endif
-+ ibool success;
-
-- lock->last_s_file_name = file_name;
-- lock->last_s_line = line;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ success = os_compare_and_swap(&(lock->lock_word), X_LOCK_DECR, 0);
-+#else
-
-+ success = FALSE;
-+ mutex_enter(&(lock->mutex));
-+ if (lock->lock_word == X_LOCK_DECR) {
-+ lock->lock_word = 0;
- success = TRUE;
- }
-+ mutex_exit(&(lock->mutex));
-
-- mutex_exit(rw_lock_get_mutex(lock));
--
-- return(success);
--}
-+#endif
-+ if (success) {
-+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
-
--/**********************************************************************
--NOTE! Use the corresponding macro, not directly this function! Lock an
--rw-lock in exclusive mode for the current thread if the lock can be
--obtained immediately. */
--UNIV_INLINE
--ibool
--rw_lock_x_lock_func_nowait(
--/*=======================*/
-- /* out: TRUE if success */
-- rw_lock_t* lock, /* in: pointer to rw-lock */
-- const char* file_name,/* in: file name where lock requested */
-- ulint line) /* in: line where requested */
--{
-- ibool success = FALSE;
-- os_thread_id_t curr_thread = os_thread_get_curr_id();
-- mutex_enter(rw_lock_get_mutex(lock));
-+ } else if (lock->recursive
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ /* Relock: this lock_word modification is safe since no other
-+ threads can modify (lock, unlock, or reserve) lock_word while
-+ there is an exclusive writer and this is the writer thread. */
-+ lock->lock_word -= X_LOCK_DECR;
-
-- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-- } else if (UNIV_LIKELY(rw_lock_get_writer(lock)
-- == RW_LOCK_NOT_LOCKED)) {
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_thread = curr_thread;
-- lock->pass = 0;
-- relock:
-- lock->writer_count++;
-+ ut_ad(((-lock->lock_word) % X_LOCK_DECR) == 0);
-
-+ } else {
-+ /* Failure */
-+ return(FALSE);
-+ }
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
- #endif
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- success = TRUE;
-- } else if (rw_lock_get_writer(lock) == RW_LOCK_EX
-- && lock->pass == 0
-- && os_thread_eq(lock->writer_thread, curr_thread)) {
-- goto relock;
-- }
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-
- ut_ad(rw_lock_validate(lock));
-
-- return(success);
-+ return(TRUE);
- }
-
- /**********************************************************************
-@@ -354,39 +495,21 @@
- #endif
- )
- {
-- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
--
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter(mutex);
--
-- /* Reset the shared lock by decrementing the reader count */
--
-- ut_a(lock->reader_count > 0);
-- lock->reader_count--;
-+ ut_ad((lock->lock_word % X_LOCK_DECR) != 0);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
- #endif
-
-- /* If there may be waiters and this was the last s-lock,
-- signal the object */
-+ /* Increment lock_word to indicate 1 less reader */
-+ if (rw_lock_lock_word_incr(lock, 1) == 0) {
-
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->reader_count == 0) {
-- sg = TRUE;
--
-- rw_lock_set_waiters(lock, 0);
-- }
--
-- mutex_exit(mutex);
--
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ /* wait_ex waiter exists. It may not be asleep, but we signal
-+ anyway. We do not wake other waiters, because they can't
-+ exist without wait_ex waiter and wait_ex waiter goes first.*/
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
- sync_array_object_signalled(sync_primary_wait_array);
-+
- }
-
- ut_ad(rw_lock_validate(lock));
-@@ -405,16 +528,15 @@
- /*====================*/
- rw_lock_t* lock) /* in: rw-lock */
- {
-- /* Reset the shared lock by decrementing the reader count */
--
-- ut_ad(lock->reader_count > 0);
--
-- lock->reader_count--;
-+ ut_ad(lock->lock_word < X_LOCK_DECR);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+ /* Decrease reader count by incrementing lock_word */
-+ lock->lock_word++;
-+
- ut_ad(!lock->waiters);
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
-@@ -435,42 +557,32 @@
- #endif
- )
- {
-- ibool sg = FALSE;
--
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter(&(lock->mutex));
--
-- /* Reset the exclusive lock if this thread no longer has an x-mode
-- lock */
--
-- ut_ad(lock->writer_count > 0);
-+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
-
-- lock->writer_count--;
--
-- if (lock->writer_count == 0) {
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-+ /* lock->recursive flag also indicates if lock->writer_thread is
-+ valid or stale. If we are the last of the recursive callers
-+ then we must unset lock->recursive flag to indicate that the
-+ lock->writer_thread is now stale.
-+ Note that since we still hold the x-lock we can safely read the
-+ lock_word. */
-+ if (lock->lock_word == 0) {
-+ /* Last caller in a possible recursive chain. */
-+ lock->recursive = FALSE;
- }
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
-- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-- }
--
-- mutex_exit(&(lock->mutex));
--
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-- sync_array_object_signalled(sync_primary_wait_array);
-+ if (rw_lock_lock_word_incr(lock, X_LOCK_DECR) == X_LOCK_DECR) {
-+ /* Lock is now free. May have to signal read/write waiters.
-+ We do not need to signal wait_ex waiters, since they cannot
-+ exist when there is a writer. */
-+ if (lock->waiters) {
-+ rw_lock_reset_waiter_flag(lock);
-+ os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
- }
-
- ut_ad(rw_lock_validate(lock));
-@@ -492,18 +604,18 @@
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
-- ut_ad(lock->writer_count > 0);
--
-- lock->writer_count--;
--
-- if (lock->writer_count == 0) {
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-- }
-+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+ if (lock->lock_word == 0) {
-+ lock->recursive = FALSE;
-+ }
-+
-+ lock->lock_word += X_LOCK_DECR;
-+
- ut_ad(!lock->waiters);
- ut_ad(rw_lock_validate(lock));
-
-diff -ruN a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/include/sync0sync.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -465,8 +488,11 @@
- struct mutex_struct {
- os_event_t event; /* Used by sync0arr.c for the wait queue */
- ulint lock_word; /* This ulint is the target of the atomic
-- test-and-set instruction in Win32 */
--#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+ test-and-set instruction in Win32 and
-+ x86 32/64 with GCC 4.1.0 or later version */
-+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+#else
- os_fast_mutex_t
- os_fast_mutex; /* In other systems we use this OS mutex
- in place of lock_word */
-@@ -525,8 +551,7 @@
- /* The number of system calls made in this module. Intended for performance
- monitoring. */
-
--extern ulint mutex_system_call_count;
--extern ulint mutex_exit_count;
-+extern ib_longlong mutex_exit_count;
-
- /* Latching order checks start when this is set TRUE */
- extern ibool sync_order_checks_on;
-diff -ruN a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic
---- a/innobase/include/sync0sync.ic 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0sync.ic 2009-10-22 15:18:44.000000000 +0900
-@@ -1,21 +1,34 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
--#if defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
--/* %z0: Use the size of operand %0 which in our case is *m to determine
--instruction size, it should end up as xchgl. "1" in the input constraint,
--says that "in" has to go in the same place as "out".*/
--#define TAS(m, in, out) \
-- asm volatile ("xchg%z0 %2, %0" \
-- : "=g" (*(m)), "=r" (out) \
-- : "1" (in)) /* Note: "1" here refers to "=r" (out) */
--#endif
--
- /**********************************************************************
- Sets the waiters field in a mutex. */
-
-@@ -94,12 +107,8 @@
- /* mutex_fence(); */
-
- return(res);
--#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
-- ulint res;
--
-- TAS(&mutex->lock_word, 1, res);
--
-- return(res);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ return __sync_lock_test_and_set(&(mutex->lock_word), 1);
- #else
- ibool ret;
-
-@@ -136,10 +145,11 @@
- __asm MOV EDX, 0
- __asm MOV ECX, lw
- __asm XCHG EDX, DWORD PTR [ECX]
--#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
-- ulint res;
--
-- TAS(&mutex->lock_word, 0, res);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ /* In theory __sync_lock_release should be used to release the lock.
-+ Unfortunately, it does not work properly alone. The workaround is
-+ that more conservative __sync_lock_test_and_set is used instead. */
-+ __sync_lock_test_and_set(&(mutex->lock_word), 0);
- #else
- mutex->lock_word = 0;
-
-diff -ruN a/innobase/row/row0sel.c b/innobase/row/row0sel.c
---- a/innobase/row/row0sel.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/row/row0sel.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1178,7 +1178,7 @@
- rw_lock_s_lock(&btr_search_latch);
-
- search_latch_locked = TRUE;
-- } else if (btr_search_latch.writer_is_wait_ex) {
-+ } else if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_WAIT_EX) {
-
- /* There is an x-latch request waiting: release the
- s-latch for a moment; as an s-latch here is often
-@@ -3123,7 +3123,7 @@
- /* PHASE 0: Release a possible s-latch we are holding on the
- adaptive hash index latch if there is someone waiting behind */
-
-- if (UNIV_UNLIKELY(btr_search_latch.writer != RW_LOCK_NOT_LOCKED)
-+ if (UNIV_UNLIKELY(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_NOT_LOCKED)
- && trx->has_search_latch) {
-
- /* There is an x-latch request on the adaptive hash index:
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-09-10 04:03:01.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The wait array used in synchronization primitives
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -297,25 +320,21 @@
- }
-
- /***********************************************************************
--Puts the cell event in reset state. */
-+Returns the event that the thread owning the cell waits for. */
- static
--ib_longlong
--sync_cell_event_reset(
--/*==================*/
-- /* out: value of signal_count
-- at the time of reset. */
-- ulint type, /* in: lock type mutex/rw_lock */
-- void* object) /* in: the rw_lock/mutex object */
-+os_event_t
-+sync_cell_get_event(
-+/*================*/
-+ sync_cell_t* cell) /* in: non-empty sync array cell */
- {
-+ ulint type = cell->request_type;
-+
- if (type == SYNC_MUTEX) {
-- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
-+ return(((mutex_t *) cell->wait_object)->event);
- } else if (type == RW_LOCK_WAIT_EX) {
-- return(os_event_reset(
-- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ return(((rw_lock_t *) cell->wait_object)->wait_ex_event);
-+ } else { /* RW_LOCK_SHARED and RW_LOCK_EX wait on the same event */
-+ return(((rw_lock_t *) cell->wait_object)->event);
- }
- }
-
-@@ -334,6 +353,7 @@
- ulint* index) /* out: index of the reserved cell */
- {
- sync_cell_t* cell;
-+ os_event_t event;
- ulint i;
-
- ut_a(object);
-@@ -372,8 +392,8 @@
- /* Make sure the event is reset and also store
- the value of signal_count at which the event
- was reset. */
-- cell->signal_count = sync_cell_event_reset(type,
-- object);
-+ event = sync_cell_get_event(cell);
-+ cell->signal_count = os_event_reset(event);
-
- cell->reservation_time = time(NULL);
-
-@@ -413,19 +433,7 @@
- ut_a(!cell->waiting);
- ut_ad(os_thread_get_curr_id() == cell->thread);
-
-- if (cell->request_type == SYNC_MUTEX) {
-- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
-- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
-- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-- }
--
-+ event = sync_cell_get_event(cell);
- cell->waiting = TRUE;
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -464,6 +472,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,9 +501,7 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-@@ -505,21 +512,24 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, waiters flag %lu, "
-+ "lock_word: %lx\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
-- (ulong) rwlock->reader_count,
-+ (ulong) rw_lock_get_reader_count(rwlock),
- (ulong) rwlock->waiters,
-+ rwlock->lock_word,
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -773,28 +783,30 @@
- return(TRUE);
- }
-
-- } else if (cell->request_type == RW_LOCK_EX
-- || cell->request_type == RW_LOCK_WAIT_EX) {
-+ } else if (cell->request_type == RW_LOCK_EX) {
-
- lock = cell->wait_object;
-
-- if (rw_lock_get_reader_count(lock) == 0
-- && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ if (lock->lock_word > 0) {
-+ /* Either unlocked or only read locked. */
-
- return(TRUE);
- }
-
-- if (rw_lock_get_reader_count(lock) == 0
-- && rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX
-- && os_thread_eq(lock->writer_thread, cell->thread)) {
-+ } else if (cell->request_type == RW_LOCK_WAIT_EX) {
-+
-+ lock = cell->wait_object;
-+
-+ /* lock_word == 0 means all readers have left */
-+ if (lock->lock_word == 0) {
-
- return(TRUE);
- }
--
- } else if (cell->request_type == RW_LOCK_SHARED) {
- lock = cell->wait_object;
-
-- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* lock_word > 0 means no writer or reserved writer */
-+ if (lock->lock_word > 0) {
-
- return(TRUE);
- }
-@@ -839,11 +851,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ (void) os_atomic_increment(&arr->sg_count, 1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -859,6 +875,7 @@
- sync_cell_t* cell;
- ulint count;
- ulint i;
-+ os_event_t event;
-
- sync_array_enter(arr);
-
-@@ -868,36 +885,20 @@
- while (count < arr->n_reserved) {
-
- cell = sync_array_get_nth_cell(arr, i);
-+ i++;
-
-- if (cell->wait_object != NULL) {
--
-+ if (cell->wait_object == NULL) {
-+ continue;
-+ }
- count++;
-
- if (sync_arr_cell_can_wake_up(cell)) {
-
-- if (cell->request_type == SYNC_MUTEX) {
-- mutex_t* mutex;
-+ event = sync_cell_get_event(cell);
-
-- mutex = cell->wait_object;
-- os_event_set(mutex->event);
--#ifdef __WIN__
-- } else if (cell->request_type
-- == RW_LOCK_WAIT_EX) {
-- rw_lock_t* lock;
--
-- lock = cell->wait_object;
-- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-- rw_lock_t* lock;
--
-- lock = cell->wait_object;
-- os_event_set(lock->event);
-- }
-- }
-+ os_event_set(event);
- }
-
-- i++;
- }
-
- sync_array_exit(arr);
-@@ -1014,4 +1015,3 @@
-
- sync_array_exit(arr);
- }
--
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-09-10 04:03:01.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for thread synchronization)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -15,17 +38,110 @@
- #include "mem0mem.h"
- #include "srv0srv.h"
-
--ulint rw_s_system_call_count = 0;
--ulint rw_s_spin_wait_count = 0;
--ulint rw_s_os_wait_count = 0;
-+/*
-+ IMPLEMENTATION OF THE RW_LOCK
-+ =============================
-+The status of a rw_lock is held in lock_word. The initial value of lock_word is
-+X_LOCK_DECR. lock_word is decremented by 1 for each s-lock and by X_LOCK_DECR
-+for each x-lock. This describes the lock state for each value of lock_word:
-+
-+lock_word == X_LOCK_DECR: Unlocked.
-+0 < lock_word < X_LOCK_DECR: Read locked, no waiting writers.
-+ (X_LOCK_DECR - lock_word) is the
-+ number of readers that hold the lock.
-+lock_word == 0: Write locked
-+-X_LOCK_DECR < lock_word < 0: Read locked, with a waiting writer.
-+ (-lock_word) is the number of readers
-+ that hold the lock.
-+lock_word <= -X_LOCK_DECR: Recursively write locked. lock_word has been
-+ decremented by X_LOCK_DECR once for each lock,
-+ so the number of locks is:
-+ ((-lock_word) / X_LOCK_DECR) + 1
-+When lock_word <= -X_LOCK_DECR, we also know that lock_word % X_LOCK_DECR == 0:
-+other values of lock_word are invalid.
-+
-+The lock_word is always read and updated atomically and consistently, so that
-+it always represents the state of the lock, and the state of the lock changes
-+with a single atomic operation. This lock_word holds all of the information
-+that a thread needs in order to determine if it is eligible to gain the lock
-+or if it must spin or sleep. The one exception to this is that writer_thread
-+must be verified before recursive write locks: to solve this scenario, we make
-+writer_thread readable by all threads, but only writeable by the x-lock holder.
-+
-+The other members of the lock obey the following rules to remain consistent:
-+
-+recursive: This and the writer_thread field together control the
-+ behaviour of recursive x-locking.
-+ lock->recursive must be FALSE in following states:
-+ 1) The writer_thread contains garbage i.e.: the
-+ lock has just been initialized.
-+ 2) The lock is not x-held and there is no
-+ x-waiter waiting on WAIT_EX event.
-+ 3) The lock is x-held or there is an x-waiter
-+ waiting on WAIT_EX event but the 'pass' value
-+ is non-zero.
-+ lock->recursive is TRUE iff:
-+ 1) The lock is x-held or there is an x-waiter
-+ waiting on WAIT_EX event and the 'pass' value
-+ is zero.
-+ This flag must be set after the writer_thread field
-+ has been updated with a memory ordering barrier.
-+ It is unset before the lock_word has been incremented.
-+writer_thread: Is used only in recursive x-locking. Can only be safely
-+ read iff lock->recursive flag is TRUE.
-+ This field is uninitialized at lock creation time and
-+ is updated atomically when x-lock is acquired or when
-+ move_ownership is called. A thread is only allowed to
-+ set the value of this field to it's thread_id i.e.: a
-+ thread cannot set writer_thread to some other thread's
-+ id.
-+waiters: May be set to 1 anytime, but to avoid unnecessary wake-up
-+ signals, it should only be set to 1 when there are threads
-+ waiting on event. Must be 1 when a writer starts waiting to
-+ ensure the current x-locking thread sends a wake-up signal
-+ during unlock. May only be reset to 0 immediately before a
-+ a wake-up signal is sent to event. On most platforms, a
-+ memory barrier is required after waiters is set, and before
-+ verifying lock_word is still held, to ensure some unlocker
-+ really does see the flags new value.
-+event: Threads wait on event for read or writer lock when another
-+ thread has an x-lock or an x-lock reservation (wait_ex). A
-+ thread may only wait on event after performing the following
-+ actions in order:
-+ (1) Record the counter value of event (with os_event_reset).
-+ (2) Set waiters to 1.
-+ (3) Verify lock_word <= 0.
-+ (1) must come before (2) to ensure signal is not missed.
-+ (2) must come before (3) to ensure a signal is sent.
-+ These restrictions force the above ordering.
-+ Immediately before sending the wake-up signal, we should:
-+ (1) Verify lock_word == X_LOCK_DECR (unlocked)
-+ (2) Reset waiters to 0.
-+wait_ex_event: A thread may only wait on the wait_ex_event after it has
-+ performed the following actions in order:
-+ (1) Decrement lock_word by X_LOCK_DECR.
-+ (2) Record counter value of wait_ex_event (os_event_reset,
-+ called from sync_array_reserve_cell).
-+ (3) Verify that lock_word < 0.
-+ (1) must come first to ensures no other threads become reader
-+ or next writer, and notifies unlocker that signal must be sent.
-+ (2) must come before (3) to ensure the signal is not missed.
-+ These restrictions force the above ordering.
-+ Immediately before sending the wake-up signal, we should:
-+ Verify lock_word == 0 (waiting thread holds x_lock)
-+*/
-+
-+ib_longlong rw_s_spin_wait_count = 0;
-+ib_longlong rw_s_spin_round_count = 0;
-+ib_longlong rw_s_os_wait_count = 0;
-+
-+ib_longlong rw_s_exit_count = 0;
-+
-+ib_longlong rw_x_spin_wait_count = 0;
-+ib_longlong rw_x_spin_round_count = 0;
-+ib_longlong rw_x_os_wait_count = 0;
-
--ulint rw_s_exit_count = 0;
--
--ulint rw_x_system_call_count = 0;
--ulint rw_x_spin_wait_count = 0;
--ulint rw_x_os_wait_count = 0;
--
--ulint rw_x_exit_count = 0;
-+ib_longlong rw_x_exit_count = 0;
-
- /* The global list of rw-locks */
- rw_lock_list_t rw_lock_list;
-@@ -99,22 +215,30 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
- lock->mutex.cfile_name = cfile_name;
- lock->mutex.cline = cline;
--#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
-+# if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
--#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+# endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-
-- rw_lock_set_waiters(lock, 0);
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-- lock->writer_count = 0;
-- rw_lock_set_reader_count(lock, 0);
--
-- lock->writer_is_wait_ex = FALSE;
-+#else /* HAVE_ATOMIC_BUILTINS */
-+# ifdef UNIV_DEBUG
-+ UT_NOT_USED(cmutex_name);
-+# endif
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
-+ lock->lock_word = X_LOCK_DECR;
-+ lock->waiters = 0;
-+
-+ /* We set this value to signify that lock->writer_thread
-+ contains garbage at initialization and cannot be used for
-+ recursive x-locking. */
-+ lock->recursive = FALSE;
-
- #ifdef UNIV_SYNC_DEBUG
- UT_LIST_INIT(lock->debug_list);
-@@ -126,15 +250,13 @@
- lock->cfile_name = cfile_name;
- lock->cline = cline;
-
-+ lock->count_os_wait = 0;
- lock->last_s_file_name = "not yet reserved";
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -158,23 +280,17 @@
- /*=========*/
- rw_lock_t* lock) /* in: rw-lock */
- {
--#ifdef UNIV_DEBUG
- ut_a(rw_lock_validate(lock));
--#endif /* UNIV_DEBUG */
-- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-- ut_a(rw_lock_get_reader_count(lock) == 0);
-+ ut_a(lock->lock_word == X_LOCK_DECR);
-
-- lock->magic_n = 0;
--
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- mutex_enter(&rw_lock_list_mutex);
- os_event_free(lock->event);
-
--#ifdef __WIN__
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -186,6 +302,8 @@
- UT_LIST_REMOVE(list, rw_lock_list, lock);
-
- mutex_exit(&rw_lock_list_mutex);
-+
-+ lock->magic_n = 0;
- }
-
- /**********************************************************************
-@@ -199,19 +317,12 @@
- {
- ut_a(lock);
-
-- mutex_enter(rw_lock_get_mutex(lock));
-+ ulint waiters = rw_lock_get_waiters(lock);
-+ lint lock_word = lock->lock_word;
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-- ut_a((rw_lock_get_reader_count(lock) == 0)
-- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ ut_a(waiters == 0 || waiters == 1);
-+ ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0);
-
- return(TRUE);
- }
-@@ -232,18 +343,15 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint i; /* spin round count */
-+ ulint i = 0; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
-+ rw_s_spin_wait_count++; /* Count calls to this function */
- lock_loop:
-- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
--
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS && lock->lock_word <= 0) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,28 +370,32 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-- mutex_enter(rw_lock_get_mutex(lock));
--
- /* We try once again to obtain the lock */
--
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-- mutex_exit(rw_lock_get_mutex(lock));
-+ rw_s_spin_round_count += i;
-
- return; /* Success */
- } else {
-- /* If we get here, locking did not succeed, we may
-- suspend the thread to wait in the wait array */
-
-- rw_s_system_call_count++;
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto lock_loop;
-+ }
-+
-+ rw_s_spin_round_count += i;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock, RW_LOCK_SHARED,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* Set waiters before checking lock_word to ensure wake-up
-+ signal is sent. This may lead to some unnecessary signals. */
-+ rw_lock_set_waiter_flag(lock);
-+
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -292,11 +404,13 @@
- lock, lock->cfile_name, (ulong) lock->cline);
- }
-
-- rw_s_system_call_count++;
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
- rw_s_os_wait_count++;
-
- sync_array_wait_event(sync_primary_wait_array, index);
-
-+ i = 0;
- goto lock_loop;
- }
- }
-@@ -318,114 +432,130 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-- mutex_enter(&(lock->mutex));
--
-- lock->writer_thread = os_thread_get_curr_id();
--
-- lock->pass = 0;
--
-- mutex_exit(&(lock->mutex));
-+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
- }
-
- /**********************************************************************
--Low-level function for acquiring an exclusive lock. */
-+Function for the next writer to call. Waits for readers to exit.
-+The caller must have already decremented lock_word by X_LOCK_DECR.*/
- UNIV_INLINE
--ulint
--rw_lock_x_lock_low(
--/*===============*/
-- /* out: RW_LOCK_NOT_LOCKED if did
-- not succeed, RW_LOCK_EX if success,
-- RW_LOCK_WAIT_EX, if got wait reservation */
-+void
-+rw_lock_x_lock_wait(
-+/*================*/
- rw_lock_t* lock, /* in: pointer to rw-lock */
-+#ifdef UNIV_SYNC_DEBUG
- ulint pass, /* in: pass value; != 0, if the lock will
- be passed to another thread to unlock */
-+#endif
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
--#endif /* UNIV_SYNC_DEBUG */
-- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ ulint index;
-+ ulint i = 0;
-
-- if (rw_lock_get_reader_count(lock) == 0) {
-+ ut_ad(lock->lock_word <= 0);
-+
-+ while (lock->lock_word < 0) {
-+ if (srv_spin_wait_delay) {
-+ ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
-+ }
-+ if(i < SYNC_SPIN_ROUNDS) {
-+ i++;
-+ continue;
-+ }
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_thread = os_thread_get_curr_id();
-- lock->writer_count++;
-- lock->pass = pass;
-+ /* If there is still a reader, then go to sleep.*/
-+ rw_x_spin_round_count += i;
-+ i = 0;
-+ sync_array_reserve_cell(sync_primary_wait_array,
-+ lock,
-+ RW_LOCK_WAIT_EX,
-+ file_name, line,
-+ &index);
-+ /* Check lock_word to ensure wake-up isn't missed.*/
-+ if(lock->lock_word < 0) {
-
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
-+ rw_x_os_wait_count++;
-+
-+ /* Add debug info as it is needed to detect possible
-+ deadlock. We must add info for WAIT_EX thread for
-+ deadlock detection to work properly. */
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
- file_name, line);
- #endif
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-- } else {
-- /* There are readers, we have to wait */
-- rw_lock_set_writer(lock, RW_LOCK_WAIT_EX);
-- lock->writer_thread = os_thread_get_curr_id();
-- lock->pass = pass;
-- lock->writer_is_wait_ex = TRUE;
-
-+ sync_array_wait_event(sync_primary_wait_array,
-+ index);
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-- file_name, line);
-+ rw_lock_remove_debug_info(lock, pass,
-+ RW_LOCK_WAIT_EX);
- #endif
--
-- return(RW_LOCK_WAIT_EX);
-+ /* It is possible to wake when lock_word < 0.
-+ We must pass the while-loop check to proceed.*/
-+ } else {
-+ sync_array_free_cell(sync_primary_wait_array,
-+ index);
- }
-+ }
-+ rw_x_spin_round_count += i;
-+}
-
-- } else if ((rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- && os_thread_eq(lock->writer_thread,
-- os_thread_get_curr_id())) {
-+/**********************************************************************
-+Low-level function for acquiring an exclusive lock. */
-+UNIV_INLINE
-+ibool
-+rw_lock_x_lock_low(
-+/*===============*/
-+ /* out: RW_LOCK_NOT_LOCKED if did
-+ not succeed, RW_LOCK_EX if success. */
-+ rw_lock_t* lock, /* in: pointer to rw-lock */
-+ ulint pass, /* in: pass value; != 0, if the lock will
-+ be passed to another thread to unlock */
-+ const char* file_name,/* in: file name where lock requested */
-+ ulint line) /* in: line where requested */
-+{
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-
-- if (rw_lock_get_reader_count(lock) == 0) {
-+ if (rw_lock_lock_word_decr(lock, X_LOCK_DECR)) {
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_count++;
-- lock->pass = pass;
-- lock->writer_is_wait_ex = FALSE;
-+ /* lock->recursive also tells us if the writer_thread
-+ field is stale or active. As we are going to write
-+ our own thread id in that field it must be that the
-+ current writer_thread value is not active. */
-+ ut_a(!lock->recursive);
-
-+ /* Decrement occurred: we are writer or next-writer. */
-+ rw_lock_set_writer_id_and_recursion_flag(lock,
-+ pass ? FALSE : TRUE);
-+
-+ rw_lock_x_lock_wait(lock,
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-- file_name, line);
-+ pass,
- #endif
-+ file_name, line);
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-+ } else {
-+ /* Decrement failed: relock or failed lock */
-+ if (!pass && lock->recursive
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ /* Relock */
-+ lock->lock_word -= X_LOCK_DECR;
-+ } else {
-+ /* Another thread locked before us */
-+ return(FALSE);
- }
--
-- return(RW_LOCK_WAIT_EX);
--
-- } else if ((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- && os_thread_eq(lock->writer_thread,
-- os_thread_get_curr_id())
-- && (lock->pass == 0)
-- && (pass == 0)) {
--
-- lock->writer_count++;
--
-+ }
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-- line);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
- #endif
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = (unsigned int) line;
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-- }
--
-- /* Locking did not succeed */
-- return(RW_LOCK_NOT_LOCKED);
-+ return(TRUE);
- }
-
- /**********************************************************************
-@@ -448,47 +578,30 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
- ulint i; /* spin round count */
-+ ibool spinning = FALSE;
-
- ut_ad(rw_lock_validate(lock));
-
--lock_loop:
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter_fast(&(lock->mutex));
--
-- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ i = 0;
-
-- mutex_exit(&(lock->mutex));
-+lock_loop:
-
-- if (state == RW_LOCK_EX) {
-+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
-+ rw_x_spin_round_count += i;
-
- return; /* Locking succeeded */
-
-- } else if (state == RW_LOCK_NOT_LOCKED) {
--
-- /* Spin waiting for the writer field to become free */
-- i = 0;
--
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-- if (srv_spin_wait_delay) {
-- ut_delay(ut_rnd_interval(0,
-- srv_spin_wait_delay));
-- }
-+ } else {
-
-- i++;
-- }
-- if (i == SYNC_SPIN_ROUNDS) {
-- os_thread_yield();
-+ if (!spinning) {
-+ spinning = TRUE;
-+ rw_x_spin_wait_count++;
- }
-- } else if (state == RW_LOCK_WAIT_EX) {
-
-- /* Spin waiting for the reader count field to become zero */
-- i = 0;
--
-- while (rw_lock_get_reader_count(lock) != 0
-- && i < SYNC_SPIN_ROUNDS) {
-+ /* Spin waiting for the lock_word to become free */
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word <= 0) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -498,12 +611,13 @@
- }
- if (i == SYNC_SPIN_ROUNDS) {
- os_thread_yield();
-+ } else {
-+ goto lock_loop;
- }
-- } else {
-- i = 0; /* Eliminate a compiler warning */
-- ut_error;
- }
-
-+ rw_x_spin_round_count += i;
-+
- if (srv_print_latch_waits) {
- fprintf(stderr,
- "Thread %lu spin wait rw-x-lock at %p cfile %s cline %lu rnds %lu\n",
-@@ -511,39 +625,20 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-- rw_x_spin_wait_count++;
--
-- /* We try once again to obtain the lock. Acquire the mutex protecting
-- the rw-lock fields */
--
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- state = rw_lock_x_lock_low(lock, pass, file_name, line);
--
-- if (state == RW_LOCK_EX) {
-- mutex_exit(rw_lock_get_mutex(lock));
--
-- return; /* Locking succeeded */
-- }
--
-- rw_x_system_call_count++;
--
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
-- (state == RW_LOCK_WAIT_EX)
-- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* Waiters must be set before checking lock_word, to ensure signal
-+ is sent. This could lead to a few unnecessary wake-up signals. */
-+ rw_lock_set_waiter_flag(lock);
-+
-+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -552,11 +647,13 @@
- lock->cfile_name, (ulong) lock->cline);
- }
-
-- rw_x_system_call_count++;
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
- rw_x_os_wait_count++;
-
- sync_array_wait_event(sync_primary_wait_array, index);
-
-+ i = 0;
- goto lock_loop;
- }
-
-@@ -697,7 +794,9 @@
- rw_lock_t* lock, /* in: rw-lock */
- ulint level) /* in: level */
- {
-+#ifdef UNIV_SYNC_DEBUG
- lock->level = level;
-+#endif /* UNIV_SYNC_DEBUG */
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -718,7 +817,7 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-- mutex_enter(&(lock->mutex));
-+ rw_lock_debug_mutex_enter();
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +827,7 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-- mutex_exit(&(lock->mutex));
-+ rw_lock_debug_mutex_exit();
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +835,7 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-- mutex_exit(&(lock->mutex));
-+ rw_lock_debug_mutex_exit();
-
- return(FALSE);
- }
-@@ -758,22 +857,18 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-- mutex_enter(&(lock->mutex));
--
- if (lock_type == RW_LOCK_SHARED) {
-- if (lock->reader_count > 0) {
-+ if (rw_lock_get_reader_count(lock) > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-- mutex_exit(&(lock->mutex));
--
- return(ret);
- }
-
-@@ -801,11 +896,10 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
--
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+#endif
-+ if (lock->lock_word != X_LOCK_DECR) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-@@ -821,8 +915,10 @@
- info = UT_LIST_GET_NEXT(list, info);
- }
- }
--
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-+
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -845,9 +941,10 @@
- "RW-LATCH INFO\n"
- "RW-LATCH: %p ", lock);
-
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
-+ mutex_enter(&(lock->mutex));
-+#endif
-+ if (lock->lock_word != X_LOCK_DECR) {
-
- if (rw_lock_get_waiters(lock)) {
- fputs(" Waiters for the lock exist\n", stderr);
-@@ -861,6 +958,9 @@
- info = UT_LIST_GET_NEXT(list, info);
- }
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
-+ mutex_exit(&(lock->mutex));
-+#endif
- }
-
- /*************************************************************************
-@@ -909,14 +1009,11 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-- mutex_enter(rw_lock_get_mutex(lock));
-
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)) {
-+ if (lock->lock_word != X_LOCK_DECR) {
- count++;
- }
-
-- mutex_exit(rw_lock_get_mutex(lock));
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/sync/sync0sync.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -140,17 +163,12 @@
-
- ulint sync_dummy = 0;
-
--/* The number of system calls made in this module. Intended for performance
--monitoring. */
--
--ulint mutex_system_call_count = 0;
--
- /* Number of spin waits on mutexes: for performance monitoring */
-
--ulint mutex_spin_round_count = 0;
--ulint mutex_spin_wait_count = 0;
--ulint mutex_os_wait_count = 0;
--ulint mutex_exit_count = 0;
-+ib_longlong mutex_spin_round_count = 0;
-+ib_longlong mutex_spin_wait_count = 0;
-+ib_longlong mutex_os_wait_count = 0;
-+ib_longlong mutex_exit_count = 0;
-
- /* The global array of wait cells for implementation of the database's own
- mutexes and read-write locks */
-@@ -240,6 +258,8 @@
- {
- #if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
- mutex_reset_lock_word(mutex);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ mutex_reset_lock_word(mutex);
- #else
- os_fast_mutex_init(&(mutex->os_fast_mutex));
- mutex->lock_word = 0;
-@@ -325,7 +345,9 @@
-
- os_event_free(mutex->event);
-
--#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+#else
- os_fast_mutex_free(&(mutex->os_fast_mutex));
- #endif
- /* If we free the mutex protecting the mutex list (freeing is
-@@ -421,6 +443,12 @@
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
- ut_ad(mutex);
-
-+ /* This update is not thread safe, but we don't mind if the count
-+ isn't exact. Moved out of ifdef that follows because we are willing
-+ to sacrifice the cost of counting this as the data is valuable.
-+ Count the number of calls to mutex_spin_wait. */
-+ mutex_spin_wait_count++;
-+
- mutex_loop:
-
- i = 0;
-@@ -433,7 +461,6 @@
-
- spin_loop:
- #if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
-- mutex_spin_wait_count++;
- mutex->count_spin_loop++;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-
-@@ -502,8 +529,6 @@
- sync_array_reserve_cell(sync_primary_wait_array, mutex,
- SYNC_MUTEX, file_name, line, &index);
-
-- mutex_system_call_count++;
--
- /* The memory order of the array reservation and the change in the
- waiters field is important: when we suspend a thread, we first
- reserve the cell and then set waiters field to 1. When threads are
-@@ -551,7 +576,6 @@
- mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
- #endif
-
-- mutex_system_call_count++;
- mutex_os_wait_count++;
-
- #ifndef UNIV_HOTBACKUP
-@@ -1368,20 +1392,31 @@
- FILE* file) /* in: file where to print */
- {
- #ifdef UNIV_SYNC_DEBUG
-- fprintf(stderr, "Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
-+ fprintf(file, "Mutex exits %llu, rws exits %llu, rwx exits %llu\n",
- mutex_exit_count, rw_s_exit_count, rw_x_exit_count);
- #endif
-
- fprintf(file,
--"Mutex spin waits %lu, rounds %lu, OS waits %lu\n"
--"RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n",
-- (ulong) mutex_spin_wait_count,
-- (ulong) mutex_spin_round_count,
-- (ulong) mutex_os_wait_count,
-- (ulong) rw_s_spin_wait_count,
-- (ulong) rw_s_os_wait_count,
-- (ulong) rw_x_spin_wait_count,
-- (ulong) rw_x_os_wait_count);
-+ "Mutex spin waits %llu, rounds %llu, OS waits %llu\n"
-+ "RW-shared spins %llu, OS waits %llu;"
-+ " RW-excl spins %llu, OS waits %llu\n",
-+ mutex_spin_wait_count,
-+ mutex_spin_round_count,
-+ mutex_os_wait_count,
-+ rw_s_spin_wait_count,
-+ rw_s_os_wait_count,
-+ rw_x_spin_wait_count,
-+ rw_x_os_wait_count);
-+
-+ fprintf(file,
-+ "Spin rounds per wait: %.2f mutex, %.2f RW-shared, "
-+ "%.2f RW-excl\n",
-+ (double) mutex_spin_round_count /
-+ (mutex_spin_wait_count ? mutex_spin_wait_count : 1),
-+ (double) rw_s_spin_round_count /
-+ (rw_s_spin_wait_count ? rw_s_spin_wait_count : 1),
-+ (double) rw_x_spin_round_count /
-+ (rw_x_spin_wait_count ? rw_x_spin_wait_count : 1));
- }
-
- /***********************************************************************
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-10-22 15:18:30.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks ported from InnoDB Plugin
-+Version=1.0
-+Author=InnoBase Oy.
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20091116/innodb_rw_lock_old.patch b/percona/5.0.87-b20-20091116/innodb_rw_lock_old.patch
deleted file mode 100644
index b4a1a79..0000000
--- a/percona/5.0.87-b20-20091116/innodb_rw_lock_old.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(btr_search_latch.writer_count == 0);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.87-b20-20091116/innodb_show_bp.patch b/percona/5.0.87-b20-20091116/innodb_show_bp.patch
deleted file mode 100644
index 766a3b7..0000000
--- a/percona/5.0.87-b20-20091116/innodb_show_bp.patch
+++ /dev/null
@@ -1,453 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,19 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.87-b20-20091116/innodb_show_hashed_memory.patch b/percona/5.0.87-b20-20091116/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.87-b20-20091116/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20091116/innodb_show_hashed_memory_standalone.patch b/percona/5.0.87-b20-20091116/innodb_show_hashed_memory_standalone.patch
deleted file mode 100644
index bf8f6b4..0000000
--- a/percona/5.0.87-b20-20091116/innodb_show_hashed_memory_standalone.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,80 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes());
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20091116/innodb_split_buf_pool_mutex.patch b/percona/5.0.87-b20-20091116/innodb_split_buf_pool_mutex.patch
deleted file mode 100644
index 11a39c5..0000000
--- a/percona/5.0.87-b20-20091116/innodb_split_buf_pool_mutex.patch
+++ /dev/null
@@ -1,1895 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-08-28 11:06:20.000000000 +0900
-@@ -1101,7 +1101,7 @@
- ulint* offsets;
-
- rw_lock_x_lock(&btr_search_latch);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- table = btr_search_sys->hash_index;
-
-@@ -1186,7 +1186,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- rw_lock_x_unlock(&btr_search_latch);
-
- if (UNIV_LIKELY_NULL(heap)) {
-diff -ruN a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/buf/buf0buf.c 2009-08-28 11:06:30.000000000 +0900
-@@ -549,6 +549,17 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_BUF_LRU_LIST);
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_BUF_PAGE_HASH);
-+ mutex_create(&(buf_pool->free_mutex));
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_BUF_FREE_LIST);
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_BUF_FLUSH_LIST);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +735,8 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -753,6 +766,7 @@
- {
- buf_block_t* bck;
-
-+ ut_error; /* don't support AWE */
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -851,7 +865,7 @@
- buf_block_t* block) /* in: block to make younger */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(!mutex_own(&(buf_pool->mutex)));
-+ ut_ad(!mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Note that we read freed_page_clock's without holding any mutex:
-@@ -860,12 +874,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- }
- }
-
-@@ -881,7 +895,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +903,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +914,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +924,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +965,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +986,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +994,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1013,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1023,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1065,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1073,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1094,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1102,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1181,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ //mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1226,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ //mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1238,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1242,7 +1263,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1685,7 +1706,7 @@
- buf_block_t* block) /* in: block to init */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
-@@ -1792,7 +1813,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1829,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1845,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1901,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1913,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1937,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1949,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1963,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +1999,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2082,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2090,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2126,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,11 +2136,24 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
- if (srv_io_pattern && srv_io_pattern_trace_running) {
-@@ -2132,6 +2178,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2188,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2215,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2195,7 +2241,10 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ /* for keep the new latch order, it cannot validate correctly... */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2256,18 +2305,26 @@
- }
-
- ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
-+ /* because of latching order with block->mutex, we cannot get free_mutex before that */
-+/*
- if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
- fprintf(stderr, "Free list len %lu, free blocks %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free);
- ut_error;
- }
-+*/
-+ /* because of latching order with block->mutex, we cannot get flush_list_mutex before that */
-+/*
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+*/
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2356,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2411,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,7 +2448,7 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2404,7 +2465,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2493,7 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2501,7 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(ratio);
- }
-@@ -2460,7 +2521,10 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- if (srv_use_awe) {
- fprintf(stderr,
-@@ -2533,7 +2597,10 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-
- /**************************************************************************
-@@ -2563,7 +2630,7 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2586,7 +2653,7 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(TRUE);
- }
-@@ -2626,11 +2693,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-08-28 11:06:30.000000000 +0900
-@@ -49,7 +49,9 @@
- buf_block_t* block) /* in: block which is modified */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -79,7 +81,9 @@
- buf_block_t* b;
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- prev_b = NULL;
-@@ -130,16 +134,18 @@
- BUF_BLOCK_FILE_PAGE and in the LRU list */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
-- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ if (!block->in_LRU_list || block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -165,12 +171,13 @@
- ulint flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-+ //ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
-+ if (block->state == BUF_BLOCK_FILE_PAGE
-+ && (ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
- && (block->io_fix == 0)) {
- if (flush_type != BUF_FLUSH_LRU) {
-
-@@ -199,15 +206,17 @@
- {
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block->oldest_modification = ut_dulint_zero;
-
- UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
-
- ut_d(UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- (buf_pool->n_flush[block->flush_type])--;
-
-@@ -553,18 +562,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -761,7 +772,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -795,7 +806,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -806,14 +817,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -848,6 +859,7 @@
- ulint space;
- ulint offset;
- ibool found;
-+ ulint remaining = 0;
-
- ut_ad((flush_type == BUF_FLUSH_LRU)
- || (flush_type == BUF_FLUSH_LIST));
-@@ -866,6 +878,12 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- for (;;) {
- /* If we have flushed enough, leave the loop */
-@@ -882,7 +900,10 @@
- } else {
- ut_ad(flush_type == BUF_FLUSH_LIST);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ remaining = UT_LIST_GET_LEN(buf_pool->flush_list);
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- if (!block
- || (ut_dulint_cmp(block->oldest_modification,
- lsn_limit) >= 0)) {
-@@ -912,7 +933,9 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- old_page_count = page_count;
-
-@@ -932,7 +955,9 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -944,17 +969,26 @@
-
- mutex_exit(&block->mutex);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block = UT_LIST_GET_PREV(flush_list, block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ remaining--;
- }
- }
-
- /* If we could not find anything to flush, leave the loop */
-
-- if (!found) {
-+ if (!found && !remaining) {
- break;
- }
- }
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
-+
- (buf_pool->init_flush)[flush_type] = FALSE;
-
- if ((buf_pool->n_flush[flush_type] == 0)
-@@ -1014,7 +1048,7 @@
- ulint n_replaceable;
- ulint distance = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-@@ -1025,6 +1059,12 @@
- + BUF_FLUSH_EXTRA_MARGIN)
- && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
-
-+ if (!block->in_LRU_list) {
-+ /* reatart. but it is very optimistic */
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+ continue;
-+ }
-+
- mutex_enter(&block->mutex);
-
- if (buf_flush_ready_for_replace(block)) {
-@@ -1038,7 +1078,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1057,8 +1097,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1068,7 +1109,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1118,11 +1159,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -ruN a/innobase/buf/buf0lru.c b/innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c 2009-07-07 21:53:57.000000000 +0900
-+++ b/innobase/buf/buf0lru.c 2009-08-28 11:06:30.000000000 +0900
-@@ -108,7 +108,7 @@
-
- page_arr = ut_malloc(sizeof(ulint)
- * BUF_LRU_DROP_SEARCH_HASH_SIZE);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- scan_again:
- num_entries = 0;
-@@ -147,12 +147,12 @@
- }
- /* Array full. We release the buf_pool->mutex to
- obey the latching order. */
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- buf_LRU_drop_page_hash_batch(id, page_arr,
- num_entries);
- num_entries = 0;
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- } else {
- mutex_exit(&block->mutex);
- }
-@@ -177,7 +177,7 @@
- }
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- /* Drop any remaining batch of search hashed pages. */
- buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);
-@@ -206,7 +206,8 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +245,8 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +276,8 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +300,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +316,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +340,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +363,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,7 +386,6 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
-@@ -381,6 +393,16 @@
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,6 +413,7 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-
- mutex_exit(&(buf_pool->mutex));
-@@ -398,6 +421,8 @@
- return(FALSE);
- }
- }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +474,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +483,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +507,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,10 +563,16 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ mutex_enter(&(buf_pool->free_mutex));
-+ block = UT_LIST_GET_LAST(buf_pool->free);
-+ if (!block) {
-+ mutex_exit(&(buf_pool->free_mutex));
-+ goto no_block;
-+ }
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-+ mutex_exit(&(buf_pool->free_mutex));
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
- ut_a(!block->in_LRU_list);
-
-@@ -564,7 +597,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -572,11 +605,12 @@
-
- return(block);
- }
-+no_block:
-
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +647,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -655,7 +689,7 @@
-
- ut_a(buf_pool->LRU_old);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5);
-
-@@ -730,7 +764,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -796,7 +830,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -861,7 +895,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -964,7 +998,7 @@
- buf_block_t* block) /* in: block, must not contain a file page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -981,8 +1015,10 @@
- /* Wipe contents of page to reveal possible stale pointers to it */
- memset(block->frame, '\0', UNIV_PAGE_SIZE);
- #endif
-+ mutex_enter(&(buf_pool->free_mutex));
- UT_LIST_ADD_FIRST(free, buf_pool->free, block);
- block->in_free_list = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (srv_use_awe && block->frame) {
- /* Add to the list of mapped pages */
-@@ -1004,7 +1040,7 @@
- may or may not be a hash index to the page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -1062,7 +1098,7 @@
- be in a state where it can be freed */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
-@@ -1085,7 +1121,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1130,6 +1166,9 @@
- ut_a(buf_pool->LRU_old_len == old_len);
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
- block = UT_LIST_GET_FIRST(buf_pool->free);
-@@ -1140,7 +1179,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1195,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1239,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-08-28 11:06:30.000000000 +0900
-@@ -277,10 +277,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -292,7 +294,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -388,7 +390,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -491,6 +493,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -504,6 +507,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -520,23 +524,23 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
--
- return(0);
- }
-
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -552,7 +556,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -628,7 +632,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -696,7 +700,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -768,7 +772,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -ruN a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/include/buf0buf.h 2009-08-28 11:06:30.000000000 +0900
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -ruN a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0buf.ic 2009-08-28 11:06:30.000000000 +0900
-@@ -112,7 +112,8 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+try_again:
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -120,9 +121,13 @@
- lsn = ut_dulint_zero;
- } else {
- lsn = block->oldest_modification;
-+ if (ut_dulint_cmp(lsn, ut_dulint_zero) == 0) {
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ goto try_again;
-+ }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -137,7 +142,7 @@
- /* out: new clock value */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- buf_pool->ulint_clock++;
-@@ -392,18 +397,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +430,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +438,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -456,7 +461,7 @@
- block = buf_block_align(frame);
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /*UNIV_SYNC_DEBUG */
-
-@@ -477,7 +482,7 @@
- buf_block_t* block) /* in: block */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /* UNIV_SYNC_DEBUG */
-
-@@ -555,7 +560,8 @@
-
- ut_ad(buf_pool);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_EX)
-+ || rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_SHARED));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Look for the page in the hash table */
-@@ -631,11 +637,14 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ /* buf_flush_note_modification() should be called before this function. */
-+/*
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
- mutex_enter(&buf_pool->mutex);
- buf_flush_note_modification(block, mtr);
- mutex_exit(&buf_pool->mutex);
- }
-+*/
-
- mutex_enter(&block->mutex);
-
-diff -ruN a/innobase/include/buf0flu.h b/innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0flu.h 2009-08-28 11:06:30.000000000 +0900
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -ruN a/innobase/include/buf0flu.ic b/innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0flu.ic 2009-08-28 11:06:30.000000000 +0900
-@@ -38,11 +38,14 @@
- mtr_t* mtr) /* in: mtr */
- {
- ut_ad(block);
-+
-+ mutex_enter(&block->mutex);
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0);
-@@ -52,16 +55,20 @@
- block->newest_modification = mtr->end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = mtr->start_lsn;
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- mtr->start_lsn) <= 0);
- }
-
-+ mutex_exit(&block->mutex);
-+
- ++srv_buf_pool_write_requests;
- }
-
-@@ -78,29 +85,32 @@
- set of mtr's */
- {
- ut_ad(block);
-+
-+ mutex_enter(&(block->mutex));
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
--
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
- block->newest_modification = end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = start_lsn;
-
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_sorted_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(block->mutex));
- }
-diff -ruN a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h 2009-07-07 21:54:06.000000000 +0900
-+++ b/innobase/include/sync0sync.h 2009-08-28 11:06:30.000000000 +0900
-@@ -438,8 +438,12 @@
- SYNC_SEARCH_SYS, as memory allocation
- can call routines there! Otherwise
- the level is SYNC_MEM_HASH. */
-+#define SYNC_BUF_LRU_LIST 157
-+#define SYNC_BUF_PAGE_HASH 156
-+#define SYNC_BUF_BLOCK 155
-+#define SYNC_BUF_FREE_LIST 153
- #define SYNC_BUF_POOL 150
--#define SYNC_BUF_BLOCK 149
-+#define SYNC_BUF_FLUSH_LIST 149
- #define SYNC_DOUBLEWRITE 140
- #define SYNC_ANY_LATCH 135
- #define SYNC_THR_LOCAL 133
-diff -ruN a/innobase/log/log0recv.c b/innobase/log/log0recv.c
---- a/innobase/log/log0recv.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/log/log0recv.c 2009-08-28 11:06:30.000000000 +0900
-@@ -1695,11 +1695,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -ruN a/innobase/mtr/mtr0mtr.c b/innobase/mtr/mtr0mtr.c
---- a/innobase/mtr/mtr0mtr.c 2009-07-07 21:54:08.000000000 +0900
-+++ b/innobase/mtr/mtr0mtr.c 2009-08-28 11:06:30.000000000 +0900
-@@ -103,6 +103,38 @@
- }
- }
-
-+UNIV_INLINE
-+void
-+mtr_memo_note_modification_all(
-+/*===========================*/
-+ mtr_t* mtr) /* in: mtr */
-+{
-+ mtr_memo_slot_t* slot;
-+ dyn_array_t* memo;
-+ ulint offset;
-+
-+ ut_ad(mtr);
-+ ut_ad(mtr->magic_n == MTR_MAGIC_N);
-+ ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in
-+ commit */
-+ ut_ad(mtr->modifications);
-+
-+ memo = &(mtr->memo);
-+
-+ offset = dyn_array_get_data_size(memo);
-+
-+ while (offset > 0) {
-+ offset -= sizeof(mtr_memo_slot_t);
-+ slot = dyn_array_get_element(memo, offset);
-+
-+ if (UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-+ }
-+}
-+
- /****************************************************************
- Writes the contents of a mini-transaction log, if any, to the database log. */
- static
-@@ -177,6 +209,8 @@
- #endif
- if (mtr->modifications) {
- mtr_log_reserve_and_write(mtr);
-+
-+ mtr_memo_note_modification_all(mtr);
- }
-
- /* We first update the modification info to buffer pages, and only
-@@ -187,12 +221,13 @@
- required when we insert modified buffer pages in to the flush list
- which must be sorted on oldest_modification. */
-
-- mtr_memo_pop_all(mtr);
--
- if (mtr->modifications) {
- log_release();
- }
-
-+ /* All unlocking has been moved here, after log_sys mutex release. */
-+ mtr_memo_pop_all(mtr);
-+
- #ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTED;
- #endif
-@@ -262,6 +297,12 @@
- slot = dyn_array_get_element(memo, offset);
-
- if ((object == slot->object) && (type == slot->type)) {
-+ if (mtr->modifications &&
-+ UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-
- mtr_memo_slot_release(mtr, slot);
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-28 11:06:30.000000000 +0900
-@@ -370,6 +370,7 @@
- ulong srv_n_free_tickets_to_enter = 500;
- ulong srv_thread_sleep_delay = 10000;
- ulint srv_spin_wait_delay = 5;
-+ulint srv_spins_microsec = 50;
- ibool srv_priority_boost = TRUE;
-
- ibool srv_print_thread_releases = FALSE;
-@@ -676,6 +677,47 @@
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-
-+static
-+void
-+srv_align_spins_microsec(void)
-+{
-+ ulint start_sec, end_sec;
-+ ulint start_usec, end_usec;
-+ ib_longlong usecs;
-+
-+ /* change temporary */
-+ srv_spins_microsec = 1;
-+
-+ if (ut_usectime(&start_sec, &start_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ ut_delay(100000);
-+
-+ if (ut_usectime(&end_sec, &end_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ usecs = (end_sec - start_sec) * 1000000LL + (end_usec - start_usec);
-+
-+ if (usecs) {
-+ srv_spins_microsec = 100000 / usecs;
-+ if (srv_spins_microsec == 0)
-+ srv_spins_microsec = 1;
-+ if (srv_spins_microsec > 50)
-+ srv_spins_microsec = 50;
-+ } else {
-+ srv_spins_microsec = 50;
-+ }
-+end:
-+ if (srv_spins_microsec != 50)
-+ fprintf(stderr,
-+ "InnoDB: unit of spin count at ut_delay() is aligned to %lu\n",
-+ srv_spins_microsec);
-+}
-+
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-
-@@ -909,6 +951,8 @@
- dict_table_t* table;
- ulint i;
-
-+ srv_align_spins_microsec();
-+
- srv_sys = mem_alloc(sizeof(srv_sys_t));
-
- kernel_mutex_temp = mem_alloc(sizeof(mutex_t));
-@@ -2665,7 +2709,7 @@
- ib_longlong level, bpl;
- buf_block_t* bpage;
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- level = 0;
- bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-@@ -2687,7 +2731,7 @@
- bpl = 0;
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- if (!srv_use_doublewrite_buf) {
- /* flush is faster than when doublewrite */
-diff -ruN a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c 2009-07-07 21:54:10.000000000 +0900
-+++ b/innobase/sync/sync0sync.c 2009-08-28 11:06:30.000000000 +0900
-@@ -1105,11 +1105,19 @@
- } else if (level == SYNC_DOUBLEWRITE) {
- ut_a(sync_thread_levels_g(array, SYNC_DOUBLEWRITE));
- } else if (level == SYNC_BUF_BLOCK) {
-- ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL)
-+ ut_a((sync_thread_levels_contain(array, SYNC_BUF_LRU_LIST)
- && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1))
- || sync_thread_levels_g(array, SYNC_BUF_BLOCK));
- } else if (level == SYNC_BUF_POOL) {
- ut_a(sync_thread_levels_g(array, SYNC_BUF_POOL));
-+ } else if (level == SYNC_BUF_FLUSH_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FLUSH_LIST));
-+ } else if (level == SYNC_BUF_FREE_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FREE_LIST));
-+ } else if (level == SYNC_BUF_PAGE_HASH) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_PAGE_HASH));
-+ } else if (level == SYNC_BUF_LRU_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_LRU_LIST));
- } else if (level == SYNC_SEARCH_SYS) {
- ut_a(sync_thread_levels_g(array, SYNC_SEARCH_SYS));
- } else if (level == SYNC_TRX_LOCK_HEAP) {
-diff -ruN a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c
---- a/innobase/ut/ut0ut.c 2009-07-07 21:54:12.000000000 +0900
-+++ b/innobase/ut/ut0ut.c 2009-08-28 11:06:30.000000000 +0900
-@@ -347,6 +347,7 @@
- /*****************************************************************
- Runs an idle loop on CPU. The argument gives the desired delay
- in microseconds on 100 MHz Pentium + Visual C++. */
-+extern ulint srv_spins_microsec;
-
- ulint
- ut_delay(
-@@ -358,7 +359,11 @@
-
- j = 0;
-
-- for (i = 0; i < delay * 50; i++) {
-+ for (i = 0; i < delay * srv_spins_microsec; i++) {
-+#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__)
-+ /* it is equal to the instruction 'pause' */
-+ __asm__ __volatile__ ("rep; nop");
-+#endif
- j += i;
- }
-
-diff -ruN a/patch_info/innodb_split_buf_pool_mutex.info b/patch_info/innodb_split_buf_pool_mutex.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_split_buf_pool_mutex.info 2009-08-28 11:06:30.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_split_buf_pool_mutex.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=Backport from XtraDB
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-28 11:08:17.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-28 11:06:30.000000000 +0900
-@@ -1507,6 +1507,13 @@
- /* We set srv_pool_size here in units of 1 kB. InnoDB internally
- changes the value so that it becomes the number of database pages. */
-
-+ if (innobase_buffer_pool_awe_mem_mb) {
-+ /* split_buf_pool_mutex.patch don't support AWE */
-+ fputs("InnoDB: Warning: split_buf_pool_mutex.patch don't support AWE. Disabled.\n",
-+ stderr);
-+ innobase_buffer_pool_awe_mem_mb = 0;
-+ }
-+
- if (innobase_buffer_pool_awe_mem_mb == 0) {
- /* Careful here: we first convert the signed long int to ulint
- and only after that divide */
diff --git a/percona/5.0.87-b20-20091116/innodb_thread_concurrency_timer_based.patch b/percona/5.0.87-b20-20091116/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 3b8f659..0000000
--- a/percona/5.0.87-b20-20091116/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/innodb_use_sys_malloc.patch b/percona/5.0.87-b20-20091116/innodb_use_sys_malloc.patch
deleted file mode 100644
index 9637315..0000000
--- a/percona/5.0.87-b20-20091116/innodb_use_sys_malloc.patch
+++ /dev/null
@@ -1,265 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-06 16:06:51.000000000 +0900
-@@ -90,6 +90,7 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_use_sys_malloc;
- extern ibool srv_thread_concurrency_timer_based;
-
- extern ulint srv_n_file_io_threads;
-diff -ruN a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h
---- a/innobase/include/ut0mem.h 2009-07-07 21:54:07.000000000 +0900
-+++ b/innobase/include/ut0mem.h 2009-08-03 14:42:17.000000000 +0900
-@@ -30,6 +30,13 @@
-
-
- /**************************************************************************
-+Initializes the mem block list at database startup. */
-+
-+void
-+ut_mem_block_list_init(void);
-+/*========================*/
-+
-+/**************************************************************************
- Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
- defined and set_to_zero is TRUE. */
-
-diff -ruN a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
---- a/innobase/mem/mem0dbg.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0dbg.c 2009-07-06 16:48:17.000000000 +0900
-@@ -134,6 +134,14 @@
- mem_hash_initialized = TRUE;
- #endif
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ /* When innodb_use_sys_malloc is set, the
-+ mem_comm_pool won't be used for any allocations. We
-+ create a dummy mem_comm_pool, because some statistics
-+ and debugging code relies on it being initialized. */
-+ size = 1;
-+ }
-+
- mem_comm_pool = mem_pool_create(size);
- }
-
-diff -ruN a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c
---- a/innobase/mem/mem0pool.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0pool.c 2009-07-06 17:22:09.000000000 +0900
-@@ -11,6 +11,7 @@
- #include "mem0pool.ic"
- #endif
-
-+#include "srv0srv.h"
- #include "sync0sync.h"
- #include "ut0mem.h"
- #include "ut0lst.h"
-@@ -191,8 +192,6 @@
- ulint i;
- ulint used;
-
-- ut_a(size > 10000);
--
- pool = ut_malloc(sizeof(mem_pool_t));
-
- /* We do not set the memory to zero (FALSE) in the pool,
-@@ -330,6 +329,10 @@
- ulint n;
- ibool ret;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(malloc(size));
-+ }
-+
- n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
-
- mutex_enter(&(pool->mutex));
-@@ -457,6 +460,11 @@
- ulint size;
- ulint n;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ free(ptr);
-+ return;
-+ }
-+
- /* It may be that the area was really allocated from the OS with
- regular malloc: check if ptr points within our memory pool */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-06 16:08:06.000000000 +0900
-@@ -273,6 +273,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_use_sys_malloc = TRUE;
- ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-@@ -1012,6 +1013,7 @@
- srv_general_init(void)
- /*==================*/
- {
-+ ut_mem_block_list_init();
- os_sync_init();
- sync_init();
- mem_init(srv_mem_pool_size);
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-06 16:23:38.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ fprintf(stderr,
-+ "InnoDB: The InnoDB memory heap is disabled\n");
-+ }
-+
- #ifdef HAVE_ATOMIC_BUILTINS
- fprintf(stderr,
- "InnoDB: use atomic builtins.\n");
-diff -ruN a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
---- a/innobase/ut/ut0mem.c 2009-05-08 06:12:13.000000000 +0900
-+++ b/innobase/ut/ut0mem.c 2009-07-06 16:42:26.000000000 +0900
-@@ -15,6 +15,7 @@
- #include "mem0mem.h"
- #include "os0sync.h"
- #include "os0thread.h"
-+#include "srv0srv.h"
-
- /* This struct is placed first in every allocated memory block */
- typedef struct ut_mem_block_struct ut_mem_block_t;
-@@ -43,7 +44,7 @@
-
- /**************************************************************************
- Initializes the mem block list at database startup. */
--static
-+
- void
- ut_mem_block_list_init(void)
- /*========================*/
-@@ -70,11 +71,21 @@
- ulint retry_count = 0;
- void* ret;
-
-- ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ ret = malloc(n);
-+ ut_a(ret || !assert_on_error);
-
-- if (!ut_mem_block_list_inited) {
-- ut_mem_block_list_init();
-+#ifdef UNIV_SET_MEM_TO_ZERO
-+ if (set_to_zero) {
-+ memset(ret, '\0', n);
-+ }
-+#endif
-+ return(ret);
- }
-+
-+ ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+
-+ ut_a(ut_mem_block_list_inited);
- retry:
- os_fast_mutex_lock(&ut_list_mutex);
-
-@@ -223,6 +236,11 @@
- {
- 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);
-@@ -275,6 +293,10 @@
- ulint min_size;
- void* new_ptr;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(realloc(ptr, size));
-+ }
-+
- if (ptr == NULL) {
-
- return(ut_malloc(size));
-diff -ruN a/patch_info/innodb_use_sys_malloc.info b/patch_info/innodb_use_sys_malloc.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_use_sys_malloc.info 2009-07-06 16:04:24.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_use_sys_malloc.patch
-+Name=InnoDB uses malloc directly (backport from InnoDB-Plugin)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-06 16:10:15.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_use_sys_malloc;
- my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -1492,6 +1493,8 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_use_sys_malloc = (ibool) innobase_use_sys_malloc;
-+
- srv_thread_concurrency_timer_based =
- (ibool) innobase_thread_concurrency_timer_based;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-06 16:10:42.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_use_sys_malloc;
- extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-06 16:16:56.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_USE_SYS_MALLOC,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5470,6 +5471,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_use_sys_malloc", OPT_INNODB_USE_SYS_MALLOC,
-+ "Use OS memory allocator instead of InnoDB's internal memory allocator",
-+ (gptr*) &innobase_use_sys_malloc, (gptr*) &innobase_use_sys_malloc,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
- {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- "Use InnoDB timer based concurrency throttling. ",
- (gptr*) &innobase_thread_concurrency_timer_based,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-06 16:22:05.000000000 +0900
-@@ -1093,6 +1093,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20091116/microsec_process.patch b/percona/5.0.87-b20-20091116/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.87-b20-20091116/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.87-b20-20091116/microslow_innodb.patch b/percona/5.0.87-b20-20091116/microslow_innodb.patch
deleted file mode 100644
index 11a186c..0000000
--- a/percona/5.0.87-b20-20091116/microslow_innodb.patch
+++ /dev/null
@@ -1,2492 +0,0 @@
-diff -r 1242d4575291 include/my_getopt.h
---- a/include/my_getopt.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_getopt.h Tue Jul 28 23:42:44 2009 -0700
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 1242d4575291 include/my_time.h
---- a/include/my_time.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_time.h Tue Jul 28 23:42:44 2009 -0700
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 1242d4575291 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0buf.c Tue Jul 28 23:42:44 2009 -0700
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1090,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1142,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1158,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1190,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1303,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1276,6 +1323,12 @@
- break;
- }
- }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
- }
-
- fix_type = MTR_MEMO_BUF_FIX;
-@@ -1296,12 +1349,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1384,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,7 +1499,7 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
-@@ -1448,6 +1507,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-@@ -1470,6 +1534,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1559,6 +1624,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-diff -r 1242d4575291 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0rea.c Tue Jul 28 23:42:44 2009 -0700
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 1242d4575291 innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/fil/fil0fil.c Tue Jul 28 23:42:44 2009 -0700
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 1242d4575291 innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/buf0rea.h Tue Jul 28 23:42:44 2009 -0700
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 1242d4575291 innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/fil0fil.h Tue Jul 28 23:42:44 2009 -0700
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 1242d4575291 innobase/include/os0file.h
---- a/innobase/include/os0file.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/os0file.h Tue Jul 28 23:42:44 2009 -0700
-@@ -11,6 +11,8 @@
-
- #include "univ.i"
-
-+#include "trx0types.h"
-+
- #ifndef __WIN__
- #include <dirent.h>
- #include <sys/stat.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 1242d4575291 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/srv0srv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -27,6 +27,8 @@
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-
-+extern ibool srv_slow_log;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-
-diff -r 1242d4575291 innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/trx0trx.h Tue Jul 28 23:42:44 2009 -0700
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 1242d4575291 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/lock/lock0lock.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 1242d4575291 innobase/os/os0file.c
---- a/innobase/os/os0file.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/os/os0file.c Tue Jul 28 23:42:44 2009 -0700
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1905,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1919,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1948,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1968,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1981,6 +2005,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(ret);
- }
- #endif
-@@ -2103,7 +2134,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2144,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2209,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3169,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3423,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3463,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3497,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 1242d4575291 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/srv/srv0srv.c Tue Jul 28 23:42:44 2009 -0700
-@@ -48,6 +48,8 @@
- #include "srv0start.h"
- #include "row0mysql.h"
-
-+ibool srv_slow_log = 0;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
- ibool srv_lower_case_table_names = FALSE;
-@@ -1002,6 +1004,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1060,6 +1066,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1115,12 +1122,23 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_waiting_threads--;
-diff -r 1242d4575291 innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/trx/trx0trx.c Tue Jul 28 23:42:44 2009 -0700
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 1242d4575291 mysys/my_getopt.c
---- a/mysys/my_getopt.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/mysys/my_getopt.c Tue Jul 28 23:42:44 2009 -0700
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1062,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 1242d4575291 patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Tue Jul 28 23:42:44 2009 -0700
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 1242d4575291 scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Tue Jul 28 23:39:12 2009 -0700
-+++ b/scripts/mysqldumpslow.sh Tue Jul 28 23:42:44 2009 -0700
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 1242d4575291 sql-common/my_time.c
---- a/sql-common/my_time.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql-common/my_time.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1253,3 +1253,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 1242d4575291 sql/filesort.cc
---- a/sql/filesort.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/filesort.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 1242d4575291 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -819,9 +820,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1324,6 +1350,8 @@
-
- /* -------------- Log files ---------------------------*/
-
-+ srv_slow_log = (ibool) opt_slow_log;
-+
- /* The default dir for log files is the datadir of MySQL */
-
- if (!innobase_log_group_home_dir) {
-@@ -4697,6 +4725,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4962,6 +4996,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5049,6 +5089,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5115,6 +5161,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len1 = strlen(from);
- name_len2 = strlen(to);
-
-@@ -6122,6 +6174,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6245,7 +6298,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 1242d4575291 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.h Tue Jul 28 23:42:44 2009 -0700
-@@ -271,6 +271,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 1242d4575291 sql/log.cc
---- a/sql/log.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2289,11 +2289,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2303,7 +2304,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2333,22 +2335,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 1242d4575291 sql/log_event.cc
---- a/sql/log_event.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log_event.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2061,6 +2061,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 1242d4575291 sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysql_priv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -507,6 +507,78 @@
-
- #define STRING_BUFFER_USUAL_SIZE 80
-
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-+
- enum enum_parsing_place
- {
- NO_MATTER,
-@@ -1365,6 +1437,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1376,7 +1449,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 1242d4575291 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysqld.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -176,7 +176,6 @@
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
-
--
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
- #endif
-@@ -411,10 +410,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -509,6 +511,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -588,7 +591,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3697,6 +3700,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4947,7 +4952,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5038,11 +5043,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5441,10 +5453,19 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
- "Path to transaction coordinator log (used for transactions that affect "
- "more than one storage engine, when binary log is disabled)",
-@@ -5808,6 +5829,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6110,11 +6134,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6893,7 +6937,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7364,6 +7412,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7696,10 +7773,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 1242d4575291 sql/set_var.cc
---- a/sql/set_var.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -697,6 +717,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -720,6 +744,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -773,6 +798,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -994,8 +1021,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1022,6 +1052,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1109,6 +1140,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1149,6 +1182,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1777,6 +1811,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1933,6 +1978,19 @@
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
- }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
-+ }
- case SHOW_HA_ROWS:
- {
- ha_rows value;
-@@ -2765,6 +2823,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3549,6 +3631,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 1242d4575291 sql/set_var.h
---- a/sql/set_var.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.h Tue Jul 28 23:42:44 2009 -0700
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -378,7 +384,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ulonglong :public sys_var_thd
- {
- public:
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -478,6 +496,66 @@
- };
-
-
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
- class sys_var_thd_storage_engine :public sys_var_thd
- {
- protected:
-@@ -1109,3 +1187,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 1242d4575291 sql/slave.cc
---- a/sql/slave.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/slave.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2983,6 +2983,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 1242d4575291 sql/sql_cache.cc
---- a/sql/sql_cache.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_cache.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1402,6 +1402,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1409,6 +1410,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 1242d4575291 sql/sql_class.cc
---- a/sql/sql_class.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -190,7 +190,7 @@
- table_map_for_update(0),
- global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2251,6 +2251,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2267,7 +2273,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2320,6 +2332,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 1242d4575291 sql/sql_class.h
---- a/sql/sql_class.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.h Tue Jul 28 23:42:44 2009 -0700
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1129,6 +1134,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1185,6 +1196,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1293,10 +1309,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1696,11 +1726,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 1242d4575291 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_parse.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,28 +2363,57 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-- thd->end_time(); // Set start time
-+ ulonglong start_of_query_timer= thd->start_timer;
-+ thd->end_time(); // Set start timea
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-+
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
-+
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((thd->start_time > thd->time_after_lock &&
-- (ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time) ||
-- ((thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END))
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2669,6 +2708,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6203,6 +6244,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 1242d4575291 sql/sql_select.cc
---- a/sql/sql_select.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_select.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -6272,8 +6272,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6288,8 +6291,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9350,6 +9356,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10210,6 +10217,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 1242d4575291 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_show.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1560,6 +1560,12 @@
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
-+ break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
- break;
-diff -r 1242d4575291 sql/structs.h
---- a/sql/structs.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/structs.h Tue Jul 28 23:42:44 2009 -0700
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.87-b20-20091116/mirror_binlog.patch b/percona/5.0.87-b20-20091116/mirror_binlog.patch
deleted file mode 100644
index d52e806..0000000
--- a/percona/5.0.87-b20-20091116/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5098,6 +5098,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
- };
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.87-b20-20091116/mysql-test.patch b/percona/5.0.87-b20-20091116/mysql-test.patch
deleted file mode 100644
index 7fce8e0..0000000
--- a/percona/5.0.87-b20-20091116/mysql-test.patch
+++ /dev/null
@@ -1,108 +0,0 @@
---- a/mysql-test/r/information_schema.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/information_schema.result 2009-05-07 19:32:59.000000000 +0000
-@@ -60,6 +60,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- columns_priv
- db
- func
-@@ -743,7 +744,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--109
-+110
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -819,7 +820,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 24
-+information_schema 25
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1228,6 +1229,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1267,6 +1269,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1342,6 +1345,7 @@
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
---- a/mysql-test/r/information_schema_db.result 2009-05-07 19:31:27.000000000 +0000
-+++ b/mysql-test/r/information_schema_db.result 2009-05-07 19:35:01.000000000 +0000
-@@ -29,6 +29,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
---- a/mysql-test/r/mysqlshow.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/mysqlshow.result 2009-05-07 19:36:32.000000000 +0000
-@@ -103,6 +103,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -132,6 +133,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
---- a/mysql-test/r/profiling.result 2009-05-28 19:39:42.000000000 +0000
-+++ b/mysql-test/r/profiling.result 2009-05-28 19:40:14.000000000 +0000
-@@ -6,6 +6,8 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 15
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 0
-@@ -16,12 +18,16 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 100
-+profiling_server OFF
-+profiling_use_getrusage OFF
- set session profiling = ON;
- set session profiling_history_size=30;
- show session variables like 'profil%';
- Variable_name Value
- profiling ON
- profiling_history_size 30
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 1
diff --git a/percona/5.0.87-b20-20091116/mysqld_safe_syslog.patch b/percona/5.0.87-b20-20091116/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.87-b20-20091116/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.87-b20-20091116/profiling_slow.patch b/percona/5.0.87-b20-20091116/profiling_slow.patch
deleted file mode 100644
index 78d35a0..0000000
--- a/percona/5.0.87-b20-20091116/profiling_slow.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-diff -r 4636d2e0b0d0 patch_info/profiling_slow.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/profiling_slow.info Fri Jul 03 15:40:29 2009 -0700
-@@ -0,0 +1,9 @@
-+File=profiling_slow.info
-+Name=profiling from SHOW PROFILE to slow.log
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2009-05-18
-+Initial implementation
-diff -r 4636d2e0b0d0 sql/log.cc
---- a/sql/log.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/log.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -2402,6 +2402,11 @@
- tmp_errno=errno;
- }
- }
-+
-+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
-+ thd->profiling.print_current(&log_file);
-+#endif
-+
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
- if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
-diff -r 4636d2e0b0d0 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -5052,6 +5052,8 @@
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_PROFILING_SERVER,
-+ OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
-@@ -5675,6 +5677,16 @@
- (gptr*) &global_system_variables.profiling_history_size,
- (gptr*) &max_system_variables.profiling_history_size,
- 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
-+ {"profiling_server", OPT_PROFILING_SERVER,
-+ "Enable profiling of all threads",
-+ (gptr*) &global_system_variables.profiling_server,
-+ (gptr*) &max_system_variables.profiling_server, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
-+ {"profiling_use_getrusage", OPT_PROFILING_USE_GETRUSAGE,
-+ "Enable getrusage function call for profiling",
-+ (gptr*) &global_system_variables.profiling_use_getrusage,
-+ (gptr*) &max_system_variables.profiling_use_getrusage, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
- #endif
- {"relay-log", OPT_RELAY_LOG,
- "The location and name to use for relay logs.",
-diff -r 4636d2e0b0d0 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -592,6 +592,10 @@
- ulonglong(OPTION_PROFILING));
- static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
- &SV::profiling_history_size);
-+static sys_var_thd_bool sys_profiling_server("profiling_server",
-+ &SV::profiling_server);
-+static sys_var_thd_bool sys_profiling_use_getrusage("profiling_use_getrusage",
-+ &SV::profiling_use_getrusage);
- #endif
-
- /* Local state variables */
-@@ -764,6 +768,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- &sys_profiling,
- &sys_profiling_history_size,
-+ &sys_profiling_server,
-+ &sys_profiling_use_getrusage,
- #endif
- &sys_pseudo_thread_id,
- &sys_query_alloc_block_size,
-@@ -1094,6 +1100,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- {sys_profiling.name, (char*) &sys_profiling, SHOW_SYS},
- {sys_profiling_history_size.name, (char*) &sys_profiling_history_size, SHOW_SYS},
-+ {sys_profiling_server.name, (char*) &sys_profiling_server, SHOW_SYS},
-+ {sys_profiling_use_getrusage.name, (char*) &sys_profiling_use_getrusage, SHOW_SYS},
- #endif
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
-diff -r 4636d2e0b0d0 sql/sql_class.h
---- a/sql/sql_class.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_class.h Fri Jul 03 15:40:29 2009 -0700
-@@ -550,6 +550,8 @@
- ulong optimizer_search_depth;
- ulong preload_buff_size;
- ulong profiling_history_size;
-+ my_bool profiling_server;
-+ my_bool profiling_use_getrusage;
- ulong query_cache_type;
- ulong log_slow_rate_limit;
- ulong read_buff_size;
-diff -r 4636d2e0b0d0 sql/sql_profile.cc
---- a/sql/sql_profile.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -221,9 +221,22 @@
- */
- void PROF_MEASUREMENT::collect()
- {
-+ struct timespec tp;
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
- #ifdef HAVE_GETRUSAGE
-- getrusage(RUSAGE_SELF, &rusage);
-+ if ((profile->get_profiling())->enabled_getrusage())
-+ getrusage(RUSAGE_SELF, &rusage);
-+#endif
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ {
-+ cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
-+ }
-+ else
-+ {
-+ cpu_time_usecs= 0;
-+ }
- #endif
- }
-
-@@ -341,7 +354,7 @@
- finish_current_query();
- }
-
-- enabled= (((thd)->options & OPTION_PROFILING) != 0);
-+ enabled= (((thd)->options & OPTION_PROFILING) != 0) || ( thd->variables.profiling_server );
-
- if (! enabled) DBUG_VOID_RETURN;
-
-@@ -379,7 +392,8 @@
- status_change("ending", NULL, NULL, 0);
-
- if ((enabled) && /* ON at start? */
-- ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
-+ (((thd->options & OPTION_PROFILING) != 0) ||
-+ (thd->variables.profiling_server)) && /* and ON at end? */
- (current->query_source != NULL) &&
- (! current->entries.is_empty()))
- {
-@@ -480,6 +494,88 @@
- DBUG_VOID_RETURN;
- }
-
-+bool PROFILING::enabled_getrusage()
-+{
-+ return thd->variables.profiling_use_getrusage;
-+}
-+
-+/**
-+ Print output for current query to file
-+*/
-+
-+int PROFILING::print_current(IO_CACHE *log_file)
-+{
-+ DBUG_ENTER("PROFILING::print_current");
-+ ulonglong row_number= 0;
-+ char query_time_buff[22+7];
-+ char query_cpu_time_buff[22+7];
-+
-+ QUERY_PROFILE *query;
-+ /* Get current query */
-+ if (current == NULL)
-+ {
-+ DBUG_RETURN(0);
-+ }
-+
-+ query= current;
-+
-+ my_b_printf(log_file, "# PROFILE_VALUES ");
-+
-+ void *entry_iterator;
-+ PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
-+ /* ...and for each query, go through all its state-change steps. */
-+ for (entry_iterator= query->entries.new_iterator();
-+ entry_iterator != NULL;
-+ entry_iterator= query->entries.iterator_next(entry_iterator),
-+ previous=entry, row_number++)
-+ {
-+ entry= query->entries.iterator_value(entry_iterator);
-+
-+ /* Skip the first. We count spans of fence, not fence-posts. */
-+ if (previous == NULL) {first= entry; continue;}
-+
-+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
-+ {
-+ /*
-+ We got here via a SHOW command. That means that we stored
-+ information about the query we wish to show and that isn't
-+ in a WHERE clause at a higher level to filter out rows we
-+ wish to exclude.
-+
-+ Because that functionality isn't available in the server yet,
-+ we must filter here, at the wrong level. Once one can con-
-+ struct where and having conditions at the SQL layer, then this
-+ condition should be ripped out.
-+ */
-+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
-+ {
-+ if (query != last)
-+ continue;
-+ }
-+ else
-+ {
-+ if (thd->lex->profile_query_id != query->profiling_query_id)
-+ continue;
-+ }
-+ }
-+
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
-+
-+ }
-+
-+ my_b_printf(log_file, "\n");
-+ if ((entry != NULL) && (first != NULL))
-+ {
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /**
- Fill the information schema table, "query_profile", as defined in show.cc .
- There are two ways to get to this function: Selecting from the information
-diff -r 4636d2e0b0d0 sql/sql_profile.h
---- a/sql/sql_profile.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.h Fri Jul 03 15:40:29 2009 -0700
-@@ -193,6 +193,7 @@
- unsigned int line;
-
- double time_usecs;
-+ double cpu_time_usecs;
- char *allocated_status_memory;
-
- void set_label(const char *status_arg, const char *function_arg,
-@@ -243,6 +244,11 @@
-
- /* Show this profile. This is called by PROFILING. */
- bool show(uint options);
-+
-+public:
-+
-+ inline PROFILING * get_profiling() { return profiling; };
-+
- };
-
-
-@@ -288,9 +294,11 @@
-
- /* SHOW PROFILES */
- bool show_profiles();
-+ bool enabled_getrusage();
-
- /* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
-+ int print_current(IO_CACHE *log_file);
- };
-
- # endif /* HAVE_PROFILING */
diff --git a/percona/5.0.87-b20-20091116/series b/percona/5.0.87-b20-20091116/series
deleted file mode 100644
index 0dcc631..0000000
--- a/percona/5.0.87-b20-20091116/series
+++ /dev/null
@@ -1,22 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-profiling_slow.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_show_hashed_memory.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-innodb_use_sys_malloc.patch
-innodb_recovery_patches.patch
-innodb_misc_patch.patch
-innodb_split_buf_pool_mutex.patch
-innodb_rw_lock.patch
-mysql-test.patch
diff --git a/percona/5.0.87-b20-20091116/show_patches.patch b/percona/5.0.87-b20-20091116/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.87-b20-20091116/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.87-b20-20091116/userstatv2.patch b/percona/5.0.87-b20-20091116/userstatv2.patch
deleted file mode 100644
index 474eb49..0000000
--- a/percona/5.0.87-b20-20091116/userstatv2.patch
+++ /dev/null
@@ -1,4394 +0,0 @@
-diff -r 592f6c3641ba BUILD/Makefile.in
---- a/BUILD/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/BUILD/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Docs/Makefile.in
---- a/Docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Makefile.in
---- a/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba SSL/Makefile.in
---- a/SSL/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/SSL/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba client/Makefile.in
---- a/client/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/client/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba configure
---- a/configure Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure Wed Jul 29 13:34:11 2009 -0700
-@@ -35347,7 +35347,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38791,7 +38875,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 592f6c3641ba configure.in
---- a/configure.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure.in Wed Jul 29 13:34:11 2009 -0700
-@@ -2136,7 +2136,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2772,7 +2783,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 592f6c3641ba dbug/Makefile.in
---- a/dbug/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/dbug/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/Makefile.in
---- a/extra/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba heap/Makefile.in
---- a/heap/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/heap/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/Makefile.in
---- a/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 13:34:11 2009 -0700
-@@ -25,6 +25,7 @@
- #define USERNAME_LENGTH 16
- #define SERVER_VERSION_LENGTH 60
- #define SQLSTATE_LENGTH 5
-+#define LIST_PROCESS_HOST_LEN 64
-
- /*
- USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
-@@ -106,6 +107,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 592f6c3641ba libmysql/Makefile.in
---- a/libmysql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql_r/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba man/Makefile.in
---- a/man/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/man/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisam/Makefile.in
---- a/myisam/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisam/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisammrg/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 13:34:11 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
-diff -r 592f6c3641ba mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 13:34:11 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 592f6c3641ba mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 13:34:11 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 592f6c3641ba mysys/Makefile.in
---- a/mysys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/Makefile.in
---- a/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba netware/Makefile.in
---- a/netware/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/netware/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/Makefile.in
---- a/os2/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/Makefile.in
---- a/os2/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/sys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Wed Jul 29 13:34:11 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 592f6c3641ba pstack/Makefile.in
---- a/pstack/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/aout/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba regex/Makefile.in
---- a/regex/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/regex/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba scripts/Makefile.in
---- a/scripts/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/scripts/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/Makefile.in
---- a/server-tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/Makefile.in
---- a/sql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -3341,6 +3341,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3613,6 +3615,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3661,6 +3665,8 @@
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -4092,6 +4098,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 592f6c3641ba sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_myisam.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1521,13 +1523,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1538,6 +1544,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1548,6 +1561,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1558,6 +1578,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1568,6 +1595,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1578,6 +1612,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1588,6 +1629,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1598,6 +1646,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1614,6 +1669,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1631,6 +1693,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1645,6 +1708,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 592f6c3641ba sql/handler.cc
---- a/sql/handler.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 592f6c3641ba sql/handler.h
---- a/sql/handler.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.h Wed Jul 29 13:34:11 2009 -0700
-@@ -32,6 +32,10 @@
- #define USING_TRANSACTIONS
- #endif
-
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
-+#endif
-+
- // the following is for checking tables
-
- #define HA_ADMIN_ALREADY_DONE 1
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 592f6c3641ba sql/lex.h
---- a/sql/lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 592f6c3641ba sql/log.cc
---- a/sql/log.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/log.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 592f6c3641ba sql/mysql_priv.h
---- a/sql/mysql_priv.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysql_priv.h Wed Jul 29 13:34:11 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 592f6c3641ba sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 592f6c3641ba sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 592f6c3641ba sql/share/Makefile.in
---- a/sql/share/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/share/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/sql_base.cc
---- a/sql/sql_base.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_base.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 592f6c3641ba sql/sql_class.cc
---- a/sql/sql_class.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 592f6c3641ba sql/sql_class.h
---- a/sql/sql_class.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.h Wed Jul 29 13:34:11 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,8 +1943,14 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-
-+ char *get_client_host_port(THD *client);
-+
- public:
- /**
- Add an internal error handler to the thread execution context.
-@@ -1935,6 +1993,10 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 592f6c3641ba sql/sql_delete.cc
---- a/sql/sql_delete.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_delete.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -887,6 +888,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 592f6c3641ba sql/sql_insert.cc
---- a/sql/sql_insert.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_insert.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -990,6 +990,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3094,6 +3095,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 592f6c3641ba sql/sql_lex.h
---- a/sql/sql_lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 592f6c3641ba sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -146,6 +152,17 @@
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
- #endif
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,"%s",ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- (net->vio && net->error && net->report_error))
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4539,6 +4994,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4847,6 +5311,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5691,6 +6156,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5726,6 +6192,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5758,11 +6225,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5796,6 +6267,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5828,6 +6300,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5859,6 +6332,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5912,8 +6391,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5930,9 +6409,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6442,6 +6924,30 @@
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
- LEX *lex= thd->lex;
-@@ -6520,6 +7026,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7531,8 +8074,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 592f6c3641ba sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_prepare.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -81,6 +81,9 @@
- #include <mysql_com.h>
- #endif
-
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- /* A result class used to send cursor rows using the binary protocol. */
-
- class Select_fetch_protocol_prep: public select_send
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2503,6 +2717,43 @@
-
- send_ok(thd);
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-diff -r 592f6c3641ba sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", USERNAME_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,10 +4912,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 592f6c3641ba sql/sql_update.cc
---- a/sql/sql_update.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_update.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 592f6c3641ba sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 13:34:11 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 592f6c3641ba sql/structs.h
---- a/sql/structs.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/structs.h Wed Jul 29 13:34:11 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 592f6c3641ba sql/table.h
---- a/sql/table.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/table.h Wed Jul 29 13:34:11 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 592f6c3641ba strings/Makefile.in
---- a/strings/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/strings/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/Makefile.in
---- a/support-files/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tests/Makefile.in
---- a/tests/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tests/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tools/Makefile.in
---- a/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba vio/Makefile.in
---- a/vio/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/vio/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba win/Makefile.in
---- a/win/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/win/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba zlib/Makefile.in
---- a/zlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/zlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
diff --git a/percona/5.0.87-b20-20100217/README-GENTOO b/percona/5.0.87-b20-20100217/README-GENTOO
deleted file mode 100644
index cf527d2..0000000
--- a/percona/5.0.87-b20-20100217/README-GENTOO
+++ /dev/null
@@ -1,7 +0,0 @@
-The following patches, while distributed by Percona, are NOT applied in their
-specfile. As such, we do not apply them in Gentoo either:
-=========
-innodb_extra_status.patch
-innodb_rw_lock_old.patch
-innodb_show_hashed_memory_standalone.patch
-mirror_binlog.patch
diff --git a/percona/5.0.87-b20-20100217/innodb_check_fragmentation.patch b/percona/5.0.87-b20-20100217/innodb_check_fragmentation.patch
deleted file mode 100644
index 4b16731..0000000
--- a/percona/5.0.87-b20-20100217/innodb_check_fragmentation.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -r 936d427a9a15 innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -516,6 +516,14 @@
- == index->table->comp);
- }
-
-+ if (level == 0) {
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+ }
-+
- break;
- }
-
-@@ -663,6 +671,12 @@
- btr_cur_add_path_info(cursor, height,
- root_height);
- }
-+
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-
- break;
- }
-diff -r 936d427a9a15 innobase/btr/btr0pcur.c
---- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
-@@ -381,6 +381,7 @@
- last record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint next_page_no;
- ulint space;
- page_t* page;
-@@ -393,11 +394,22 @@
- cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- next_page_no = btr_page_get_next(page, mtr);
- space = buf_frame_get_space_id(page);
-
- ut_ad(next_page_no != FIL_NULL);
-+
-+ if (next_page_no - page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
- ut_a(page_is_comp(next_page) == page_is_comp(page));
-@@ -427,6 +439,7 @@
- record of the current page */
- mtr_t* mtr) /* in: mtr */
- {
-+ ulint page_no;
- ulint prev_page_no;
- ulint space;
- page_t* page;
-@@ -462,9 +475,20 @@
- btr_pcur_restore_position(latch_mode2, cursor, mtr);
-
- page = btr_pcur_get_page(cursor);
-+ page_no = buf_frame_get_page_no(page);
-
- prev_page_no = btr_page_get_prev(page, mtr);
- space = buf_frame_get_space_id(page);
-+
-+ if (page_no - prev_page_no == 1) {
-+ innobase_mysql_thd_increment_innodb_scan_cont(1);
-+ } else {
-+ innobase_mysql_thd_increment_innodb_scan_jump(1);
-+ }
-+ innobase_mysql_thd_increment_innodb_scan_data(
-+ page_get_data_size(page));
-+ innobase_mysql_thd_increment_innodb_scan_garbage(
-+ page_header_get_field(page, PAGE_GARBAGE));
-
- if (btr_pcur_is_before_first_on_page(cursor, mtr)
- && (prev_page_no != FIL_NULL)) {
-diff -r 936d427a9a15 innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
-@@ -861,6 +861,12 @@
-
- buf_pool->n_page_gets++;
-
-+ /* Initializes status counters */
-+ innobase_mysql_thd_init_innodb_scan_cont();
-+ innobase_mysql_thd_init_innodb_scan_jump();
-+ innobase_mysql_thd_init_innodb_scan_data();
-+ innobase_mysql_thd_init_innodb_scan_garbage();
-+
- return(TRUE);
-
- /*-------------------------------------------*/
-diff -r 936d427a9a15 innobase/include/btr0cur.h
---- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
-@@ -697,6 +697,17 @@
- extern ulint btr_cur_n_non_sea_old;
- extern ulint btr_cur_n_sea_old;
-
-+/*--------------------------------------*/
-+/* prototypes for new functions added to ha_innodb.cc */
-+void innobase_mysql_thd_init_innodb_scan_cont();
-+void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_jump();
-+void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_data();
-+void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
-+void innobase_mysql_thd_init_innodb_scan_garbage();
-+void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
-+
- #ifndef UNIV_NONINL
- #include "btr0cur.ic"
- #endif
-diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_check_fragmentation.patch
-+Name=Session status to check fragmentation of the last InnoDB scan
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=The names are Innodb_scan_*
-diff -r 936d427a9a15 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -760,6 +760,102 @@
- }
-
- /*************************************************************************
-+Initializes Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_cont()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_contiguous. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_cont+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_jump()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_blocks_jumpy. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_jump+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_data()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_data_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_data(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_data+= length;
-+ }
-+}
-+
-+/*************************************************************************
-+Initializes Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_init_innodb_scan_garbage()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage = 0;
-+ }
-+}
-+
-+/*************************************************************************
-+Increments Innodb_scan_garbages_in_pages. */
-+extern "C"
-+void
-+innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ thd->status_var.innodb_scan_garbage+= length;
-+ }
-+}
-+
-+/*************************************************************************
- Gets the InnoDB transaction handle for a MySQL handler object, creates
- an InnoDB transaction struct if the corresponding MySQL thread struct still
- lacks one. */
-diff -r 936d427a9a15 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
-@@ -6673,6 +6673,10 @@
- {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
- #ifdef HAVE_INNOBASE_DB
- {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
-+ {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
-+ {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
- #endif /*HAVE_INNOBASE_DB*/
- {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
- {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
-diff -r 936d427a9a15 sql/sql_class.h
---- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
-+++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
-@@ -729,6 +729,10 @@
- sense to add to the /global/ status variable counter.
- */
- double last_query_cost;
-+ ulonglong innodb_scan_cont;
-+ ulonglong innodb_scan_jump;
-+ ulonglong innodb_scan_data;
-+ ulonglong innodb_scan_garbage;
- } STATUS_VAR;
-
- /*
diff --git a/percona/5.0.87-b20-20100217/innodb_dict_size_limit.patch b/percona/5.0.87-b20-20100217/innodb_dict_size_limit.patch
deleted file mode 100644
index ced1aec..0000000
--- a/percona/5.0.87-b20-20100217/innodb_dict_size_limit.patch
+++ /dev/null
@@ -1,633 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-08-27 18:43:11.000000000 +0900
-@@ -1077,6 +1077,124 @@
- }
-
- /************************************************************************
-+Drops a page hash index based on index */
-+
-+void
-+btr_search_drop_page_hash_index_on_index(
-+/*=====================================*/
-+ dict_index_t* index) /* in: record descriptor */
-+{
-+ page_t* page;
-+ hash_table_t* table;
-+ buf_block_t* block;
-+ ulint n_fields;
-+ ulint n_bytes;
-+ rec_t* rec;
-+ ulint fold;
-+ ulint prev_fold;
-+ dulint tree_id;
-+ ulint n_cached;
-+ ulint n_recs;
-+ ulint* folds;
-+ ulint i;
-+ mem_heap_t* heap = NULL;
-+ ulint* offsets;
-+
-+ rw_lock_x_lock(&btr_search_latch);
-+ mutex_enter(&buf_pool->mutex);
-+
-+ table = btr_search_sys->hash_index;
-+
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+
-+ while (block != NULL) {
-+ if (block->index == index && block->is_hashed) {
-+ page = block->frame;
-+
-+ /* from btr_search_drop_page_hash_index() */
-+ n_fields = block->curr_n_fields;
-+ n_bytes = block->curr_n_bytes;
-+
-+ ut_a(n_fields + n_bytes > 0);
-+
-+ n_recs = page_get_n_recs(page);
-+
-+ /* Calculate and cache fold values into an array for fast deletion
-+ from the hash index */
-+
-+ folds = mem_alloc(n_recs * sizeof(ulint));
-+
-+ n_cached = 0;
-+
-+ rec = page_get_infimum_rec(page);
-+ rec = page_rec_get_next(rec);
-+
-+ tree_id = btr_page_get_index_id(page);
-+
-+ ut_a(0 == ut_dulint_cmp(tree_id, index->id));
-+
-+ prev_fold = 0;
-+
-+ offsets = NULL;
-+
-+ while (!page_rec_is_supremum(rec)) {
-+ /* FIXME: in a mixed tree, not all records may have enough
-+ ordering fields: */
-+ offsets = rec_get_offsets(rec, index, offsets,
-+ n_fields + (n_bytes > 0), &heap);
-+ ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
-+ fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id);
-+
-+ if (fold == prev_fold && prev_fold != 0) {
-+
-+ goto next_rec;
-+ }
-+
-+ /* Remove all hash nodes pointing to this page from the
-+ hash chain */
-+
-+ folds[n_cached] = fold;
-+ n_cached++;
-+next_rec:
-+ rec = page_rec_get_next(rec);
-+ prev_fold = fold;
-+ }
-+
-+ for (i = 0; i < n_cached; i++) {
-+
-+ ha_remove_all_nodes_to_page(table, folds[i], page);
-+ }
-+
-+ ut_a(index->search_info->ref_count > 0);
-+ index->search_info->ref_count--;
-+
-+ block->is_hashed = FALSE;
-+ block->index = NULL;
-+
-+ if (UNIV_UNLIKELY(block->n_pointers)) {
-+ /* Corruption */
-+ ut_print_timestamp(stderr);
-+ fprintf(stderr,
-+" InnoDB: Corruption of adaptive hash index. After dropping\n"
-+"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n",
-+ index->name, (ulong) block->n_pointers);
-+ }
-+
-+ mem_free(folds);
-+ }
-+
-+ block = UT_LIST_GET_PREV(LRU, block);
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+ rw_lock_x_unlock(&btr_search_latch);
-+
-+ if (UNIV_LIKELY_NULL(heap)) {
-+ mem_heap_free(heap);
-+ }
-+}
-+
-+/************************************************************************
- Drops a page hash index when a page is freed from a fseg to the file system.
- Drops possible hash index if the page happens to be in the buffer pool. */
-
-diff -ruN a/innobase/dict/dict0boot.c b/innobase/dict/dict0boot.c
---- a/innobase/dict/dict0boot.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0boot.c 2009-08-27 18:42:59.000000000 +0900
-@@ -247,6 +247,7 @@
- system tables */
- /*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -283,6 +284,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-@@ -309,6 +311,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0);
-@@ -345,6 +348,7 @@
- ut_a(success);
- /*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0);
- dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0);
-diff -ruN a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
---- a/innobase/dict/dict0crea.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0crea.c 2009-08-27 18:42:59.000000000 +0900
-@@ -1178,6 +1178,9 @@
- /* Foreign constraint system tables have already been
- created, and they are ok */
-
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- mutex_exit(&(dict_sys->mutex));
-
- return(DB_SUCCESS);
-@@ -1267,6 +1270,11 @@
-
- trx->op_info = "";
-
-+ table1 = dict_table_get_low("SYS_FOREIGN");
-+ table2 = dict_table_get_low("SYS_FOREIGN_COLS");
-+ table1->n_mysql_handles_opened = 1; /* for pin */
-+ table2->n_mysql_handles_opened = 1; /* for pin */
-+
- row_mysql_unlock_data_dictionary(trx);
-
- trx_free_for_mysql(trx);
-diff -ruN a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
---- a/innobase/dict/dict0dict.c 2009-07-07 21:53:58.000000000 +0900
-+++ b/innobase/dict/dict0dict.c 2009-08-27 18:43:11.000000000 +0900
-@@ -638,6 +638,8 @@
- mutex_enter(&(dict_sys->mutex));
-
- table = dict_table_get_on_id_low(table_id, trx);
-+
-+ dict_table_LRU_trim(table);
-
- mutex_exit(&(dict_sys->mutex));
-
-@@ -752,6 +754,8 @@
-
- table = dict_table_get_low(table_name);
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -787,6 +791,8 @@
- table->n_mysql_handles_opened++;
- }
-
-+ dict_table_LRU_trim(table);
-+
- mutex_exit(&(dict_sys->mutex));
-
- if (table != NULL) {
-@@ -1267,20 +1273,64 @@
- too much space. Currently not used! */
-
- void
--dict_table_LRU_trim(void)
--/*=====================*/
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self)
- {
- dict_table_t* table;
- dict_table_t* prev_table;
-+ dict_foreign_t* foreign;
-+ ulint n_removed;
-+ ulint n_have_parent;
-+ ulint cached_foreign_tables;
-
-- ut_error;
-+ //ut_error;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
-+retry:
-+ n_removed = n_have_parent = 0;
- table = UT_LIST_GET_LAST(dict_sys->table_LRU);
-
-+ while ( srv_dict_size_limit && table
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit ) {
-+ prev_table = UT_LIST_GET_PREV(table_LRU, table);
-+
-+ if (table == self || table->n_mysql_handles_opened)
-+ goto next_loop;
-+
-+ cached_foreign_tables = 0;
-+ foreign = UT_LIST_GET_FIRST(table->foreign_list);
-+ while (foreign != NULL) {
-+ if (foreign->referenced_table)
-+ cached_foreign_tables++;
-+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
-+ }
-+
-+ /* TODO: use table->mem_fix also, if it becomes exact. */
-+
-+ if (cached_foreign_tables == 0) {
-+ dict_table_remove_from_cache(table);
-+ n_removed++;
-+ } else {
-+ n_have_parent++;
-+ }
-+next_loop:
-+ table = prev_table;
-+ }
-+
-+ if ( srv_dict_size_limit && n_have_parent && n_removed
-+ && ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) > srv_dict_size_limit )
-+ goto retry;
-+/*
- while (table && (dict_sys->size >
- buf_pool_get_max_size() / DICT_POOL_PER_VARYING)) {
-
-@@ -1292,6 +1342,7 @@
-
- table = prev_table;
- }
-+*/
- }
-
- /**************************************************************************
-@@ -1565,6 +1616,10 @@
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(dict_sys->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-+ /* remove all entry of the index from adaptive hash index,
-+ because removing from adaptive hash index needs dict_index */
-+ if (srv_use_adaptive_hash_indexes && srv_dict_size_limit)
-+ btr_search_drop_page_hash_index_on_index(index);
-
- /* We always create search info whether or not adaptive
- hash index is enabled or not. */
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-08-27 18:42:59.000000000 +0900
-@@ -535,6 +535,7 @@
- sprintf(buf, "SYS_IBUF_TABLE_%lu", (ulong) space);
- /* use old-style record format for the insert buffer */
- table = dict_mem_table_create(buf, space, 2, FALSE);
-+ table->n_mysql_handles_opened = 1; /* for pin */
-
- dict_mem_table_add_col(table, "PAGE_NO", DATA_BINARY, 0, 0, 0);
- dict_mem_table_add_col(table, "TYPES", DATA_BINARY, 0, 0, 0);
-diff -ruN a/innobase/include/btr0sea.h b/innobase/include/btr0sea.h
---- a/innobase/include/btr0sea.h 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/btr0sea.h 2009-08-27 18:43:11.000000000 +0900
-@@ -97,6 +97,13 @@
- /*============================*/
- page_t* page); /* in: index page, s- or x-latched */
- /************************************************************************
-+Drops a page hash index based on index */
-+
-+void
-+btr_search_drop_page_hash_index_on_index(
-+/*=====================================*/
-+ dict_index_t* index); /* in: record descriptor */
-+/************************************************************************
- Drops a page hash index when a page is freed from a fseg to the file system.
- Drops possible hash index if the page happens to be in the buffer pool. */
-
-diff -ruN a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h
---- a/innobase/include/dict0dict.h 2009-07-07 21:54:01.000000000 +0900
-+++ b/innobase/include/dict0dict.h 2009-08-27 18:42:59.000000000 +0900
-@@ -938,6 +938,11 @@
- const char* ptr, /* in: scan from */
- const char* string);/* in: look for this */
-
-+void
-+dict_table_LRU_trim(
-+/*================*/
-+ dict_table_t* self);
-+
- /* Buffers for storing detailed information about the latest foreign key
- and unique key errors */
- extern FILE* dict_foreign_err_file;
-diff -ruN a/innobase/include/dict0dict.ic b/innobase/include/dict0dict.ic
---- a/innobase/include/dict0dict.ic 2009-07-07 21:54:01.000000000 +0900
-+++ b/innobase/include/dict0dict.ic 2009-08-27 18:42:59.000000000 +0900
-@@ -533,6 +533,13 @@
-
- HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, table,
- ut_strcmp(table->name, table_name) == 0);
-+
-+ /* make young in table_LRU */
-+ if (table) {
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+ }
-+
- return(table);
- }
-
-@@ -592,6 +599,10 @@
- if (table != NULL) {
- table->mem_fix++;
-
-+ /* make young in table_LRU */
-+ UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
-+ UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
-+
- /* lock_push(trx, table, LOCK_DICT_MEM_FIX) */
- }
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-08-27 18:42:59.000000000 +0900
-@@ -147,6 +147,8 @@
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-
-+extern ulint srv_dict_size_limit;
-+
- extern volatile ibool srv_io_pattern;
- extern ulong srv_io_pattern_trace;
- extern ulong srv_io_pattern_trace_running;
-@@ -552,6 +554,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_tables;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-27 18:42:17.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-27 18:42:59.000000000 +0900
-@@ -353,6 +353,8 @@
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-
-+ulint srv_dict_size_limit = 0;
-+
- volatile ibool srv_io_pattern = FALSE;
- ulint srv_io_pattern_trace = 0;
- ulint srv_io_pattern_trace_running = 0;
-@@ -1953,6 +1955,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-diff -ruN a/mysql-test/r/innodb_dict_size_limit.result b/mysql-test/r/innodb_dict_size_limit.result
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/mysql-test/r/innodb_dict_size_limit.result 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,60 @@
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+FLUSH TABLES;
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 8
-+SELECT * FROM `test_1`;
-+a b
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 9
-+SELECT * FROM `test_3`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 10
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+a b
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+Variable_name Value
-+Innodb_dict_tables 11
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-diff -ruN a/mysql-test/t/innodb_dict_size_limit.test b/mysql-test/t/innodb_dict_size_limit.test
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/mysql-test/t/innodb_dict_size_limit.test 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,63 @@
-+#
-+# Test for new variable innodb_dict_size_limit;
-+#
-+-- source include/have_innodb.inc
-+
-+--disable_warnings
-+DROP TABLE IF EXISTS `test_5`;
-+DROP TABLE IF EXISTS `test_4`;
-+DROP TABLE IF EXISTS `test_3`;
-+DROP TABLE IF EXISTS `test_2`;
-+DROP TABLE IF EXISTS `test_1`;
-+--enable_warnings
-+
-+SET storage_engine=InnoDB;
-+SET GLOBAL innodb_dict_size_limit=1;
-+
-+FLUSH TABLES;
-+
-+CREATE TABLE `test_1` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_2` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_3` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_4` (`a` int, `b` int, PRIMARY KEY (`a`));
-+CREATE TABLE `test_5` (`a` int, `b` int, PRIMARY KEY (`a`));
-+
-+ALTER TABLE `test_5` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_4`(`a`);
-+ALTER TABLE `test_4` ADD CONSTRAINT FOREIGN KEY(`b`) REFERENCES `test_3`(`a`);
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_1`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_1`;
-+FLUSH TABLES;
-+SELECT * FROM `test_4`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SELECT * FROM `test_3`;
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+SET GLOBAL innodb_dict_size_limit=0;
-+FLUSH TABLES;
-+SELECT * FROM `test_2`;
-+
-+SHOW GLOBAL STATUS LIKE 'Innodb_dict_tables';
-+
-+DROP TABLE `test_5`;
-+DROP TABLE `test_4`;
-+DROP TABLE `test_3`;
-+DROP TABLE `test_2`;
-+DROP TABLE `test_1`;
-+
-diff -ruN a/patch_info/innodb_dict_size_limit.info b/patch_info/innodb_dict_size_limit.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_dict_size_limit.info 2009-08-27 18:42:59.000000000 +0900
-@@ -0,0 +1,9 @@
-+File=innodb_dict_size_limit.patch
-+Name=Limit dictionary cache size
-+Version=1.0
-+Author=Percona
-+License=GPL
-+Comment=Variable innodb_dict_size_limit in bytes
-+ChangeLog=
-+2009-01-26
-+YK: Initial release
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -288,6 +288,8 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_tables",
-+ (char*) &export_vars.innodb_dict_tables, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-08-27 18:42:59.000000000 +0900
-@@ -243,6 +243,7 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_dict_size_limit;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
- extern ulong srv_io_pattern_trace;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/mysqld.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5464,6 +5465,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
-+ "Limit the allocated memory for dictionary cache. (0: unlimited)",
-+ (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-+ GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 0 ,0},
- {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
- "Create/Drop the internal hash table for IO pattern tracing.",
- (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-08-27 18:42:17.000000000 +0900
-+++ b/sql/set_var.cc 2009-08-27 18:42:59.000000000 +0900
-@@ -540,6 +540,8 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_dict_size_limit("innodb_dict_size_limit",
-+ &srv_dict_size_limit);
- sys_var_long_ptr sys_innodb_show_locks_held(
- "innodb_show_locks_held",
- &srv_show_locks_held);
-@@ -930,6 +932,7 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_dict_size_limit,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
- &sys_innodb_io_pattern_trace,
-@@ -1084,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
- {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20100217/innodb_extra_rseg.patch b/percona/5.0.87-b20-20100217/innodb_extra_rseg.patch
deleted file mode 100644
index cab3b26..0000000
--- a/percona/5.0.87-b20-20100217/innodb_extra_rseg.patch
+++ /dev/null
@@ -1,243 +0,0 @@
-diff -r 85e7025cf2d1 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/srv0srv.h Fri Jul 03 15:41:47 2009 -0700
-@@ -146,6 +146,8 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern ulint srv_extra_rsegments;
-
- extern ulint srv_dict_size_limit;
-
-diff -r 85e7025cf2d1 innobase/include/trx0sys.h
---- a/innobase/include/trx0sys.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/include/trx0sys.h Fri Jul 03 15:41:47 2009 -0700
-@@ -105,6 +105,13 @@
- void
- trx_sys_create(void);
- /*================*/
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num); /* in: number of extra user rollback segments */
- /********************************************************************
- Looks for a free slot for a rollback segment in the trx system file copy. */
-
-diff -r 85e7025cf2d1 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:47 2009 -0700
-@@ -352,6 +352,8 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+ulint srv_extra_rsegments = 0; /* extra rseg for users */
-
- ulint srv_dict_size_limit = 0;
-
-diff -r 85e7025cf2d1 innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/srv/srv0start.c Fri Jul 03 15:41:47 2009 -0700
-@@ -1418,6 +1418,8 @@
- dict_create();
- srv_startup_is_before_trx_rollback_phase = FALSE;
-
-+ if (srv_extra_rsegments)
-+ trx_sys_create_extra_rseg(srv_extra_rsegments);
- #ifdef UNIV_LOG_ARCHIVE
- } else if (srv_archive_recovery) {
- fprintf(stderr,
-diff -r 85e7025cf2d1 innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:41 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:47 2009 -0700
-@@ -944,3 +944,28 @@
-
- trx_sys_init_at_db_start();
- }
-+
-+/*********************************************************************
-+Create extra rollback segments when create_new_db */
-+
-+void
-+trx_sys_create_extra_rseg(
-+/*======================*/
-+ ulint num) /* in: number of extra user rollback segments */
-+{
-+ mtr_t mtr;
-+ ulint slot_no;
-+ ulint i;
-+
-+ /* Craete extra rollback segments */
-+ mtr_start(&mtr);
-+ for (i = 1; i < num + 1; i++) {
-+ if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
-+ fprintf(stderr,
-+"InnoDB: Warning: Failed to create extra rollback segments.\n");
-+ break;
-+ }
-+ ut_a(slot_no == i);
-+ }
-+ mtr_commit(&mtr);
-+}
-diff -r 85e7025cf2d1 patch_info/innodb_extra_rseg.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_rseg.info Fri Jul 03 15:41:47 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_extra_rseg.patch
-+Name=allow to create extra rollback segments
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -r 85e7025cf2d1 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1521,6 +1522,8 @@
- srv_n_read_io_threads = (ulint) innobase_read_io_threads;
- srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
-+ srv_extra_rsegments = (ulint) innobase_extra_rsegments;
-+
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-diff -r 85e7025cf2d1 sql/ha_innodb.h
---- a/sql/ha_innodb.h Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/ha_innodb.h Fri Jul 03 15:41:47 2009 -0700
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-diff -r 85e7025cf2d1 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -5101,6 +5101,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
-@@ -5465,6 +5466,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
-+ "Number of extra user rollback segments when create new database.",
-+ (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-+ 0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
- {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
- "Limit the allocated memory for dictionary cache. (0: unlimited)",
- (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
-diff -r 85e7025cf2d1 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -1087,6 +1087,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
- {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-diff -r 85e7025cf2d1 sql/sql_show.cc
---- a/sql/sql_show.cc Fri Jul 03 15:41:41 2009 -0700
-+++ b/sql/sql_show.cc Fri Jul 03 15:41:47 2009 -0700
-@@ -39,6 +39,8 @@
- #include "srv0srv.h"
- #include "buf0buf.h"
- #include "dict0dict.h"
-+#include "trx0rseg.h" /* for trx_rseg_struct */
-+#include "trx0sys.h" /* for trx_sys */
- }
- /* We need to undef it in InnoDB */
- #undef byte
-@@ -4180,6 +4182,45 @@
- DBUG_RETURN(returnable);
- }
-
-+int
-+innodb_rseg_fill(
-+/*=================*/
-+ THD* thd, /* in: thread */
-+ TABLE_LIST* tables, /* in/out: tables to fill */
-+ COND* cond) /* in: condition (ignored) */
-+{
-+ TABLE* table = (TABLE *) tables->table;
-+ int status = 0;
-+ trx_rseg_t* rseg;
-+
-+ DBUG_ENTER("innodb_rseg_fill");
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+
-+ DBUG_RETURN(0);
-+ }
-+
-+ rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
-+
-+ while (rseg) {
-+ table->field[0]->store(rseg->id);
-+ table->field[1]->store(rseg->space);
-+ table->field[2]->store(rseg->page_no);
-+ table->field[3]->store(rseg->max_size);
-+ table->field[4]->store(rseg->curr_size);
-+
-+ if (schema_table_store_record(thd, table)) {
-+ status = 1;
-+ break;
-+ }
-+
-+ rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
-+ }
-+
-+ DBUG_RETURN(status);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4996,6 +5037,16 @@
- {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
- {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
- {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO innodb_rseg_fields_info[]=
-+{
-+ {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
-+ {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
- #endif
-@@ -5177,6 +5228,8 @@
- #ifdef HAVE_INNOBASE_DB
- {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
- innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+ {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
-+ innodb_rseg_fill, 0, 0, -1, -1, 0},
- #endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
diff --git a/percona/5.0.87-b20-20100217/innodb_extra_status.patch b/percona/5.0.87-b20-20100217/innodb_extra_status.patch
deleted file mode 100644
index adc1642..0000000
--- a/percona/5.0.87-b20-20100217/innodb_extra_status.patch
+++ /dev/null
@@ -1,747 +0,0 @@
-diff -r b059d02ec814 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -2353,6 +2353,7 @@
- "AWE: Database pages and free buffers mapped in frames %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
-+ if (file) {
- fprintf(file,
- "Buffer pool size %lu\n"
- "Free buffers %lu\n"
-@@ -2371,11 +2372,13 @@
- + buf_pool->init_flush[BUF_FLUSH_LIST],
- (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
-
-+ } // if (file)
- current_time = time(NULL);
- time_elapsed = 0.001 + difftime(current_time,
- buf_pool->last_printout_time);
- buf_pool->last_printout_time = current_time;
-
-+ if (file) {
- fprintf(file,
- "Pages read %lu, created %lu, written %lu\n"
- "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
-@@ -2405,6 +2408,7 @@
- } else {
- fputs("No buffer pool page gets since the last printout\n",
- file);
-+ }
- }
-
- buf_pool->n_page_gets_old = buf_pool->n_page_gets;
-diff -r b059d02ec814 innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/ibuf/ibuf0ibuf.c Mon Nov 03 05:09:34 2008 -0800
-@@ -3519,9 +3519,15 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ inno_ibuf_size = 0;
-+ inno_ibuf_inserts = 0;
-+ inno_ibuf_merged_recs = 0;
-+ inno_ibuf_merges = 0;
-+
- data = UT_LIST_GET_FIRST(ibuf->data_list);
-
- while (data) {
-+ if (file) {
- fprintf(file,
- "Ibuf: size %lu, free list len %lu, seg size %lu,\n"
- "%lu inserts, %lu merged recs, %lu merges\n",
-@@ -3542,6 +3548,12 @@
- }
- }
- #endif
-+ } // if (file)
-+ inno_ibuf_size += (ulong) data->size;
-+ inno_ibuf_inserts += (ulong) data->n_inserts;
-+ inno_ibuf_merged_recs += (ulong) data->n_merged_recs;
-+ inno_ibuf_merges += (ulong) data->n_merges;
-+
- data = UT_LIST_GET_NEXT(data_list, data);
- }
-
-diff -r b059d02ec814 innobase/include/lock0lock.h
---- a/innobase/include/lock0lock.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/lock0lock.h Mon Nov 03 05:09:34 2008 -0800
-@@ -24,6 +24,10 @@
- #endif /* UNIV_DEBUG */
- /* Buffer for storing information about the most recent deadlock error */
- extern FILE* lock_latest_err_file;
-+
-+/* number of deadlocks happened so far */
-+extern ulint innodb_deadlocks;
-+
-
- /*************************************************************************
- Gets the size of a lock struct. */
-diff -r b059d02ec814 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/include/srv0srv.h Mon Nov 03 05:09:34 2008 -0800
-@@ -261,6 +261,12 @@
- /* variable to count the number of random read-aheads were done */
- extern ulint srv_read_ahead_rnd;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+extern ibool srv_long_lock_wait;
-+
-+/* variable to count the number long semaphore waits noticed */
-+extern ulint srv_long_lock_waits;
-+
- /* Number of IO operations read/write done for all threads */
- extern ulint os_aio_read_requests;
- extern ulint os_aio_write_requests;
-@@ -278,6 +284,26 @@
- extern ulint inno_pending_ibuf_aio_reads;
- extern ulint inno_pending_log_ios;
- extern ulint inno_pending_sync_ios;
-+
-+/* all 24 innodb status variables, exported to status */
-+extern ulint inno_transaction_count;
-+extern ulint inno_transaction_purge_count;
-+extern ulint inno_transaction_purge_lag;
-+extern ulint inno_num_active_transactions;
-+extern ulint inno_summed_transaction_age;
-+extern ulint inno_longest_transaction_age;
-+extern ulint inno_lock_wait_timeouts;
-+extern ulint inno_num_lock_waiters;
-+extern ulint inno_summed_lock_wait_time;
-+extern ulint inno_longest_lock_wait;
-+extern ulint inno_os_reads;
-+extern ulint inno_os_writes;
-+extern ulint inno_os_fsyncs;
-+extern ulint inno_ibuf_size;
-+extern ulint inno_ibuf_inserts;
-+extern ulint inno_ibuf_merged_recs;
-+extern ulint inno_ibuf_merges;
-+extern ulint inno_log_ios_done;
-
- /* In this structure we store status variables to be passed to MySQL */
- typedef struct export_var_struct export_struc;
-@@ -552,6 +578,7 @@
- ulint innodb_data_writes;
- ulint innodb_data_written;
- ulint innodb_data_reads;
-+ ulint innodb_dict_size;
- ulint innodb_buffer_pool_pages_total;
- ulint innodb_buffer_pool_pages_data;
- ulint innodb_buffer_pool_pages_dirty;
-@@ -587,6 +614,43 @@
- ulint innodb_rows_inserted;
- ulint innodb_rows_updated;
- ulint innodb_rows_deleted;
-+ ibool innodb_long_lock_wait;
-+ ulint innodb_long_lock_waits;
-+
-+ ulint innodb_os_aio_read_requests;
-+ ulint innodb_os_aio_write_requests;
-+ ulint innodb_os_aio_pages_read;
-+ ulint innodb_os_aio_pages_written;
-+ ib_longlong innodb_os_aio_read_time;
-+ ib_longlong innodb_os_aio_write_time;
-+ ib_longlong innodb_os_aio_read_time_avg;
-+ ib_longlong innodb_os_aio_write_time_avg;
-+ ulint innodb_deadlocks;
-+
-+ // the following 24 variables are exported to "show status"
-+ ulint inno_transaction_count;
-+ ulint inno_transaction_purge_count;
-+ ulint inno_transaction_purge_lag;
-+ ulint inno_num_active_transactions;
-+ ulint inno_summed_transaction_age;
-+ ulint inno_longest_transaction_age;
-+ ulint inno_lock_wait_timeouts;
-+ ulint inno_num_lock_waiters;
-+ ulint inno_summed_lock_wait_time;
-+ ulint inno_longest_lock_wait;
-+ ulint inno_pending_normal_aio_reads;
-+ ulint inno_pending_normal_aio_writes;
-+ ulint inno_pending_ibuf_aio_reads;
-+ ulint inno_pending_log_ios;
-+ ulint inno_pending_sync_ios;
-+ ulint inno_os_reads;
-+ ulint inno_os_writes;
-+ ulint inno_os_fsyncs;
-+ ulint inno_ibuf_size;
-+ ulint inno_ibuf_inserts;
-+ ulint inno_ibuf_merged_recs;
-+ ulint inno_ibuf_merges;
-+ ulint inno_log_ios_done;
- };
-
- /* The server system struct */
-diff -r b059d02ec814 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/lock/lock0lock.c Mon Nov 03 05:09:34 2008 -0800
-@@ -360,6 +360,9 @@
- ibool lock_deadlock_found = FALSE;
- FILE* lock_latest_err_file;
-
-+/* number of deadlocks happened so far */
-+ulint innodb_deadlocks = 0;
-+
- /* Flags for recursive deadlock search */
- #define LOCK_VICTIM_IS_START 1
- #define LOCK_VICTIM_IS_OTHER 2
-@@ -3304,6 +3307,7 @@
-
- FILE* ef = lock_latest_err_file;
-
-+ innodb_deadlocks++;
- rewind(ef);
- ut_print_timestamp(ef);
-
-@@ -4238,6 +4242,7 @@
- innobase_mysql_prepare_print_arbitrary_thd();
- lock_mutex_enter_kernel();
-
-+ if (file) {
- if (lock_deadlock_found) {
- fputs(
- "------------------------\n"
-@@ -4269,6 +4274,12 @@
- fprintf(file,
- "Total number of lock structs in row lock hash table %lu\n",
- (ulong) lock_get_n_rec_locks());
-+ } // if (file)
-+ inno_transaction_purge_count =
-+ (ulong) ut_dulint_get_low(purge_sys->purge_trx_no);
-+ inno_transaction_count =
-+ (ulong) ut_dulint_get_low(trx_sys->max_trx_id);
-+ inno_transaction_purge_lag = (ulong) trx_sys->rseg_history_len;
- }
-
- /*************************************************************************
-@@ -4289,7 +4300,17 @@
- ulint i;
- mtr_t mtr;
- trx_t* trx;
--
-+ time_t current_time = time(NULL);
-+
-+ /* init all counters to be updated */
-+ inno_num_lock_waiters = 0;
-+ inno_summed_lock_wait_time = 0;
-+ inno_longest_lock_wait = 0;
-+ inno_num_active_transactions = 0;
-+ inno_summed_transaction_age = 0;
-+ inno_longest_transaction_age = 0;
-+
-+ if (file) {
- fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
-
- /* First print info on non-active transactions */
-@@ -4304,6 +4325,7 @@
-
- trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
- }
-+ } // if (file)
-
- loop:
- trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
-@@ -4330,6 +4352,7 @@
- }
-
- if (nth_lock == 0) {
-+ if (file) {
- fputs("---", file);
- trx_print(file, trx, 600);
-
-@@ -4341,11 +4364,27 @@
- (ulong) ut_dulint_get_high(trx->read_view->up_limit_id),
- (ulong) ut_dulint_get_low(trx->read_view->up_limit_id));
- }
-+ } // if (file)
-+
-+ if (trx->conc_state == TRX_ACTIVE) {
-+ ulong trx_age = (ulong)difftime(time(NULL), trx->start_time);
-+ inno_num_active_transactions++;
-+ inno_summed_transaction_age += trx_age;
-+ if (inno_longest_transaction_age > trx_age)
-+ inno_longest_transaction_age = trx_age;
-+ }
-
- if (trx->que_state == TRX_QUE_LOCK_WAIT) {
-+ ulong wait_time = (ulong)difftime(current_time,
-+ trx->wait_started);
-+ inno_num_lock_waiters++;
-+ inno_summed_lock_wait_time += wait_time;
-+ if (inno_longest_lock_wait < wait_time)
-+ inno_longest_lock_wait = wait_time;
-+ if (file) {
- fprintf(file,
- "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
-- (ulong)difftime(time(NULL), trx->wait_started));
-+ wait_time);
-
- if (lock_get_type(trx->wait_lock) == LOCK_REC) {
- lock_rec_print(file, trx->wait_lock);
-@@ -4354,10 +4393,16 @@
- }
-
- fputs("------------------\n", file);
-- }
-- }
--
-- if (!srv_print_innodb_lock_monitor) {
-+ } // if (file)
-+ }
-+ }
-+
-+ /* don't print locks per transaction if either
-+ 1) srv_print_innodb_lock_monitor is NOT set,
-+ ie no magic table innodb_lock_monitor is created, or
-+ 2) file == NULL, ie, at counter updating stage from "show status"
-+ */
-+ if (!srv_print_innodb_lock_monitor || !file) {
- nth_trx++;
- goto loop;
- }
-diff -r b059d02ec814 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Nov 03 05:08:52 2008 -0800
-+++ b/innobase/srv/srv0srv.c Mon Nov 03 05:09:34 2008 -0800
-@@ -267,6 +267,35 @@
- ulint inno_pending_log_ios = 0;
- ulint inno_pending_sync_ios = 0;
-
-+/* variable to identify if there is currently a long semaphore wait */
-+ibool srv_long_lock_wait = FALSE;
-+
-+/* variable to count the number long semaphore waits noticed */
-+ulint srv_long_lock_waits = 0;
-+
-+/* time interval in seconds allowed to calling innodb_show_status functions */
-+extern long innobase_min_status_update_time_interval;
-+
-+/* all 24 innodb status variables, exported to status */
-+ulint inno_transaction_count = 0;
-+ulint inno_transaction_purge_count = 0;
-+ulint inno_transaction_purge_lag = 0;
-+ulint inno_num_active_transactions = 0;
-+ulint inno_summed_transaction_age = 0;
-+ulint inno_longest_transaction_age = 0;
-+ulint inno_lock_wait_timeouts = 0; /* Counts number of lock wait timeouts. */
-+ulint inno_num_lock_waiters = 0;
-+ulint inno_summed_lock_wait_time = 0;
-+ulint inno_longest_lock_wait = 0;
-+ulint inno_os_reads = 0;
-+ulint inno_os_writes = 0;
-+ulint inno_os_fsyncs = 0;
-+ulint inno_ibuf_size = 0;
-+ulint inno_ibuf_inserts = 0;
-+ulint inno_ibuf_merged_recs = 0;
-+ulint inno_ibuf_merges = 0;
-+ulint inno_log_ios_done = 0;
-+
- /* structure to pass status variables to MySQL */
- export_struc export_vars;
-
-@@ -419,6 +448,10 @@
- const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
-
- time_t srv_last_monitor_time;
-+
-+/* last time innodb status were updated thru show status */
-+time_t srv_last_innodb_status_time = 0;
-+
-
- mutex_t srv_innodb_monitor_mutex;
-
-@@ -677,6 +710,24 @@
-
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-+
-+/*************************************************************************
-+Prints counters for work done by srv_master_thread. */
-+
-+static
-+void
-+srv_print_extra(
-+/*===================*/
-+ FILE *file) /* in: output stream */
-+{
-+ fprintf(file, "srv_master_thread loops: %lu 1_second, %lu sleeps, "
-+ "%lu 10_second, %lu background, %lu flush\n",
-+ srv_main_1_second_loops, srv_main_sleeps,
-+ srv_main_10_second_loops, srv_main_background_loops,
-+ srv_main_flush_loops);
-+ fprintf(file, "srv_master_thread log flush: %lu sync, %lu async\n",
-+ srv_sync_flush, srv_async_flush);
-+}
-
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-@@ -1685,12 +1736,13 @@
- fputs("----------\n"
- "BACKGROUND THREAD\n"
- "----------\n", file);
-+ srv_print_extra(file);
- fil_print(file);
--
-
- fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
-+ fprintf(file, "Lock wait timeouts %lu\n", inno_lock_wait_timeouts);
- sync_print(file);
-
- /* Conceptually, srv_innodb_monitor_mutex has a very high latching
-@@ -1709,24 +1761,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1815,6 +1849,27 @@
- (srv_n_rows_read - srv_n_rows_read_old)
- / time_elapsed);
-
-+ /* Print open transaction details */
-+ lock_print_info_summary(file);
-+
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- srv_n_rows_inserted_old = srv_n_rows_inserted;
- srv_n_rows_updated_old = srv_n_rows_updated;
- srv_n_rows_deleted_old = srv_n_rows_deleted;
-@@ -1833,7 +1888,8 @@
- void
- srv_export_innodb_status(void)
- {
--
-+ long time_elapsed;
-+ time_t current_time;
- mutex_enter(&srv_innodb_monitor_mutex);
- export_vars.innodb_data_pending_reads= os_n_pending_reads;
- export_vars.innodb_data_pending_writes= os_n_pending_writes;
-@@ -1844,6 +1900,7 @@
- export_vars.innodb_data_reads= os_n_file_reads;
- export_vars.innodb_data_writes= os_n_file_writes;
- export_vars.innodb_data_written= srv_data_written;
-+ export_vars.innodb_dict_size= dict_sys->size;
- export_vars.innodb_buffer_pool_read_requests= buf_pool->n_page_gets;
- export_vars.innodb_buffer_pool_write_requests= srv_buf_pool_write_requests;
- export_vars.innodb_buffer_pool_wait_free= srv_buf_pool_wait_free;
-@@ -1854,10 +1911,12 @@
- export_vars.innodb_buffer_pool_pages_data= UT_LIST_GET_LEN(buf_pool->LRU);
- export_vars.innodb_buffer_pool_pages_dirty= UT_LIST_GET_LEN(buf_pool->flush_list);
- export_vars.innodb_buffer_pool_pages_free= UT_LIST_GET_LEN(buf_pool->free);
-- export_vars.innodb_buffer_pool_pages_latched= buf_get_latched_pages_number();
-+ /* This function uses too much CPU for large buffer caches. */
-+ export_vars.innodb_buffer_pool_pages_latched= 1; /* buf_get_latched_pages_number(); */
- export_vars.innodb_buffer_pool_pages_total= buf_pool->curr_size;
- export_vars.innodb_buffer_pool_pages_misc= buf_pool->max_size -
- UT_LIST_GET_LEN(buf_pool->LRU) - UT_LIST_GET_LEN(buf_pool->free);
-+
- export_vars.innodb_page_size= UNIV_PAGE_SIZE;
- export_vars.innodb_log_waits= srv_log_waits;
- export_vars.innodb_os_log_written= srv_os_log_written;
-@@ -1885,6 +1944,103 @@
- export_vars.innodb_rows_inserted= srv_n_rows_inserted;
- export_vars.innodb_rows_updated= srv_n_rows_updated;
- export_vars.innodb_rows_deleted= srv_n_rows_deleted;
-+ export_vars.innodb_long_lock_wait = srv_long_lock_wait;
-+ export_vars.innodb_long_lock_waits = srv_long_lock_waits;
-+
-+ export_vars.innodb_os_aio_read_requests = os_aio_read_requests;
-+ export_vars.innodb_os_aio_write_requests = os_aio_write_requests;
-+
-+ export_vars.innodb_os_aio_pages_read = os_aio_pages_read;
-+ export_vars.innodb_os_aio_pages_written = os_aio_pages_written;
-+
-+ export_vars.innodb_os_aio_read_time = os_aio_read_time;
-+ export_vars.innodb_os_aio_write_time = os_aio_write_time;
-+
-+ if (os_aio_read_requests > 0 ) {
-+ export_vars.innodb_os_aio_read_time_avg
-+ = os_aio_read_time / os_aio_read_requests;
-+ } else {
-+ export_vars.innodb_os_aio_read_time_avg = 0;
-+ }
-+ if (os_aio_write_requests > 0 ) {
-+ export_vars.innodb_os_aio_write_time_avg
-+ = os_aio_write_time / os_aio_write_requests;
-+ } else {
-+ export_vars.innodb_os_aio_write_time_avg = 0;
-+ }
-+
-+ export_vars.innodb_deadlocks = innodb_deadlocks;
-+
-+ // simulate srv_printf_innodb_monitor, invoked by innodb_show_status
-+ // 0. direct printout inno_lock_wait_timeouts, declared in srv0srv.c
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_lock_wait_timeouts = inno_lock_wait_timeouts;
-+
-+ // *_print functions are allowed to be called once every
-+ // some seconds to prevent too frequent invocation.
-+ // the number is innobase_min_status_update_time_interval
-+ current_time = time(NULL);
-+ time_elapsed = difftime(current_time, srv_last_innodb_status_time);
-+ if (time_elapsed >= innobase_min_status_update_time_interval) {
-+ os_aio_print(NULL);
-+ ibuf_print(NULL);
-+ buf_print_io(NULL);
-+ lock_print_info_summary(NULL);
-+ lock_print_info_all_transactions(NULL);
-+
-+ srv_last_innodb_status_time = current_time;
-+ }
-+
-+ // 1. os_aio_print
-+ // the following were filled by calling os_aio_print
-+ // total # of variable(s) updated: 8
-+
-+ export_vars.inno_pending_normal_aio_reads =
-+ inno_pending_normal_aio_reads;
-+ export_vars.inno_pending_normal_aio_writes =
-+ inno_pending_normal_aio_writes;
-+ export_vars.inno_pending_ibuf_aio_reads = inno_pending_ibuf_aio_reads;
-+ export_vars.inno_pending_log_ios = inno_pending_log_ios;
-+ export_vars.inno_pending_sync_ios = inno_pending_sync_ios;
-+ export_vars.inno_os_reads = os_n_file_reads;
-+ export_vars.inno_os_writes = os_n_file_writes;
-+ export_vars.inno_os_fsyncs = os_n_fsyncs;
-+
-+ // 2. ibuf_print()
-+ // total # of variable(s) updated: 4
-+
-+ export_vars.inno_ibuf_size = inno_ibuf_size;
-+ export_vars.inno_ibuf_inserts = inno_ibuf_inserts;
-+ export_vars.inno_ibuf_merged_recs = inno_ibuf_merged_recs;
-+ export_vars.inno_ibuf_merges = inno_ibuf_merges;
-+
-+ // 3. log_print
-+ // total # of variable(s) updated: 1
-+ export_vars.inno_log_ios_done = (ulong) log_sys->n_log_ios;
-+
-+ // 5. lock_print_info_summary
-+ // it enters the mutexes
-+ // 1) innobase_mysql_prepare_print_arbitrary_thd()
-+ // 2) lock_mutex_enter_kernel()
-+ // total # of variable(s) updated: 3
-+
-+ export_vars.inno_transaction_count = inno_transaction_count;
-+ export_vars.inno_transaction_purge_count =
-+ inno_transaction_purge_count;
-+ export_vars.inno_transaction_purge_lag = inno_transaction_purge_lag;
-+
-+ // 6. lock_print_info_all_transactions(NULL)
-+ // it exits two mutexes entered from lock_print_info_summary(NULL)
-+ // total # of variable(s) updated: 6
-+
-+ export_vars.inno_num_active_transactions = inno_num_active_transactions;
-+ export_vars.inno_summed_transaction_age = inno_summed_transaction_age;
-+ export_vars.inno_longest_transaction_age = inno_longest_transaction_age;
-+
-+ export_vars.inno_num_lock_waiters = inno_num_lock_waiters;
-+ export_vars.inno_summed_lock_wait_time = inno_summed_lock_wait_time;
-+ export_vars.inno_longest_lock_wait = inno_longest_lock_wait;
-+
- mutex_exit(&srv_innodb_monitor_mutex);
-
- }
-@@ -2026,6 +2182,7 @@
- if (thr_get_trx(slot->thr)->wait_lock) {
- lock_cancel_waiting_and_release(
- thr_get_trx(slot->thr)->wait_lock);
-+ ++inno_lock_wait_timeouts;
- }
- }
- }
-diff -r b059d02ec814 patch_info/innodb_extra_status.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_extra_status.info Mon Nov 03 05:09:34 2008 -0800
-@@ -0,0 +1,9 @@
-+File=innodb_extra_status.patch
-+Name=Adds additional information of InnoDB counters into SHOW STATUS
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-03
-+VT: Initial porting
-diff -r b059d02ec814 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -299,12 +299,36 @@
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
- {"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
-+ {"dict_size",
-+ (char*) &export_vars.innodb_dict_size, SHOW_LONG},
- {"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
- {"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
- {"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
-+ {"long_lock_wait",
-+ (char*) &export_vars.innodb_long_lock_wait, SHOW_BOOL},
-+ {"long_lock_waits",
-+ (char*) &export_vars.innodb_long_lock_waits, SHOW_LONG},
-+
-+ {"os_read_requests",
-+ (char*) &export_vars.innodb_os_aio_read_requests, SHOW_LONG},
-+ {"os_write_requests",
-+ (char*) &export_vars.innodb_os_aio_write_requests, SHOW_LONG},
-+ {"os_pages_read",
-+ (char*) &export_vars.innodb_os_aio_pages_read, SHOW_LONG},
-+ {"os_pages_written",
-+ (char*) &export_vars.innodb_os_aio_pages_written, SHOW_LONG},
-+ {"os_read_time",
-+ (char*) &export_vars.innodb_os_aio_read_time, SHOW_LONGLONG},
-+ {"os_write_time",
-+ (char*) &export_vars.innodb_os_aio_write_time, SHOW_LONGLONG},
-+ {"time_per_read",
-+ (char*) &export_vars.innodb_os_aio_read_time_avg, SHOW_LONGLONG},
-+ {"time_per_write",
-+ (char*) &export_vars.innodb_os_aio_write_time_avg, SHOW_LONGLONG},
-+
- {"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
- {"os_log_pending_fsyncs",
-@@ -339,6 +363,56 @@
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
- {"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
-+ {"deadlocks",
-+ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
-+
-+ /* 24 innodb status variables exported to status */
-+ {"transaction_count",
-+ (char*) &export_vars.inno_transaction_count, SHOW_LONG},
-+ {"transaction_purge_count",
-+ (char*) &export_vars.inno_transaction_purge_count, SHOW_LONG},
-+ {"transaction_purge_lag",
-+ (char*) &export_vars.inno_transaction_purge_lag, SHOW_LONG},
-+ {"active_transactions",
-+ (char*) &export_vars.inno_num_active_transactions, SHOW_LONG},
-+ {"summed_transaction_age",
-+ (char*) &export_vars.inno_summed_transaction_age, SHOW_LONG},
-+ {"longest_transaction_age",
-+ (char*) &export_vars.inno_longest_transaction_age, SHOW_LONG},
-+ {"lock_wait_timeouts",
-+ (char*) &export_vars.inno_lock_wait_timeouts, SHOW_LONG},
-+ {"lock_waiters",
-+ (char*) &export_vars.inno_num_lock_waiters, SHOW_LONG},
-+ {"summed_lock_wait_time",
-+ (char*) &export_vars.inno_summed_lock_wait_time, SHOW_LONG},
-+ {"longest_lock_wait",
-+ (char*) &export_vars.inno_longest_lock_wait, SHOW_LONG},
-+ {"pending_normal_aio_reads",
-+ (char*) &export_vars.inno_pending_normal_aio_reads, SHOW_LONG},
-+ {"pending_normal_aio_writes",
-+ (char*) &export_vars.inno_pending_normal_aio_writes, SHOW_LONG},
-+ {"pending_ibuf_aio_reads",
-+ (char*) &export_vars.inno_pending_ibuf_aio_reads, SHOW_LONG},
-+ {"pending_log_ios",
-+ (char*) &export_vars.inno_pending_log_ios, SHOW_LONG},
-+ {"pending_sync_ios",
-+ (char*) &export_vars.inno_pending_sync_ios, SHOW_LONG},
-+ {"os_reads",
-+ (char*) &export_vars.inno_os_reads, SHOW_LONG},
-+ {"os_writes",
-+ (char*) &export_vars.inno_os_writes, SHOW_LONG},
-+ {"os_fsyncs",
-+ (char*) &export_vars.inno_os_fsyncs, SHOW_LONG},
-+ {"ibuf_inserts",
-+ (char*) &export_vars.inno_ibuf_size, SHOW_LONG},
-+ {"ibuf_size",
-+ (char*) &export_vars.inno_ibuf_inserts, SHOW_LONG},
-+ {"ibuf_merged_recs",
-+ (char*) &export_vars.inno_ibuf_merged_recs, SHOW_LONG},
-+ {"ibuf_merges",
-+ (char*) &export_vars.inno_ibuf_merges, SHOW_LONG},
-+ {"log_ios_done",
-+ (char*) &export_vars.inno_log_ios_done, SHOW_LONG},
- {NullS, NullS, SHOW_LONG}};
-
- /* General functions */
-diff -r b059d02ec814 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 03 05:09:34 2008 -0800
-@@ -198,6 +198,7 @@
- extern struct show_var_st innodb_status_variables[];
- extern ulong innobase_fast_shutdown;
- extern long innobase_max_merged_io;
-+extern long innobase_min_status_update_time_interval;
- extern ulong innobase_large_page_size;
- extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
- extern longlong innobase_buffer_pool_size, innobase_log_file_size;
-diff -r b059d02ec814 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/mysqld.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -4950,6 +4950,7 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -6031,6 +6032,14 @@
- (gptr*) &srv_thread_sleep_delay,
- (gptr*) &srv_thread_sleep_delay,
- 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
-+ {"innodb_status_update_interval",
-+ OPT_INNODB_MIN_STATUS_UPDATE_TIME_INTERVAL,
-+ "Minimum time interval in seconds before InnoDB status counters "
-+ "are updated during SHOW STATUS. "
-+ "InnoDB counters are always updated during SHOW INNODB STATUS.",
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ (gptr*) &innobase_min_status_update_time_interval,
-+ 0, GET_LONG, REQUIRED_ARG, 30, 0, 3600, 0, 1, 0},
- #endif /* HAVE_INNOBASE_DB */
- {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
- "The number of seconds the server waits for activity on an interactive connection before closing it.",
-diff -r b059d02ec814 sql/set_var.cc
---- a/sql/set_var.cc Mon Nov 03 05:08:52 2008 -0800
-+++ b/sql/set_var.cc Mon Nov 03 05:09:34 2008 -0800
-@@ -948,6 +948,8 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG },
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG },
- {"innodb_max_merged_io", (char*) &innobase_max_merged_io, SHOW_LONG},
-+ {"innodb_status_update_interval",
-+ (char*) &innobase_min_status_update_time_interval, SHOW_LONG},
- #endif
- {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
- {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20100217/innodb_fsync_source.patch b/percona/5.0.87-b20-20100217/innodb_fsync_source.patch
deleted file mode 100644
index 2961b78..0000000
--- a/percona/5.0.87-b20-20100217/innodb_fsync_source.patch
+++ /dev/null
@@ -1,594 +0,0 @@
-diff -r ef44d8017b6b innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/buf/buf0flu.c Fri Jul 03 15:41:32 2009 -0700
-@@ -341,7 +341,7 @@
-
- /* Now flush the doublewrite buffer data to disk */
-
-- fil_flush(TRX_SYS_SPACE);
-+ fil_flush(TRX_SYS_SPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We know that the writes have been flushed to disk now
- and in recovery we will find them in the doublewrite buffer
-@@ -381,7 +381,7 @@
-
- /* Now we flush the data to disk (for example, with fsync) */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_DIRTY_BUFFER);
-
- /* We can now reuse the doublewrite memory buffer: */
-
-@@ -501,7 +501,8 @@
- }
- #else
- /* Force the log to the disk before writing the modified block */
-- log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_DIRTY_BUFFER);
- #endif
- buf_flush_init_for_writing(block->frame, block->newest_modification,
- block->space, block->offset);
-diff -r ef44d8017b6b innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/fil/fil0fil.c Fri Jul 03 15:41:32 2009 -0700
-@@ -245,6 +245,7 @@
- request */
- UT_LIST_BASE_NODE_T(fil_space_t) space_list;
- /* list of all file spaces */
-+ ulint flush_types[FLUSH_FROM_NUMBER];/* calls to fil_flush by caller */
- };
-
- /* The tablespace memory cache. This variable is NULL before the module is
-@@ -849,7 +850,7 @@
- /* Flush tablespaces so that we can close modified files in the LRU
- list */
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- count++;
-
-@@ -1309,7 +1310,10 @@
-
- UT_LIST_INIT(system->unflushed_spaces);
- UT_LIST_INIT(system->space_list);
--
-+ {
-+ int x;
-+ for (x = 0; x < FLUSH_FROM_NUMBER; ++x) system->flush_types[x] = 0;
-+ }
- return(system);
- }
-
-@@ -1437,6 +1441,23 @@
- }
-
- mutex_exit(&(system->mutex));
-+}
-+
-+/********************************************************************
-+Prints internal counters */
-+
-+void
-+fil_print(FILE *file)
-+{
-+ fprintf(file,
-+ "fsync callers: %lu buffer pool, %lu other, %lu checkpoint, "
-+ "%lu log aio, %lu log sync, %lu archive\n",
-+ fil_system->flush_types[FLUSH_FROM_DIRTY_BUFFER],
-+ fil_system->flush_types[FLUSH_FROM_OTHER],
-+ fil_system->flush_types[FLUSH_FROM_CHECKPOINT],
-+ fil_system->flush_types[FLUSH_FROM_LOG_IO_COMPLETE],
-+ fil_system->flush_types[FLUSH_FROM_LOG_WRITE_UP_TO],
-+ fil_system->flush_types[FLUSH_FROM_ARCHIVE]);
- }
-
- /********************************************************************
-@@ -2256,7 +2277,7 @@
-
- os_thread_sleep(20000);
-
-- fil_flush(id);
-+ fil_flush(id, FLUSH_FROM_OTHER);
-
- goto retry;
-
-@@ -3574,7 +3595,7 @@
- size_after_extend, *actual_size); */
- mutex_exit(&(system->mutex));
-
-- fil_flush(space_id);
-+ fil_flush(space_id, FLUSH_FROM_OTHER);
-
- return(success);
- }
-@@ -4167,8 +4188,9 @@
- void
- fil_flush(
- /*======*/
-- ulint space_id) /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4177,7 +4199,7 @@
- ib_longlong old_mod_counter;
-
- mutex_enter(&(system->mutex));
--
-+ system->flush_types[flush_type]++;
- HASH_SEARCH(hash, system->spaces, space_id, space,
- space->id == space_id);
- if (!space || space->is_being_deleted) {
-@@ -4282,7 +4304,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose) /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type)/* in: identifies the caller */
- {
- fil_system_t* system = fil_system;
- fil_space_t* space;
-@@ -4323,7 +4346,7 @@
- a non-existing space id. */
- for (i = 0; i < n_space_ids; i++) {
-
-- fil_flush(space_ids[i]);
-+ fil_flush(space_ids[i], flush_type);
- }
-
- mem_free(space_ids);
-diff -r ef44d8017b6b innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/fil0fil.h Fri Jul 03 15:41:32 2009 -0700
-@@ -197,6 +197,13 @@
- fil_init(
- /*=====*/
- ulint max_n_open); /* in: max number of open files */
-+/********************************************************************
-+ * Prints internal counters. */
-+
-+void
-+fil_print(
-+ /*=====*/
-+ FILE* file); /* in: output stream */
- /***********************************************************************
- Opens all log files and system tablespace data files. They stay open until the
- database server shutdown. This should be called at a server startup after the
-@@ -625,14 +632,26 @@
- ulint segment); /* in: the number of the segment in the aio
- array to wait for */
- /**************************************************************************
-+Identifies the caller of fil_flush. */
-+typedef enum {
-+ FLUSH_FROM_DIRTY_BUFFER,
-+ FLUSH_FROM_OTHER,
-+ FLUSH_FROM_CHECKPOINT,
-+ FLUSH_FROM_LOG_IO_COMPLETE,
-+ FLUSH_FROM_LOG_WRITE_UP_TO,
-+ FLUSH_FROM_ARCHIVE,
-+ FLUSH_FROM_NUMBER
-+} flush_from_type;
-+/**************************************************************************
- Flushes to disk possible writes cached by the OS. If the space does not exist
- or is being dropped, does not do anything. */
-
- void
- fil_flush(
- /*======*/
-- ulint space_id); /* in: file space id (this can be a group of
-+ ulint space_id, /* in: file space id (this can be a group of
- log files or a tablespace of the database) */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**************************************************************************
- Flushes to disk writes in file spaces of the given type possibly cached by
- the OS. */
-@@ -640,7 +659,8 @@
- void
- fil_flush_file_spaces(
- /*==================*/
-- ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
-+ ulint purpose, /* in: FIL_TABLESPACE, FIL_LOG */
-+ flush_from_type flush_type);/* in: identifies the caller */
- /**********************************************************************
- Checks the consistency of the tablespace cache. */
-
-diff -r ef44d8017b6b innobase/include/log0log.h
---- a/innobase/include/log0log.h Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/include/log0log.h Fri Jul 03 15:41:32 2009 -0700
-@@ -146,6 +146,22 @@
- log_io_complete(
- /*============*/
- log_group_t* group); /* in: log group */
-+
-+/**********************************************************
-+Describes the caller of log_write_up_to. */
-+
-+typedef enum {
-+ LOG_WRITE_FROM_DIRTY_BUFFER,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC,
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC,
-+ LOG_WRITE_FROM_INTERNAL,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC,
-+ LOG_WRITE_FROM_CHECKPOINT_ASYNC,
-+ LOG_WRITE_FROM_LOG_ARCHIVE,
-+ LOG_WRITE_FROM_COMMIT_SYNC,
-+ LOG_WRITE_FROM_COMMIT_ASYNC,
-+ LOG_WRITE_FROM_NUMBER
-+} log_sync_type;
- /**********************************************************
- This function is called, e.g., when a transaction wants to commit. It checks
- that the log has been written to the log file up to the last log entry written
-@@ -159,14 +175,21 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk);
-- /* in: TRUE if we want the written log also to be
-- flushed to disk */
-+ ibool flush_to_disk,
-+ /* in: TRUE if we want the written log also to be flushed to disk */
-+ log_sync_type caller);/* in: identifies the caller */
- /********************************************************************
- Does a syncronous flush of the log buffer to disk. */
-
- void
- log_buffer_flush_to_disk(void);
-+/*==========================*/
-+/********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
- /*==========================*/
- /********************************************************************
- Flushes the log buffer. Forces it to disk depending on the value of
-@@ -751,6 +774,12 @@
- AND flushed to disk */
- ulint n_pending_writes;/* number of currently pending flushes
- or writes */
-+ ulint log_sync_callers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to */
-+ ulint log_sync_syncers[LOG_WRITE_FROM_NUMBER];
-+ /* counts calls to log_write_up_to when log file is sync'd */
-+ ulint n_syncs; /* number of fsyncs done for log file */
-+ ulint n_checkpoints; /* number of calls to log_checkpoint */
- /* NOTE on the 'flush' in names of the fields below: starting from
- 4.0.14, we separate the write of the log file and the actual fsync()
- or other method to flush it to disk. The names below shhould really
-diff -r ef44d8017b6b innobase/log/log0log.c
---- a/innobase/log/log0log.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/log/log0log.c Fri Jul 03 15:41:32 2009 -0700
-@@ -782,6 +782,15 @@
- log_sys->written_to_all_lsn = log_sys->lsn;
-
- log_sys->n_pending_writes = 0;
-+ {
-+ int x;
-+ for (x = 0; x < LOG_WRITE_FROM_NUMBER; ++x) {
-+ log_sys->log_sync_callers[x] = 0;
-+ log_sys->log_sync_syncers[x] = 0;
-+ }
-+ }
-+ log_sys->n_syncs = 0;
-+ log_sys->n_checkpoints = 0;
-
- log_sys->no_flush_event = os_event_create(NULL);
-
-@@ -1066,7 +1075,7 @@
- if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- #ifdef UNIV_DEBUG
-@@ -1088,7 +1097,7 @@
- && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
- && srv_flush_log_at_trx_commit != 2) {
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_IO_COMPLETE);
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1303,9 +1312,10 @@
- be written, ut_dulint_max if not specified */
- ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
- or LOG_WAIT_ALL_GROUPS */
-- ibool flush_to_disk)
-+ ibool flush_to_disk,
- /* in: TRUE if we want the written log also to be
- flushed to disk */
-+ log_sync_type caller) /* in: identifies caller */
- {
- log_group_t* group;
- ulint start_offset;
-@@ -1315,6 +1325,7 @@
- ulint loop_count;
- ulint unlock;
-
-+ log_sys->log_sync_callers[caller]++;
- if (recv_no_ibuf_operations) {
- /* Recovery is running and no operations on the log files are
- allowed yet (the variable name .._no_ibuf_.. is misleading) */
-@@ -1465,13 +1476,17 @@
- so we have also flushed to disk what we have written */
-
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
-
- } else if (flush_to_disk) {
-
- group = UT_LIST_GET_FIRST(log_sys->log_groups);
-
-- fil_flush(group->space_id);
-+ fil_flush(group->space_id, FLUSH_FROM_LOG_WRITE_UP_TO);
- log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
-+ log_sys->n_syncs++;
-+ log_sys->log_sync_syncers[caller]++;
- }
-
- mutex_enter(&(log_sys->mutex));
-@@ -1520,7 +1535,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_BACKGROUND_SYNC);
- }
-
- /********************************************************************
-@@ -1574,7 +1590,7 @@
- mutex_exit(&(log->mutex));
-
- if (do_flush) {
-- log_write_up_to(lsn, LOG_NO_WAIT, FALSE);
-+ log_write_up_to(lsn, LOG_NO_WAIT, FALSE, LOG_WRITE_FROM_INTERNAL);
- }
- }
-
-@@ -1944,11 +1960,11 @@
- }
-
- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_CHECKPOINT);
- }
-
- mutex_enter(&(log_sys->mutex));
--
-+ log_sys->n_checkpoints++;
- oldest_lsn = log_buf_pool_get_oldest_modification();
-
- mutex_exit(&(log_sys->mutex));
-@@ -1961,7 +1977,8 @@
- write-ahead-logging algorithm ensures that the log has been flushed
- up to oldest_lsn. */
-
-- log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(oldest_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_CHECKPOINT_SYNC);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2589,7 +2606,7 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- fil_flush(group->archive_space_id);
-+ fil_flush(group->archive_space_id, FLUSH_FROM_ARCHIVE);
-
- mutex_enter(&(log_sys->mutex));
-
-@@ -2670,7 +2687,8 @@
-
- mutex_exit(&(log_sys->mutex));
-
-- log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE);
-+ log_write_up_to(limit_lsn, LOG_WAIT_ALL_GROUPS, TRUE,
-+ LOG_WRITE_FROM_LOG_ARCHIVE);
-
- calc_new_limit = FALSE;
-
-@@ -3207,8 +3225,8 @@
- }
- mutex_exit(&kernel_mutex);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-- fil_flush_file_spaces(FIL_LOG);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-+ fil_flush_file_spaces(FIL_LOG, FLUSH_FROM_OTHER);
-
- /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
- pool: therefore it is essential that the buffer pool has been
-@@ -3241,7 +3259,7 @@
-
- fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- fil_close_all_files();
-
-@@ -3363,15 +3381,45 @@
- time_elapsed = 0.001 + difftime(current_time,
- log_sys->last_printout_time);
- fprintf(file,
-- "%lu pending log writes, %lu pending chkp writes\n"
-- "%lu log i/o's done, %.2f log i/o's/second\n",
-- (ulong) log_sys->n_pending_writes,
-- (ulong) log_sys->n_pending_checkpoint_writes,
-- (ulong) log_sys->n_log_ios,
-- ((log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed));
-+ "%lu pending log writes, %lu pending chkp writes\n"
-+ "%lu log i/o's done, %.2f log i/o's/second, %lu syncs, %lu checkpoints\n",
-+ (ulong) log_sys->n_pending_writes,
-+ (ulong) log_sys->n_pending_checkpoint_writes,
-+ (ulong) log_sys->n_log_ios,
-+ (log_sys->n_log_ios - log_sys->n_log_ios_old) / time_elapsed,
-+ log_sys->n_syncs,
-+ log_sys->n_checkpoints);
-
- log_sys->n_log_ios_old = log_sys->n_log_ios;
- log_sys->last_printout_time = current_time;
-+
-+ fprintf(file,
-+ "log sync callers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_callers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-+
-+ fprintf(file,
-+ "log sync syncers: %lu buffer pool, background %lu sync and %lu async, "
-+ "%lu internal, checkpoint %lu sync and %lu async, %lu archive, "
-+ "commit %lu sync and %lu async\n",
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_DIRTY_BUFFER],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_BACKGROUND_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_INTERNAL],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_CHECKPOINT_ASYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_LOG_ARCHIVE],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_SYNC],
-+ log_sys->log_sync_syncers[LOG_WRITE_FROM_COMMIT_ASYNC]);
-
- mutex_exit(&(log_sys->mutex));
- }
-diff -r ef44d8017b6b innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/srv/srv0srv.c Fri Jul 03 15:41:32 2009 -0700
-@@ -1698,6 +1698,12 @@
- (ulong)time_elapsed);
-
- fputs("----------\n"
-+ "BACKGROUND THREAD\n"
-+ "----------\n", file);
-+ fil_print(file);
-+
-+
-+ fputs("----------\n"
- "SEMAPHORES\n"
- "----------\n", file);
- sync_print(file);
-diff -r ef44d8017b6b innobase/trx/trx0sys.c
---- a/innobase/trx/trx0sys.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0sys.c Fri Jul 03 15:41:32 2009 -0700
-@@ -511,7 +511,7 @@
- page += UNIV_PAGE_SIZE;
- }
-
-- fil_flush_file_spaces(FIL_TABLESPACE);
-+ fil_flush_file_spaces(FIL_TABLESPACE, FLUSH_FROM_OTHER);
-
- leave_func:
- ut_free(unaligned_read_buf);
-diff -r ef44d8017b6b innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Fri Jul 03 15:41:25 2009 -0700
-+++ b/innobase/trx/trx0trx.c Fri Jul 03 15:41:32 2009 -0700
-@@ -942,19 +942,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1701,18 +1703,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush them to
- disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-@@ -1948,19 +1953,21 @@
- if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP,
-- FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- /* Write the log to the log files AND flush
- them to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE,
-+ LOG_WRITE_FROM_COMMIT_SYNC);
- }
- } else if (srv_flush_log_at_trx_commit == 2) {
-
- /* Write the log but do not flush it to disk */
-
-- log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE);
-+ log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, FALSE,
-+ LOG_WRITE_FROM_COMMIT_ASYNC);
- } else {
- ut_error;
- }
-diff -r ef44d8017b6b patch_info/innodb_fsync_source.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_fsync_source.info Fri Jul 03 15:41:32 2009 -0700
-@@ -0,0 +1,9 @@
-+File=innodb_fsync_source.patch
-+Name=Information of fsync callers in InnoDB
-+Version=1.0
-+Author=Google
-+License=GPL
-+Comment=
-+ChangeLog=
-+2008-11-01
-+VT: Initial porting
diff --git a/percona/5.0.87-b20-20100217/innodb_io_patches.patch b/percona/5.0.87-b20-20100217/innodb_io_patches.patch
deleted file mode 100644
index aaef29a..0000000
--- a/percona/5.0.87-b20-20100217/innodb_io_patches.patch
+++ /dev/null
@@ -1,1379 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-05-08 06:12:03.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-07-02 16:44:49.000000000 +0900
-@@ -898,10 +898,17 @@
-
- old_page_count = page_count;
-
-+ if (srv_flush_neighbor_pages) {
- /* Try to flush also all the neighbors */
- page_count +=
- buf_flush_try_neighbors(space, offset,
- flush_type);
-+ } else {
-+ /* Try to flush the page only */
-+ page_count +=
-+ buf_flush_try_page(space, offset,
-+ flush_type);
-+ }
- /* fprintf(stderr,
- "Flush type %lu, page no %lu, neighb %lu\n",
- flush_type, offset,
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-07-02 16:44:49.000000000 +0900
-@@ -20,6 +20,7 @@
- #include "os0file.h"
- #include "srv0start.h"
-
-+extern uint srv_read_ahead;
- extern ulint srv_read_ahead_rnd;
- extern ulint srv_read_ahead_seq;
- extern ulint srv_buf_pool_reads;
-@@ -189,6 +190,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 1)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-@@ -396,6 +401,10 @@
- ulint err;
- ulint i;
-
-+ if (!(srv_read_ahead & 2)) {
-+ return(0);
-+ }
-+
- if (srv_startup_is_before_trx_rollback_phase) {
- /* No read-ahead to avoid thread deadlocks */
- return(0);
-diff -ruN a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
---- a/innobase/ibuf/ibuf0ibuf.c 2009-05-08 06:12:04.000000000 +0900
-+++ b/innobase/ibuf/ibuf0ibuf.c 2009-07-02 16:44:49.000000000 +0900
-@@ -370,8 +370,9 @@
- grow in size, as the references on the upper levels of the tree can
- change */
-
-- ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-- / IBUF_POOL_SIZE_PER_MAX_SIZE;
-+ ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
-+ / IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
-+ srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
- ibuf->meter = IBUF_THRESHOLD + 1;
-
- UT_LIST_INIT(ibuf->data_list);
-@@ -2258,11 +2259,13 @@
-
- mutex_enter(&ibuf_mutex);
-
-+ if (!srv_ibuf_active_contract) {
- if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
- mutex_exit(&ibuf_mutex);
-
- return;
- }
-+ }
-
- sync = FALSE;
-
-diff -ruN a/innobase/include/log0log.h b/innobase/include/log0log.h
---- a/innobase/include/log0log.h 2009-05-08 06:12:06.000000000 +0900
-+++ b/innobase/include/log0log.h 2009-07-02 16:44:49.000000000 +0900
-@@ -169,6 +169,13 @@
- log_buffer_flush_to_disk(void);
- /*==========================*/
- /********************************************************************
-+Flushes the log buffer. Forces it to disk depending on the value of
-+the configuration parameter innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void);
-+/*=============================*/
-+/********************************************************************
- Advances the smallest lsn for which there are unflushed dirty blocks in the
- buffer pool and also may make a new checkpoint. NOTE: this function may only
- be called if the calling thread owns no synchronization objects! */
-diff -ruN a/innobase/include/os0file.h b/innobase/include/os0file.h
---- a/innobase/include/os0file.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/os0file.h 2009-07-02 16:44:49.000000000 +0900
-@@ -551,8 +551,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads */
-+ ulint n_write_threads, /**/
- ulint n_slots_sync); /* in: number of slots in the sync aio array */
- /***********************************************************************
- Requests an asynchronous i/o operation. */
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-02 18:02:38.000000000 +0900
-@@ -89,6 +89,8 @@
- extern ulint srv_lock_table_size;
-
- extern ulint srv_n_file_io_threads;
-+extern ulint srv_n_read_io_threads;
-+extern ulint srv_n_write_io_threads;
-
- #ifdef UNIV_LOG_ARCHIVE
- extern ibool srv_log_archive_on;
-@@ -133,6 +135,15 @@
- extern ulong srv_max_purge_lag;
- extern ibool srv_use_awe;
- extern ibool srv_use_adaptive_hash_indexes;
-+
-+extern ulint srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulint srv_ibuf_active_contract;
-+extern ulint srv_ibuf_accel_rate;
-+extern ulint srv_flush_neighbor_pages;
-+extern ulint srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -ruN a/innobase/log/log0log.c b/innobase/log/log0log.c
---- a/innobase/log/log0log.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/log/log0log.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1524,6 +1524,29 @@
- }
-
- /********************************************************************
-+Flush the log buffer. Force it to disk depending on the value of
-+innodb_flush_log_at_trx_commit. */
-+
-+void
-+log_buffer_flush_maybe_sync(void)
-+/*=============================*/
-+{
-+ dulint lsn;
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ /* Force log buffer to disk when innodb_flush_log_at_trx_commit = 1. */
-+ log_write_up_to(lsn, LOG_WAIT_ALL_GROUPS,
-+ srv_flush_log_at_trx_commit == 1 ? TRUE : FALSE,
-+ srv_flush_log_at_trx_commit == 1 ?
-+ LOG_WRITE_FROM_BACKGROUND_SYNC :
-+ LOG_WRITE_FROM_BACKGROUND_ASYNC);
-+}
-+/********************************************************************
- Tries to establish a big enough margin of free space in the log buffer, such
- that a new log entry can be catenated without an immediate need for a flush. */
- static
-@@ -3326,6 +3349,15 @@
- (ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
- (ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
-
-+ fprintf(file,
-+ "Max checkpoint age %lu\n"
-+ "Modified age %lu\n"
-+ "Checkpoint age %lu\n",
-+ (ulong) log_sys->max_checkpoint_age,
-+ (ulong) ut_dulint_minus(log_sys->lsn,
-+ log_buf_pool_get_oldest_modification()),
-+ (ulong) ut_dulint_minus(log_sys->lsn, log_sys->last_checkpoint_lsn));
-+
- current_time = time(NULL);
-
- time_elapsed = 0.001 + difftime(current_time,
-diff -ruN a/innobase/os/os0file.c b/innobase/os/os0file.c
---- a/innobase/os/os0file.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/os/os0file.c 2009-07-02 16:44:49.000000000 +0900
-@@ -66,6 +66,28 @@
-
- ibool os_aio_print_debug = FALSE;
-
-+/* State for the state of an IO request in simulated AIO.
-+ Protocol for simulated aio:
-+ client requests IO: find slot with reserved = FALSE. Add entry with
-+ status = OS_AIO_NOT_ISSUED.
-+ IO thread wakes: find adjacent slots with reserved = TRUE and status =
-+ OS_AIO_NOT_ISSUED. Change status for slots to
-+ OS_AIO_ISSUED.
-+ IO operation completes: set status for slots to OS_AIO_DONE. set status
-+ for the first slot to OS_AIO_CLAIMED and return
-+ result for that slot.
-+ When there are multiple read and write threads, they all compete to execute
-+ the requests in the array (os_aio_array_t). This avoids the need to load
-+ balance requests at the time the request is made at the cost of waking all
-+ threads when a request is available.
-+*/
-+typedef enum {
-+ OS_AIO_NOT_ISSUED, /* Available to be processed by an IO thread. */
-+ OS_AIO_ISSUED, /* Being processed by an IO thread. */
-+ OS_AIO_DONE, /* Request processed. */
-+ OS_AIO_CLAIMED /* Result being returned to client. */
-+} os_aio_status;
-+
- /* The aio array slot structure */
- typedef struct os_aio_slot_struct os_aio_slot_t;
-
-@@ -74,6 +96,8 @@
- ulint pos; /* index of the slot in the aio
- array */
- ibool reserved; /* TRUE if this slot is reserved */
-+ os_aio_status status; /* Status for current request. Valid when reserved
-+ is TRUE. Used only in simulated aio. */
- time_t reservation_time;/* time when reserved */
- ulint len; /* length of the block to read or
- write */
-@@ -84,11 +108,11 @@
- ulint offset_high; /* 32 high bits of file offset */
- os_file_t file; /* file where to read or write */
- const char* name; /* file name or path */
-- ibool io_already_done;/* used only in simulated aio:
-- TRUE if the physical i/o already
-- made and only the slot message
-- needs to be passed to the caller
-- of os_aio_simulated_handle */
-+// ibool io_already_done;/* used only in simulated aio:
-+// TRUE if the physical i/o already
-+// made and only the slot message
-+// needs to be passed to the caller
-+// of os_aio_simulated_handle */
- fil_node_t* message1; /* message which is given by the */
- void* message2; /* the requester of an aio operation
- and which can be used to identify
-@@ -137,6 +161,13 @@
- /* Array of events used in simulated aio */
- os_event_t* os_aio_segment_wait_events = NULL;
-
-+/* Number for the first global segment for reading. */
-+const ulint os_aio_first_read_segment = 2;
-+
-+/* Number for the first global segment for writing. Set to
-+2 + os_aio_read_write_threads. */
-+ulint os_aio_first_write_segment = 0;
-+
- /* The aio arrays for non-ibuf i/o and ibuf i/o, as well as sync aio. These
- are NULL when the module has not yet been initialized. */
- static os_aio_array_t* os_aio_read_array = NULL;
-@@ -145,11 +176,17 @@
- static os_aio_array_t* os_aio_log_array = NULL;
- static os_aio_array_t* os_aio_sync_array = NULL;
-
-+/* Per thread buffer used for merged IO requests. Used by
-+os_aio_simulated_handle so that a buffer doesn't have to be allocated
-+for each request. */
-+static char* os_aio_thread_buffer[SRV_MAX_N_IO_THREADS];
-+static ulint os_aio_thread_buffer_size[SRV_MAX_N_IO_THREADS];
-+
- static ulint os_aio_n_segments = ULINT_UNDEFINED;
-
- /* If the following is TRUE, read i/o handler threads try to
- wait until a batch of new read requests have been posted */
--static ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-+static volatile ibool os_aio_recommend_sleep_for_read_threads = FALSE;
-
- ulint os_n_file_reads = 0;
- ulint os_bytes_read_since_printout = 0;
-@@ -2878,8 +2915,10 @@
- /*========*/
- ulint n, /* in: maximum number of pending aio operations
- allowed; n must be divisible by n_segments */
-- ulint n_segments, /* in: combined number of segments in the four
-- first aio arrays; must be >= 4 */
-+// ulint n_segments, /* in: combined number of segments in the four
-+// first aio arrays; must be >= 4 */
-+ ulint n_read_threads, /* n_segments == 2 + n_read_threads + n_write_threads*/
-+ ulint n_write_threads, /**/
- ulint n_slots_sync) /* in: number of slots in the sync aio array */
- {
- ulint n_read_segs;
-@@ -2889,6 +2928,8 @@
- #ifdef POSIX_ASYNC_IO
- sigset_t sigset;
- #endif
-+ ulint n_segments = 2 + n_read_threads + n_write_threads;
-+
- ut_ad(n % n_segments == 0);
- ut_ad(n_segments >= 4);
-
-@@ -2896,14 +2937,17 @@
-
- for (i = 0; i < n_segments; i++) {
- srv_set_io_thread_op_info(i, "not started yet");
-+ os_aio_thread_buffer[i] = 0;
-+ os_aio_thread_buffer_size[i] = 0;
- }
-
- n_per_seg = n / n_segments;
-- n_write_segs = (n_segments - 2) / 2;
-- n_read_segs = n_segments - 2 - n_write_segs;
-+ n_write_segs = n_write_threads;
-+ n_read_segs = n_read_threads;
-
- /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
-
-+ os_aio_first_write_segment = os_aio_first_read_segment + n_read_threads;
- os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
-
- srv_io_thread_function[0] = "insert buffer thread";
-@@ -2912,14 +2956,14 @@
-
- srv_io_thread_function[1] = "log thread";
-
-- os_aio_read_array = os_aio_array_create(n_read_segs * n_per_seg,
-+ os_aio_read_array = os_aio_array_create(n_per_seg,
- n_read_segs);
- for (i = 2; i < 2 + n_read_segs; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
- srv_io_thread_function[i] = "read thread";
- }
-
-- os_aio_write_array = os_aio_array_create(n_write_segs * n_per_seg,
-+ os_aio_write_array = os_aio_array_create(n_per_seg,
- n_write_segs);
- for (i = 2 + n_read_segs; i < n_segments; i++) {
- ut_a(i < SRV_MAX_N_IO_THREADS);
-@@ -3181,6 +3225,13 @@
- struct aiocb* control;
- #endif
- ulint i;
-+ ulint prim_segment;
-+ ulint n;
-+
-+ n = array->n_slots / array->n_segments;
-+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
-+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
-+
- loop:
- os_mutex_enter(array->mutex);
-
-@@ -3199,6 +3250,16 @@
- goto loop;
- }
-
-+ for (i = prim_segment * n; i < array->n_slots; i++) {
-+ slot = os_aio_array_get_nth_slot(array, i);
-+
-+ if (slot->reserved == FALSE) {
-+ break;
-+ }
-+ }
-+
-+ if (slot->reserved == TRUE){
-+ /* Not found after the intended segment. So we should search before. */
- for (i = 0;; i++) {
- slot = os_aio_array_get_nth_slot(array, i);
-
-@@ -3206,6 +3267,7 @@
- break;
- }
- }
-+ }
-
- array->n_reserved++;
-
-@@ -3228,7 +3290,8 @@
- slot->buf = buf;
- slot->offset = offset;
- slot->offset_high = offset_high;
-- slot->io_already_done = FALSE;
-+// slot->io_already_done = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- #ifdef WIN_ASYNC_IO
- control = &(slot->control);
-@@ -3281,6 +3344,7 @@
- ut_ad(slot->reserved);
-
- slot->reserved = FALSE;
-+ slot->status = OS_AIO_NOT_ISSUED;
-
- array->n_reserved--;
-
-@@ -3317,16 +3381,18 @@
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
- os_mutex_enter(array->mutex);
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-+ if (slot->reserved &&
-+ (slot->status == OS_AIO_NOT_ISSUED ||
-+ slot->status == OS_AIO_DONE)) {
- /* Found an i/o request */
-
- break;
-@@ -3336,7 +3402,25 @@
- os_mutex_exit(array->mutex);
-
- if (i < n) {
-- os_event_set(os_aio_segment_wait_events[global_segment]);
-+ if (array == os_aio_ibuf_array) {
-+ os_event_set(os_aio_segment_wait_events[0]);
-+
-+ } else if (array == os_aio_log_array) {
-+ os_event_set(os_aio_segment_wait_events[1]);
-+
-+ } else if (array == os_aio_read_array) {
-+ ulint x;
-+ for (x = os_aio_first_read_segment; x < os_aio_first_write_segment; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else if (array == os_aio_write_array) {
-+ ulint x;
-+ for (x = os_aio_first_write_segment; x < os_aio_n_segments; x++)
-+ os_event_set(os_aio_segment_wait_events[x]);
-+
-+ } else {
-+ ut_a(0);
-+ }
- }
- }
-
-@@ -3347,8 +3431,6 @@
- os_aio_simulated_wake_handler_threads(void)
- /*=======================================*/
- {
-- ulint i;
--
- if (os_aio_use_native_aio) {
- /* We do not use simulated aio: do nothing */
-
-@@ -3357,9 +3439,10 @@
-
- os_aio_recommend_sleep_for_read_threads = FALSE;
-
-- for (i = 0; i < os_aio_n_segments; i++) {
-- os_aio_simulated_wake_handler_thread(i);
-- }
-+ os_aio_simulated_wake_handler_thread(0);
-+ os_aio_simulated_wake_handler_thread(1);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_read_segment);
-+ os_aio_simulated_wake_handler_thread(os_aio_first_write_segment);
- }
-
- /**************************************************************************
-@@ -3640,7 +3723,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- if (array == os_aio_sync_array) {
- os_event_wait(os_aio_array_get_nth_slot(array, pos)->event);
-@@ -3648,12 +3731,12 @@
- } else {
- srv_set_io_thread_op_info(orig_seg, "wait Windows aio");
- i = os_event_wait_multiple(n,
-- (array->native_events) + segment * n);
-+ (array->native_events));
- }
-
- os_mutex_enter(array->mutex);
-
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
- ut_a(slot->reserved);
-
-@@ -3830,10 +3913,13 @@
- os_aio_slot_t* slot;
- os_aio_slot_t* slot2;
- os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE];
-+ os_aio_slot_t* lowest_request;
-+ os_aio_slot_t* oldest_request;
- ulint n_consecutive;
- ulint total_len;
- ulint offs;
- ulint lowest_offset;
-+ ulint oldest_offset;
- ulint biggest_age;
- ulint age;
- byte* combined_buf;
-@@ -3841,6 +3927,7 @@
- ibool ret;
- ulint n;
- ulint i;
-+ time_t now;
-
- segment = os_aio_get_array_and_local_segment(&array, global_segment);
-
-@@ -3853,7 +3940,7 @@
- ut_ad(os_aio_validate());
- ut_ad(segment < array->n_segments);
-
-- n = array->n_slots / array->n_segments;
-+ n = array->n_slots;
-
- /* Look through n slots after the segment * n'th slot */
-
-@@ -3875,9 +3962,9 @@
- done */
-
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved && slot->io_already_done) {
-+ if (slot->reserved && slot->status == OS_AIO_DONE) {
-
- if (os_aio_print_debug) {
- fprintf(stderr,
-@@ -3897,67 +3984,57 @@
- then pick the one at the lowest offset. */
-
- biggest_age = 0;
-- lowest_offset = ULINT_MAX;
-+ now = time(NULL);
-+ oldest_request = lowest_request = NULL;
-+ oldest_offset = lowest_offset = ULINT_MAX;
-
-+ /* Find the oldest request and the request with the smallest offset */
- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot = os_aio_array_get_nth_slot(array, i);
-
-- if (slot->reserved) {
-- age = (ulint)difftime(time(NULL),
-- slot->reservation_time);
-+ if (slot->reserved && slot->status == OS_AIO_NOT_ISSUED) {
-+ age = (ulint)difftime(now, slot->reservation_time);
-
- if ((age >= 2 && age > biggest_age)
- || (age >= 2 && age == biggest_age
-- && slot->offset < lowest_offset)) {
-+ && slot->offset < oldest_offset)) {
-
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
- biggest_age = age;
-- lowest_offset = slot->offset;
-+ oldest_request = slot;
-+ oldest_offset = slot->offset;
- }
-- }
-- }
--
-- if (n_consecutive == 0) {
-- /* There were no old requests. Look for an i/o request at the
-- lowest offset in the array (we ignore the high 32 bits of the
-- offset in these heuristics) */
--
-- lowest_offset = ULINT_MAX;
--
-- for (i = 0; i < n; i++) {
-- slot = os_aio_array_get_nth_slot(array,
-- i + segment * n);
--
-- if (slot->reserved && slot->offset < lowest_offset) {
-
-+ /* Look for an i/o request at the lowest offset in the array
-+ * (we ignore the high 32 bits of the offset) */
-+ if (slot->offset < lowest_offset) {
- /* Found an i/o request */
-- consecutive_ios[0] = slot;
--
-- n_consecutive = 1;
--
-+ lowest_request = slot;
- lowest_offset = slot->offset;
- }
- }
- }
-
-- if (n_consecutive == 0) {
-+ if (!lowest_request && !oldest_request) {
-
- /* No i/o requested at the moment */
-
- goto wait_for_io;
- }
-
-- slot = consecutive_ios[0];
-+ if (oldest_request) {
-+ slot = oldest_request;
-+ } else {
-+ slot = lowest_request;
-+ }
-+ consecutive_ios[0] = slot;
-+ n_consecutive = 1;
-
- /* Check if there are several consecutive blocks to read or write */
-
- consecutive_loop:
- for (i = 0; i < n; i++) {
-- slot2 = os_aio_array_get_nth_slot(array, i + segment * n);
-+ slot2 = os_aio_array_get_nth_slot(array, i);
-
- if (slot2->reserved && slot2 != slot
- && slot2->offset == slot->offset + slot->len
-@@ -3965,7 +4042,8 @@
- sum does not wrap over */
- && slot2->offset_high == slot->offset_high
- && slot2->type == slot->type
-- && slot2->file == slot->file) {
-+ && slot2->file == slot->file
-+ && slot2->status == OS_AIO_NOT_ISSUED) {
-
- /* Found a consecutive i/o request */
-
-@@ -3994,6 +4072,8 @@
-
- for (i = 0; i < n_consecutive; i++) {
- total_len += consecutive_ios[i]->len;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_NOT_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_ISSUED;
- }
-
- if (n_consecutive == 1) {
-@@ -4001,7 +4081,14 @@
- combined_buf = slot->buf;
- combined_buf2 = NULL;
- } else {
-- combined_buf2 = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ if ((total_len + UNIV_PAGE_SIZE) > os_aio_thread_buffer_size[global_segment]) {
-+ if (os_aio_thread_buffer[global_segment])
-+ ut_free(os_aio_thread_buffer[global_segment]);
-+
-+ os_aio_thread_buffer[global_segment] = ut_malloc(total_len + UNIV_PAGE_SIZE);
-+ os_aio_thread_buffer_size[global_segment] = total_len + UNIV_PAGE_SIZE;
-+ }
-+ combined_buf2 = os_aio_thread_buffer[global_segment];
-
- ut_a(combined_buf2);
-
-@@ -4012,6 +4099,9 @@
- this assumes that there is just one i/o-handler thread serving
- a single segment of slots! */
-
-+ ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_ISSUED);
-+
- os_mutex_exit(array->mutex);
-
- if (slot->type == OS_FILE_WRITE && n_consecutive > 1) {
-@@ -4081,16 +4171,13 @@
- }
- }
-
-- if (combined_buf2) {
-- ut_free(combined_buf2);
-- }
--
- os_mutex_enter(array->mutex);
-
- /* Mark the i/os done in slots */
-
- for (i = 0; i < n_consecutive; i++) {
-- consecutive_ios[i]->io_already_done = TRUE;
-+ ut_a(consecutive_ios[i]->status == OS_AIO_ISSUED);
-+ consecutive_ios[i]->status = OS_AIO_DONE;
- }
-
- /* We return the messages for the first slot now, and if there were
-@@ -4100,6 +4187,8 @@
- slot_io_done:
-
- ut_a(slot->reserved);
-+ ut_a(slot->status == OS_AIO_DONE);
-+ slot->status = OS_AIO_CLAIMED;
-
- *message1 = slot->message1;
- *message2 = slot->message2;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-02 16:43:23.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-02 18:36:54.000000000 +0900
-@@ -167,6 +167,8 @@
- ulint srv_lock_table_size = ULINT_MAX;
-
- ulint srv_n_file_io_threads = ULINT_MAX;
-+ulint srv_n_read_io_threads = 1;
-+ulint srv_n_write_io_threads = 1;
-
- #ifdef UNIV_LOG_ARCHIVE
- ibool srv_log_archive_on = FALSE;
-@@ -330,6 +332,24 @@
- ibool srv_use_awe = FALSE;
- ibool srv_use_adaptive_hash_indexes = TRUE;
-
-+ulint srv_io_capacity = 100;
-+
-+/* Returns the number of IO operations that is X percent of the capacity.
-+PCT_IO(5) -> returns the number of IO operations that is 5% of the max
-+where max is srv_io_capacity. */
-+#define PCT_IO(pct) ((ulint) (srv_io_capacity * ((double) pct / 100.0)))
-+
-+long long srv_ibuf_max_size = 0;
-+ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
-+ulint srv_ibuf_accel_rate = 100;
-+#define PCT_IBUF_IO(pct) ((ulint) (srv_io_capacity * srv_ibuf_accel_rate * ((double) pct / 10000.0)))
-+
-+ulint srv_flush_neighbor_pages = 1; /* 0:disable 1:enable */
-+
-+ulint srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
-+
-+uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
-+uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-@@ -2228,6 +2248,10 @@
- ulint n_pend_ios;
- ibool skip_sleep = FALSE;
- ulint i;
-+
-+ dulint lsn_old;
-+
-+ dulint oldest_lsn;
-
- #ifdef UNIV_DEBUG_THREAD_CREATION
- fprintf(stderr, "Master thread starts, id %lu\n",
-@@ -2244,6 +2268,9 @@
-
- mutex_exit(&kernel_mutex);
-
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- os_event_set(srv_sys->operational);
- loop:
- /*****************************************************************/
-@@ -2279,6 +2306,18 @@
- if (!skip_sleep) {
-
- os_thread_sleep(1000000);
-+ /*
-+ mutex_enter(&(log_sys->mutex));
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ dulint lsn = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ if (!ut_dulint_is_zero(oldest_lsn))
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old));
-+ */
- }
-
- skip_sleep = FALSE;
-@@ -2317,13 +2356,14 @@
- + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) {
-+ if (n_pend_ios < PCT_IO(3) && (n_ios - n_ios_old < PCT_IO(5))) {
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- if (buf_get_modified_ratio_pct() >
-@@ -2332,7 +2372,7 @@
- /* Try to keep the number of modified pages in the
- buffer pool under the limit wished by the user */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
-
- /* If we had to do the flush, it may have taken
-@@ -2341,6 +2381,140 @@
- iteration of this loop. */
-
- skip_sleep = TRUE;
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (srv_adaptive_checkpoint == 1) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 4)) {
-+
-+ /* 2nd defence line (max_checkpoint_age * 3/4) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* 1st defence line (max_checkpoint_age * 1/2) */
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
-+ ut_dulint_max);
-+ skip_sleep = TRUE;
-+ } else {
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+ } else if (srv_adaptive_checkpoint == 2) {
-+
-+ /* Try to keep modified age not to exceed
-+ max_checkpoint_age * 7/8 line */
-+
-+ mutex_enter(&(log_sys->mutex));
-+
-+ oldest_lsn = buf_pool_get_oldest_modification();
-+ if (ut_dulint_is_zero(oldest_lsn)) {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+
-+ } else {
-+ if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age) - ((log_sys->max_checkpoint_age) / 8)) {
-+ /* LOG_POOL_PREFLUSH_RATIO_ASYNC is exceeded. */
-+ /* We should not flush from here. */
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ } else if (ut_dulint_minus(log_sys->lsn, oldest_lsn)
-+ > (log_sys->max_checkpoint_age)/2 ) {
-+
-+ /* defence line (max_checkpoint_age * 1/2) */
-+ dulint lsn = log_sys->lsn;
-+
-+ mutex_exit(&(log_sys->mutex));
-+
-+ ib_longlong level, bpl;
-+ buf_block_t* bpage;
-+
-+ mutex_enter(&buf_pool->mutex);
-+
-+ level = 0;
-+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-+
-+ while (bpage != NULL) {
-+ dulint oldest_modification = bpage->oldest_modification;
-+ if (!ut_dulint_is_zero(oldest_modification)) {
-+ level += log_sys->max_checkpoint_age
-+ - ut_dulint_minus(lsn, oldest_modification);
-+ }
-+ bpage = UT_LIST_GET_NEXT(flush_list, bpage);
-+ }
-+
-+ if (level) {
-+ bpl = ((ib_longlong) UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * UT_LIST_GET_LEN(buf_pool->flush_list)
-+ * ut_dulint_minus(lsn, lsn_old)) / level;
-+ } else {
-+ bpl = 0;
-+ }
-+
-+ mutex_exit(&buf_pool->mutex);
-+
-+ if (!srv_use_doublewrite_buf) {
-+ /* flush is faster than when doublewrite */
-+ bpl = (bpl * 3) / 4;
-+ }
-+
-+ if(bpl) {
-+retry_flush_batch:
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST,
-+ bpl,
-+ ut_dulint_add(oldest_lsn,
-+ ut_dulint_minus(lsn,
-+ lsn_old)));
-+ if (n_pages_flushed == ULINT_UNDEFINED) {
-+ os_thread_sleep(5000);
-+ goto retry_flush_batch;
-+ }
-+ }
-+
-+ lsn_old = lsn;
-+ /*
-+ fprintf(stderr,
-+ "InnoDB flush: age pct: %lu, lsn progress: %lu, blocks to flush:%llu\n",
-+ ut_dulint_minus(lsn, oldest_lsn) * 100 / log_sys->max_checkpoint_age,
-+ ut_dulint_minus(lsn, lsn_old), bpl);
-+ */
-+ } else {
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
-+ }
-+ }
-+
-+ } else {
-+ mutex_enter(&(log_sys->mutex));
-+ lsn_old = log_sys->lsn;
-+ mutex_exit(&(log_sys->mutex));
- }
-
- if (srv_activity_count == old_activity_count) {
-@@ -2367,23 +2541,25 @@
- n_pend_ios = buf_get_n_pending_ios() + log_sys->n_pending_writes;
- n_ios = log_sys->n_log_ios + buf_pool->n_pages_read
- + buf_pool->n_pages_written;
-- if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
-+ if (n_pend_ios < 3 && (n_ios - n_ios_very_old < PCT_IO(200))) {
-
- srv_main_thread_op_info = "flushing buffer pool pages";
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
- }
-
- /* We run a batch of insert buffer merge every 10 seconds,
- even if the server were active */
-
- srv_main_thread_op_info = "doing insert buffer merge";
-- ibuf_contract_for_n_pages(TRUE, 5);
-+ ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(5));
-
- srv_main_thread_op_info = "flushing log";
-- log_buffer_flush_to_disk();
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-
- /* We run a full purge every 10 seconds, even if the server
- were active */
-@@ -2422,14 +2598,14 @@
- (> 70 %), we assume we can afford reserving the disk(s) for
- the time it requires to flush 100 pages */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100),
- ut_dulint_max);
- } else {
- /* Otherwise, we only flush a small number of pages so that
- we do not unnecessarily use much disk i/o capacity from
- other work */
-
-- n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
-+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(10),
- ut_dulint_max);
- }
-
-@@ -2518,7 +2694,7 @@
- if (srv_fast_shutdown && srv_shutdown_state > 0) {
- n_bytes_merged = 0;
- } else {
-- n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20);
-+ n_bytes_merged = ibuf_contract_for_n_pages(TRUE, PCT_IBUF_IO(100));
- }
-
- srv_main_thread_op_info = "reserving kernel mutex";
-@@ -2535,7 +2711,7 @@
-
- if (srv_fast_shutdown < 2) {
- n_pages_flushed =
-- buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
-+ buf_flush_batch(BUF_FLUSH_LIST, PCT_IO(100), ut_dulint_max);
- } else {
- /* In the fastest shutdown we do not flush the buffer pool
- to data files: we set n_pages_flushed to 0 artificially. */
-@@ -2557,7 +2733,14 @@
-
- srv_main_thread_op_info = "flushing log";
-
-- log_buffer_flush_to_disk();
-+ current_time = time(NULL);
-+ if (difftime(current_time, last_flush_time) > 1) {
-+ log_buffer_flush_to_disk();
-+ last_flush_time = current_time;
-+ } else {
-+ /* No fsync when srv_flush_log_at_trx_commit != 1 */
-+ log_buffer_flush_maybe_sync();
-+ }
-
- srv_main_thread_op_info = "making checkpoint";
-
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-08 06:12:12.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-02 16:44:49.000000000 +0900
-@@ -1205,24 +1205,28 @@
- return(DB_ERROR);
- }
-
-+ /* over write innodb_file_io_threads */
-+ srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads;
-+
- /* Restrict the maximum number of file i/o threads */
- if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
-
- srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
-+ srv_n_read_io_threads = srv_n_write_io_threads = (SRV_MAX_N_IO_THREADS - 2) / 2;
- }
-
- if (!os_aio_use_native_aio) {
- /* In simulated aio we currently have use only for 4 threads */
-- srv_n_file_io_threads = 4;
-+ /*srv_n_file_io_threads = 4;*/
-
- os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- } else {
- os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
- * srv_n_file_io_threads,
-- srv_n_file_io_threads,
-+ srv_n_read_io_threads, srv_n_write_io_threads,
- SRV_MAX_N_PENDING_SYNC_IOS);
- }
-
-diff -ruN a/patch_info/innodb_io_patches.info b/patch_info/innodb_io_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_io_patches.info 2009-07-02 16:44:49.000000000 +0900
-@@ -0,0 +1,11 @@
-+File=innodb_io_patches.patch
-+Name=Cluster of past InnoDB IO patches
-+Version=1.1
-+Author=Percona
-+License=GPL
-+Comment=This patch contains fixed (control_flush_and_merge_and_read, control_io-threads, adaptive_flush)
-+ChangeLog=
-+2008-11-06
-+YK: Initial release
-+2009-01-09
-+YK: Some parameters are added
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-02 16:44:49.000000000 +0900
-@@ -149,6 +149,7 @@
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
-
-+long innobase_read_io_threads, innobase_write_io_threads;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
- /* The default values for the following char* start-up parameters
-@@ -1417,6 +1418,8 @@
- srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
-
- srv_n_file_io_threads = (ulint) innobase_file_io_threads;
-+ srv_n_read_io_threads = (ulint) innobase_read_io_threads;
-+ srv_n_write_io_threads = (ulint) innobase_write_io_threads;
-
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-@@ -7330,6 +7333,10 @@
- trx_t* trx = check_trx_exists(thd);
-
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
-+ if (srv_enable_unsafe_group_commit && !thd->variables.innodb_support_xa) {
-+ /* choose group commit rather than binlog order */
-+ return(0);
-+ }
-
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-02 18:10:51.000000000 +0900
-@@ -204,6 +204,7 @@
- extern long innobase_additional_mem_pool_size;
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-+extern long innobase_read_io_threads, innobase_write_io_threads;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
- extern char *innobase_data_home_dir, *innobase_data_file_path;
-@@ -234,6 +235,15 @@
- extern ulong srv_thread_concurrency;
- extern ulong srv_commit_concurrency;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_io_capacity;
-+extern long long srv_ibuf_max_size;
-+extern ulong srv_ibuf_active_contract;
-+extern ulong srv_ibuf_accel_rate;
-+extern ulong srv_flush_neighbor_pages;
-+extern ulong srv_enable_unsafe_group_commit;
-+extern uint srv_read_ahead;
-+extern uint srv_adaptive_checkpoint;
-+
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
- running with the fix disabled because MySQL 5.1 is frozen for such
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-02 18:00:04.000000000 +0900
-@@ -5086,6 +5086,16 @@
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-+ OPT_INNODB_IO_CAPACITY,
-+ OPT_INNODB_IBUF_MAX_SIZE,
-+ OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ OPT_INNODB_IBUF_ACCEL_RATE,
-+ OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ OPT_INNODB_READ_AHEAD,
-+ OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ OPT_INNODB_READ_IO_THREADS,
-+ OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
-@@ -5403,6 +5413,44 @@
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- (gptr*) &srv_use_legacy_cardinality_algorithm,
- 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
-+ "Number of IO operations per second the server can do. Tunes background IO rate.",
-+ (gptr*) &srv_io_capacity, (gptr*) &srv_io_capacity,
-+ 0, GET_ULONG, REQUIRED_ARG, 200, 100, 999999999, 0, 0, 0},
-+ {"innodb_ibuf_max_size", OPT_INNODB_IBUF_MAX_SIZE,
-+ "The maximum size of the insert buffer. (in bytes)",
-+ (gptr*) &srv_ibuf_max_size, (gptr*) &srv_ibuf_max_size, 0,
-+ GET_LL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0},
-+ {"innodb_ibuf_active_contract", OPT_INNODB_IBUF_ACTIVE_CONTRACT,
-+ "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
-+ (gptr*) &srv_ibuf_active_contract, (gptr*) &srv_ibuf_active_contract,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_ibuf_accel_rate", OPT_INNODB_IBUF_ACCEL_RATE,
-+ "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
-+ (gptr*) &srv_ibuf_accel_rate, (gptr*) &srv_ibuf_accel_rate,
-+ 0, GET_ULONG, REQUIRED_ARG, 100, 100, 999999999, 0, 0, 0},
-+ {"innodb_flush_neighbor_pages", OPT_INNODB_FLUSH_NEIGHBOR_PAGES,
-+ "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
-+ (gptr*) &srv_flush_neighbor_pages, (gptr*) &srv_flush_neighbor_pages,
-+ 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 0, 0},
-+ {"innodb_read_ahead", OPT_INNODB_READ_AHEAD,
-+ "Control read ahead activity. (none, random, linear, [both])",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_adaptive_checkpoint", OPT_INNODB_ADAPTIVE_CHECKPOINT,
-+ "Enable/Diasable flushing along modified age. ([none], reflex, estimate)",
-+ 0, 0, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"innodb_enable_unsafe_group_commit", OPT_INNODB_ENABLE_UNSAFE_GROUP_COMMIT,
-+ "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
-+ (gptr*) &srv_enable_unsafe_group_commit, (gptr*) &srv_enable_unsafe_group_commit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS,
-+ "Number of background read I/O threads in InnoDB.",
-+ (gptr*) &innobase_read_io_threads, (gptr*) &innobase_read_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS,
-+ "Number of background write I/O threads in InnoDB.",
-+ (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
-+ 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-@@ -7644,6 +7692,38 @@
- case OPT_INNODB_LOG_ARCHIVE:
- innobase_log_archive= argument ? test(atoi(argument)) : 1;
- break;
-+ case OPT_INNODB_READ_AHEAD:
-+ if (argument == disabled_my_option)
-+ srv_read_ahead = 0;
-+ else if (! argument)
-+ srv_read_ahead = 3;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_read_ahead_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_read_ahead type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_read_ahead = (uint) ((type - 1) & 3);
-+ }
-+ break;
-+ case OPT_INNODB_ADAPTIVE_CHECKPOINT:
-+ if (argument == disabled_my_option)
-+ srv_adaptive_checkpoint = 0;
-+ else if (! argument)
-+ srv_adaptive_checkpoint = 0;
-+ else
-+ {
-+ int type;
-+ if ((type=find_type(argument, &innodb_adaptive_checkpoint_typelib, 2)) <= 0)
-+ {
-+ fprintf(stderr,"Unknown innodb_adaptive_checkpoint type: %s\n",argument);
-+ exit(1);
-+ }
-+ srv_adaptive_checkpoint = (uint) ((type - 1) % 3);
-+ }
-+ break;
- #endif /* HAVE_INNOBASE_DB */
- case OPT_MYISAM_RECOVER:
- {
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-02 17:45:29.000000000 +0900
-@@ -489,6 +489,57 @@
- sys_var_long_ptr sys_innodb_flush_log_at_trx_commit(
- "innodb_flush_log_at_trx_commit",
- &srv_flush_log_at_trx_commit);
-+sys_var_long_ptr sys_innodb_io_capacity("innodb_io_capacity",
-+ &srv_io_capacity);
-+sys_var_long_ptr sys_innodb_ibuf_active_contract("innodb_ibuf_active_contract",
-+ &srv_ibuf_active_contract);
-+sys_var_long_ptr sys_innodb_ibuf_accel_rate("innodb_ibuf_accel_rate",
-+ &srv_ibuf_accel_rate);
-+sys_var_long_ptr sys_innodb_flush_neighbor_pages("innodb_flush_neighbor_pages",
-+ &srv_flush_neighbor_pages);
-+
-+const char *innodb_read_ahead_names[]=
-+{
-+ "none", /* 0 */
-+ "random",
-+ "linear",
-+ "both", /* 3 */
-+ /* For compatibility of the older patch */
-+ "0", /* 4 ("none" + 4) */
-+ "1",
-+ "2",
-+ "3", /* 7 ("both" + 4) */
-+ NullS
-+};
-+TYPELIB innodb_read_ahead_typelib=
-+{
-+ array_elements(innodb_read_ahead_names) - 1, "innodb_read_ahead_typelib",
-+ innodb_read_ahead_names, NULL
-+};
-+sys_var_enum sys_innodb_read_ahead("innodb_read_ahead", &srv_read_ahead,
-+ &innodb_read_ahead_typelib, fix_innodb_read_ahead);
-+sys_var_long_ptr sys_innodb_enable_unsafe_group_commit("innodb_enable_unsafe_group_commit",
-+ &srv_enable_unsafe_group_commit);
-+
-+const char *innodb_adaptive_checkpoint_names[]=
-+{
-+ "none", /* 0 */
-+ "reflex", /* 1 */
-+ "estimate", /* 2 */
-+ /* For compatibility of the older patch */
-+ "0", /* 3 ("none" + 3) */
-+ "1", /* 4 ("reflex" + 3) */
-+ "2", /* 5 ("estimate" + 3) */
-+ NullS
-+};
-+TYPELIB innodb_adaptive_checkpoint_typelib=
-+{
-+ array_elements(innodb_adaptive_checkpoint_names) - 1, "innodb_adaptive_checkpoint_typelib",
-+ innodb_adaptive_checkpoint_names, NULL
-+};
-+sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
-+ &srv_adaptive_checkpoint,
-+ &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -860,6 +911,13 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_io_capacity,
-+ &sys_innodb_ibuf_active_contract,
-+ &sys_innodb_ibuf_accel_rate,
-+ &sys_innodb_flush_neighbor_pages,
-+ &sys_innodb_read_ahead,
-+ &sys_innodb_enable_unsafe_group_commit,
-+ &sys_innodb_adaptive_checkpoint,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -997,6 +1055,16 @@
- {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
- {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
- {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
-+ {sys_innodb_io_capacity.name, (char*) &sys_innodb_io_capacity, SHOW_SYS},
-+ {"innodb_ibuf_max_size", (char*) &srv_ibuf_max_size, SHOW_LONGLONG},
-+ {sys_innodb_ibuf_active_contract.name, (char*) &sys_innodb_ibuf_active_contract, SHOW_SYS},
-+ {sys_innodb_ibuf_accel_rate.name, (char*) &sys_innodb_ibuf_accel_rate, SHOW_SYS},
-+ {sys_innodb_flush_neighbor_pages.name, (char*) &sys_innodb_flush_neighbor_pages, SHOW_SYS},
-+ {sys_innodb_read_ahead.name, (char*) &sys_innodb_read_ahead, SHOW_SYS},
-+ {sys_innodb_enable_unsafe_group_commit.name, (char*) &sys_innodb_enable_unsafe_group_commit, SHOW_SYS},
-+ {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
-+ {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
-+ {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -1459,6 +1527,18 @@
- }
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+extern void fix_innodb_read_ahead(THD *thd, enum_var_type type)
-+{
-+ srv_read_ahead &= 3;
-+}
-+
-+extern void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type)
-+{
-+ srv_adaptive_checkpoint %= 3;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- static void fix_max_binlog_size(THD *thd, enum_var_type type)
- {
- DBUG_ENTER("fix_max_binlog_size");
-diff -ruN a/sql/set_var.h b/sql/set_var.h
---- a/sql/set_var.h 2009-07-02 16:43:23.000000000 +0900
-+++ b/sql/set_var.h 2009-07-02 17:35:17.000000000 +0900
-@@ -31,6 +31,11 @@
-
- extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib;
-
-+#ifdef HAVE_INNOBASE_DB
-+extern TYPELIB innodb_read_ahead_typelib;
-+extern TYPELIB innodb_adaptive_checkpoint_typelib;
-+#endif /* HAVE_INNOBASE_DB */
-+
- typedef int (*sys_check_func)(THD *, set_var *);
- typedef bool (*sys_update_func)(THD *, set_var *);
- typedef void (*sys_after_update_func)(THD *,enum_var_type);
-@@ -1148,6 +1153,10 @@
- int sql_set_variables(THD *thd, List<set_var_base> *var_list);
- bool not_all_support_one_shot(List<set_var_base> *var_list);
- void fix_delay_key_write(THD *thd, enum_var_type type);
-+#ifdef HAVE_INNOBASE_DB
-+void fix_innodb_read_ahead(THD *thd, enum_var_type type);
-+void fix_innodb_adaptive_checkpoint(THD *thd, enum_var_type type);
-+#endif /* HAVE_INNOBASE_DB */
- ulong fix_sql_mode(ulong sql_mode);
- extern sys_var_const_str sys_charset_system;
- extern sys_var_str sys_init_connect;
diff --git a/percona/5.0.87-b20-20100217/innodb_io_pattern.patch b/percona/5.0.87-b20-20100217/innodb_io_pattern.patch
deleted file mode 100644
index d9e60e9..0000000
--- a/percona/5.0.87-b20-20100217/innodb_io_pattern.patch
+++ /dev/null
@@ -1,693 +0,0 @@
-diff -r d4826c0a98c2 include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 10:00:12 2009 -0700
-@@ -122,6 +122,9 @@
- #define REFRESH_DES_KEY_FILE 0x40000L
- #define REFRESH_USER_RESOURCES 0x80000L
-
-+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
-+
- #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
- #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
- #define CLIENT_LONG_FLAG 4 /* Get all column flags */
-diff -r d4826c0a98c2 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/buf/buf0buf.c Wed Jul 29 10:00:12 2009 -0700
-@@ -654,6 +654,9 @@
- }
-
- buf_pool->page_hash = hash_create(2 * max_size);
-+ buf_pool->io_counter_hash = NULL;
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-
- buf_pool->n_pend_reads = 0;
-
-@@ -1967,6 +1970,9 @@
- ulint io_type;
- ulint read_page_no;
-
-+ buf_io_counter_t* io_counter;
-+ ulint fold;
-+
- ut_ad(block);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -2068,6 +2074,26 @@
- buf_pool->n_pages_read++;
-
- rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_read++;
-+ }
-+ }
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -2083,6 +2109,26 @@
- buf_flush_write_complete(block);
-
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
-+ /* io_counter here */
-+ if (srv_io_pattern && srv_io_pattern_trace_running) {
-+ fold = buf_page_address_fold(block->space, block->offset);
-+ HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter,
-+ (io_counter->space == block->space) && (io_counter->offset == block->offset));
-+ if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) {
-+ io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t)));
-+ io_counter->space = block->space;
-+ io_counter->offset = block->offset;
-+ io_counter->n_read = 0;
-+ io_counter->n_write = 0;
-+ HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash,
-+ buf_page_address_fold(block->space, block->offset), io_counter);
-+ buf_pool->io_counters++;
-+ }
-+ if (io_counter != NULL) {
-+ io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block)));
-+ io_counter->n_write++;
-+ }
-+ }
-
- buf_pool->n_pages_written++;
-
-@@ -2657,3 +2703,58 @@
- return buf_pool_get_nth_block(buf_pool, i);
-
- }
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void)
-+/*========================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (srv_io_pattern_trace) {
-+ if (buf_pool->io_counter_hash == NULL) {
-+ /* estimating (buf_pool * 10) */
-+ buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size);
-+ buf_pool->io_counter_heap = mem_heap_create(4096 * 1024);
-+ buf_pool->io_counters = 0;
-+
-+ srv_io_pattern = TRUE;
-+ }
-+ } else {
-+ if (buf_pool->io_counter_hash != NULL) {
-+ srv_io_pattern = FALSE;
-+
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_free(buf_pool->io_counter_heap);
-+ buf_pool->io_counter_heap = NULL;
-+ buf_pool->io_counters = 0;
-+
-+ hash_table_free(buf_pool->io_counter_hash);
-+ buf_pool->io_counter_hash = NULL;
-+ }
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-+
-+void
-+buf_io_counter_clear(void)
-+/*======================*/
-+{
-+ ulint n;
-+
-+ mutex_enter(&(buf_pool->mutex));
-+ if (buf_pool->io_counter_hash != NULL) {
-+ for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ (buf_pool->io_counter_hash->array + n)->node = NULL;
-+ }
-+ mem_heap_empty(buf_pool->io_counter_heap);
-+ buf_pool->io_counters = 0;
-+ }
-+ mutex_exit(&(buf_pool->mutex));
-+}
-diff -r d4826c0a98c2 innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0buf.h Wed Jul 29 10:00:12 2009 -0700
-@@ -709,6 +709,18 @@
- void buf_pool_dump(void);
- buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-+
-+/*************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+buf_io_counter_control(void);
-+/*=========================*/
-+
-+void
-+buf_io_counter_clear(void);
-+/*=======================*/
-
- /* The buffer control block structure */
-
-@@ -930,6 +942,9 @@
- ulint curr_size; /* current pool size in pages;
- currently always the same as
- max_size */
-+ hash_table_t* io_counter_hash;
-+ mem_heap_t* io_counter_heap;
-+ ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-
- ulint n_pend_reads; /* number of pending read operations */
-@@ -1015,6 +1030,15 @@
- locki table, are not in this list */
- };
-
-+struct buf_io_counter_struct{
-+ ulint space;
-+ ulint offset;
-+ buf_io_counter_t* hash;
-+ ulint index_id;
-+ ulint n_read;
-+ ulint n_write;
-+};
-+
- /* States of a control block */
- #define BUF_BLOCK_NOT_USED 211 /* is in the free list */
- #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns
-diff -r d4826c0a98c2 innobase/include/buf0types.h
---- a/innobase/include/buf0types.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/buf0types.h Wed Jul 29 10:00:12 2009 -0700
-@@ -12,6 +12,8 @@
- typedef struct buf_block_struct buf_block_t;
- typedef struct buf_pool_struct buf_pool_t;
-
-+typedef struct buf_io_counter_struct buf_io_counter_t;
-+
- /* The 'type' used of a buffer frame */
- typedef byte buf_frame_t;
-
-diff -r d4826c0a98c2 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/include/srv0srv.h Wed Jul 29 10:00:12 2009 -0700
-@@ -146,6 +146,11 @@
- extern ulint srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+
-+extern volatile ibool srv_io_pattern;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
- /*-------------------------------------------*/
-
- extern ulint srv_n_rows_inserted;
-diff -r d4826c0a98c2 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Wed Jul 29 09:58:58 2009 -0700
-+++ b/innobase/srv/srv0srv.c Wed Jul 29 10:00:12 2009 -0700
-@@ -352,6 +352,11 @@
-
- uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
- uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */
-+
-+volatile ibool srv_io_pattern = FALSE;
-+ulint srv_io_pattern_trace = 0;
-+ulint srv_io_pattern_trace_running = 0;
-+ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024);
- /*-------------------------------------------*/
- ulong srv_n_spin_wait_rounds = 20;
- ulong srv_n_free_tickets_to_enter = 500;
-diff -r d4826c0a98c2 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 10:00:12 2009 -0700
-@@ -59,6 +59,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- columns_priv
- db
- func
-@@ -742,7 +743,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--108
-+109
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -812,12 +813,13 @@
- TABLE_PRIVILEGES TABLE_NAME select
- TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
-+INNODB_IO_PATTERN TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 23
-+information_schema 24
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1225,6 +1227,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1263,6 +1266,7 @@
- USER_PRIVILEGES GRANTEE
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
-+INNODB_IO_PATTERN SPACE
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1337,6 +1341,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
-+INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r d4826c0a98c2 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 10:00:12 2009 -0700
-@@ -28,6 +28,7 @@
- USER_PRIVILEGES
- USER_STATISTICS
- VIEWS
-+INNODB_IO_PATTERN
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
-diff -r d4826c0a98c2 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 09:58:58 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 10:00:12 2009 -0700
-@@ -102,6 +102,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -130,6 +131,7 @@
- | USER_PRIVILEGES |
- | USER_STATISTICS |
- | VIEWS |
-+| INNODB_IO_PATTERN |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
-diff -r d4826c0a98c2 patch_info/innodb_io_pattern.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_io_pattern.info Wed Jul 29 10:00:12 2009 -0700
-@@ -0,0 +1,8 @@
-+File=innodb_io_pattern.patch
-+Name=Information schema table of InnoDB IO counts for each datafile pages
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN
-+2008-12-01
-+YK: fix for mysql-test
-diff -r d4826c0a98c2 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -1583,6 +1583,8 @@
- pthread_cond_init(&commit_cond, NULL);
- innodb_inited= 1;
-
-+ buf_io_counter_control();
-+
- /* If this is a replication slave and we needed to do a crash recovery,
- set the master binlog position to what InnoDB internally knew about
- how far we got transactions durable inside InnoDB. There is a
-@@ -6551,6 +6553,28 @@
- }
-
- /****************************************************************************
-+Controls the internal hash table for IO pattern tracing
-+along innodb_io_pattern_trace value.*/
-+
-+void
-+innodb_io_pattern_control(void)
-+/*===========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_control();
-+ }
-+}
-+
-+void
-+innodb_io_pattern_clear(void)
-+/*=========================*/
-+{
-+ if (innodb_inited) {
-+ buf_io_counter_clear();
-+ }
-+}
-+
-+/****************************************************************************
- Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
- Monitor to the client. */
-
-diff -r d4826c0a98c2 sql/ha_innodb.h
---- a/sql/ha_innodb.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/ha_innodb.h Wed Jul 29 10:00:12 2009 -0700
-@@ -245,6 +245,9 @@
- extern uint srv_adaptive_checkpoint;
- extern ulong srv_show_locks_held;
- extern ulong srv_show_verbose_locks;
-+extern ulong srv_io_pattern_trace;
-+extern ulong srv_io_pattern_trace_running;
-+extern ulong srv_io_pattern_size_limit;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-@@ -278,6 +281,9 @@
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-+void innodb_io_pattern_control(void);
-+void innodb_io_pattern_clear(void);
-+
- void innobase_release_temporary_latches(THD *thd);
-
- void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
-diff -r d4826c0a98c2 sql/lex.h
---- a/sql/lex.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 10:00:12 2009 -0700
-@@ -244,6 +244,7 @@
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
- { "INNODB", SYM(INNOBASE_SYM)},
-+ { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)},
- { "INOUT", SYM(INOUT_SYM)},
- { "INSENSITIVE", SYM(INSENSITIVE_SYM)},
- { "INSERT", SYM(INSERT)},
-diff -r d4826c0a98c2 sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -5029,6 +5029,9 @@
- OPT_INNODB_SYNC_SPIN_LOOPS,
- OPT_INNODB_CONCURRENCY_TICKETS,
- OPT_INNODB_THREAD_SLEEP_DELAY,
-+ OPT_INNODB_IO_PATTERN_TRACE,
-+ OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
- OPT_BDB_CACHE_SIZE,
- OPT_BDB_LOG_BUFFER_SIZE,
- OPT_BDB_MAX_LOCK,
-@@ -5461,6 +5464,18 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE,
-+ "Create/Drop the internal hash table for IO pattern tracing.",
-+ (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING,
-+ "Control IO pattern trace running or not.",
-+ (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0},
-+ {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT,
-+ "Set max number of counters per data pages. (0 = disable counting).",
-+ (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit,
-+ 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0},
- #endif /* End HAVE_INNOBASE_DB */
- {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
- (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
-diff -r d4826c0a98c2 sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -546,6 +546,12 @@
- sys_var_long_ptr sys_innodb_show_verbose_locks(
- "innodb_show_verbose_locks",
- &srv_show_verbose_locks);
-+sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace",
-+ &srv_io_pattern_trace);
-+sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running",
-+ &srv_io_pattern_trace_running);
-+sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit",
-+ &srv_io_pattern_size_limit);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -926,6 +932,9 @@
- &sys_innodb_adaptive_checkpoint,
- &sys_innodb_show_locks_held,
- &sys_innodb_show_verbose_locks,
-+ &sys_innodb_io_pattern_trace,
-+ &sys_innodb_io_pattern_trace_running,
-+ &sys_innodb_io_pattern_size_limit,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1075,6 +1084,9 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
-+ {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
-+ {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS},
- {sys_innodb_use_legacy_cardinality_algorithm.name,
- (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
- #endif
-@@ -3210,6 +3222,19 @@
- thd->variables.lc_time_names= global_system_variables.lc_time_names;
- }
-
-+#ifdef HAVE_INNOBASE_DB
-+bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ ret = sys_var_long_ptr_global::update(thd, var);
-+
-+ innodb_io_pattern_control();
-+
-+ return ret;
-+}
-+#endif /* HAVE_INNOBASE_DB */
-+
- /*
- Functions to update thd->options bits
- */
-diff -r d4826c0a98c2 sql/set_var.h
---- a/sql/set_var.h Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/set_var.h Wed Jul 29 10:00:12 2009 -0700
-@@ -1012,6 +1012,17 @@
- virtual void set_default(THD *thd, enum_var_type type);
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+/* sys_var_innodb_io_pattern_trace */
-+class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr
-+{
-+public:
-+ sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg)
-+ :sys_var_long_ptr(name_arg,value_ptr_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-+#endif /* HAVE_INNOBASE_DB */
-+
- /****************************************************************************
- Classes for parsing of the SET command
- ****************************************************************************/
-diff -r d4826c0a98c2 sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -8104,6 +8104,13 @@
- }
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
- }
-+#ifdef HAVE_INNOBASE_DB
-+ if (options & REFRESH_INNODB_IO_PATTERN)
-+ {
-+ tmp_write_to_binlog= 0;
-+ innodb_io_pattern_clear();
-+ }
-+#endif /* HAVE_INNOBASE_DB */
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r d4826c0a98c2 sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 10:00:12 2009 -0700
-@@ -33,6 +33,17 @@
- #include "ha_innodb.h"
- #endif
-
-+#ifdef HAVE_INNOBASE_DB
-+#define INSIDE_HA_INNOBASE_CC
-+extern "C" {
-+#include "srv0srv.h"
-+#include "buf0buf.h"
-+#include "dict0dict.h"
-+}
-+/* We need to undef it in InnoDB */
-+#undef byte
-+#endif /* HAVE_INNOBASE_DB */
-+
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- static const char *grant_names[]={
- "select","insert","update","delete","create","drop","reload","shutdown",
-@@ -4108,6 +4119,72 @@
- DBUG_RETURN(res);
- }
-
-+int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ TABLE *table= (TABLE *) tables->table;
-+
-+ buf_io_counter_t* io_counter;
-+ dict_index_t* index;
-+
-+ DBUG_ENTER("innodb_io_pattern_fill_table");
-+ int returnable= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ /* We cannot use inline functions of InnoDB here */
-+
-+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
-+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
-+ /* at the same time as possible. */
-+
-+ if (srv_io_pattern) {
-+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
-+ while (io_counter) {
-+ if (!srv_io_pattern)
-+ goto end_func;
-+
-+ if (dict_sys != NULL) {
-+ dulint id;
-+ id.high = 0;
-+ id.low = io_counter->index_id;
-+ index = dict_index_find_on_id_low(id);
-+ } else {
-+ index = NULL;
-+ }
-+
-+ table->field[0]->store(io_counter->space);
-+ table->field[1]->store(io_counter->offset);
-+ table->field[2]->store(io_counter->index_id);
-+ if (index != NULL) {
-+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
-+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
-+ } else {
-+ table->field[3]->store("",0,system_charset_info);
-+ table->field[4]->store("",0,system_charset_info);
-+ }
-+ table->field[5]->store(io_counter->n_read);
-+ table->field[6]->store(io_counter->n_write);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ returnable= 1;
-+ goto end_func;
-+ }
-+ io_counter = io_counter->hash;
-+ }
-+ }
-+ }
-+
-+ end_func:
-+ DBUG_RETURN(returnable);
-+}
-+
- /*
- Find schema_tables elment by name
-
-@@ -4914,6 +4986,19 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+#ifdef HAVE_INNOBASE_DB
-+ST_FIELD_INFO innodb_io_pattern_field_info[]=
-+{
-+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
-+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
-+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
-+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
-+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
-+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
-+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+#endif
-
- ST_FIELD_INFO variables_fields_info[]=
- {
-@@ -5089,6 +5174,10 @@
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_views_record, 1, 2, 0},
-+#ifdef HAVE_INNOBASE_DB
-+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
-+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
-+#endif
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r d4826c0a98c2 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 09:58:58 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 10:00:12 2009 -0700
-@@ -685,6 +685,7 @@
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-+%token INNODB_IO_PATTERN
- %token INOUT_SYM
- %token INSENSITIVE_SYM
- %token INSERT
-@@ -8500,6 +8501,7 @@
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
- | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
- | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
- | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-@@ -9552,6 +9554,7 @@
- | ISOLATION {}
- | ISSUER_SYM {}
- | INNOBASE_SYM {}
-+ | INNODB_IO_PATTERN {}
- | INSERT_METHOD {}
- | IO_SYM {}
- | IPC_SYM {}
diff --git a/percona/5.0.87-b20-20100217/innodb_locks_held.patch b/percona/5.0.87-b20-20100217/innodb_locks_held.patch
deleted file mode 100644
index 062fa47..0000000
--- a/percona/5.0.87-b20-20100217/innodb_locks_held.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
-@@ -80,6 +80,8 @@
- extern ulint srv_log_file_size;
- extern ulint srv_log_buffer_size;
- extern ulong srv_flush_log_at_trx_commit;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
- character set */
-diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
-@@ -4181,6 +4181,7 @@
- #endif /* UNIV_SYNC_DEBUG */
- }
-
-+ if ( srv_show_verbose_locks ) {
- for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
-
- if (lock_rec_get_nth_bit(lock, i)) {
-@@ -4198,6 +4199,7 @@
- putc('\n', file);
- }
- }
-+ } /* srv_show_verbose_locks */
-
- mtr_commit(&mtr);
- if (UNIV_LIKELY_NULL(heap)) {
-@@ -4369,7 +4371,7 @@
- }
- }
-
-- if (!srv_print_innodb_lock_monitor) {
-+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
- nth_trx++;
- goto loop;
- }
-@@ -4426,9 +4428,9 @@
-
- nth_lock++;
-
-- if (nth_lock >= 10) {
-+ if (nth_lock >= srv_show_locks_held) {
- fputs(
-- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
-+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
- file);
-
- nth_trx++;
-diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
-+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
-@@ -116,6 +116,8 @@
- ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
- ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
- ulong srv_flush_log_at_trx_commit = 1;
-+ulint srv_show_locks_held = 10;
-+ulint srv_show_verbose_locks = 0;
-
- byte srv_latin1_ordering[256] /* The sort order table of the latin1
- character set. The following table is
-@@ -1711,24 +1713,6 @@
-
- mutex_exit(&dict_foreign_err_mutex);
-
-- lock_print_info_summary(file);
-- if (trx_start) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_start = ULINT_UNDEFINED;
-- } else {
-- *trx_start = (ulint) t;
-- }
-- }
-- lock_print_info_all_transactions(file);
-- if (trx_end) {
-- long t = ftell(file);
-- if (t < 0) {
-- *trx_end = ULINT_UNDEFINED;
-- } else {
-- *trx_end = (ulint) t;
-- }
-- }
- fputs("--------\n"
- "FILE I/O\n"
- "--------\n", file);
-@@ -1822,6 +1806,25 @@
- srv_n_rows_deleted_old = srv_n_rows_deleted;
- srv_n_rows_read_old = srv_n_rows_read;
-
-+ lock_print_info_summary(file);
-+ if (trx_start) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_start = ULINT_UNDEFINED;
-+ } else {
-+ *trx_start = (ulint) t;
-+ }
-+ }
-+ lock_print_info_all_transactions(file);
-+ if (trx_end) {
-+ long t = ftell(file);
-+ if (t < 0) {
-+ *trx_end = ULINT_UNDEFINED;
-+ } else {
-+ *trx_end = (ulint) t;
-+ }
-+ }
-+
- fputs("----------------------------\n"
- "END OF INNODB MONITOR OUTPUT\n"
- "============================\n", file);
-diff -r e9fb5b8bcf78 libmysqld/set_var.cc
---- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -825,6 +825,8 @@
- &sys_innodb_thread_concurrency,
- &sys_innodb_commit_concurrency,
- &sys_innodb_flush_log_at_trx_commit,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -942,6 +944,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
-diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
-@@ -0,0 +1,6 @@
-+File=innodb_locks_held.patch
-+Name=Add locks held, remove locked records in SHOW INNODB STATUS
-+Version=1.0
-+Author=Baron Schwartz <baron@xaprb.com>
-+License=GPL
-+Comment=Bug #29126 fix
-diff -r e9fb5b8bcf78 sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
-@@ -243,6 +243,8 @@
- extern ulong srv_enable_unsafe_group_commit;
- extern uint srv_read_ahead;
- extern uint srv_adaptive_checkpoint;
-+extern ulong srv_show_locks_held;
-+extern ulong srv_show_verbose_locks;
-
- /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
- NOT update cardinality for indexes of InnoDB table". By default we are
-diff -r e9fb5b8bcf78 sql/mysqld.cc
---- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -5016,6 +5016,8 @@
- OPT_INNODB_MAX_PURGE_LAG,
- OPT_INNODB_FILE_IO_THREADS,
- OPT_INNODB_LOCK_WAIT_TIMEOUT,
-+ OPT_INNODB_SHOW_LOCKS_HELD,
-+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
- OPT_INNODB_THREAD_CONCURRENCY,
- OPT_INNODB_COMMIT_CONCURRENCY,
- OPT_INNODB_FORCE_RECOVERY,
-@@ -5364,6 +5366,14 @@
- (gptr*) &srv_flush_log_at_trx_commit,
- (gptr*) &srv_flush_log_at_trx_commit,
- 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
-+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
-+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
-+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
-+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
-+ "Whether to show records locked in SHOW INNODB STATUS.",
-+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
-+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
- {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
- "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
- (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-diff -r e9fb5b8bcf78 sql/set_var.cc
---- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
-+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
-@@ -527,6 +527,12 @@
- sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
- &srv_adaptive_checkpoint,
- &innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
-+sys_var_long_ptr sys_innodb_show_locks_held(
-+ "innodb_show_locks_held",
-+ &srv_show_locks_held);
-+sys_var_long_ptr sys_innodb_show_verbose_locks(
-+ "innodb_show_verbose_locks",
-+ &srv_show_verbose_locks);
- sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
- &innobase_data_file_path);
- sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
-@@ -906,6 +912,8 @@
- &sys_innodb_read_ahead,
- &sys_innodb_enable_unsafe_group_commit,
- &sys_innodb_adaptive_checkpoint,
-+ &sys_innodb_show_locks_held,
-+ &sys_innodb_show_verbose_locks,
- #endif
- &sys_trust_routine_creators,
- &sys_trust_function_creators,
-@@ -1023,6 +1031,8 @@
- {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
- {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
- {sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
-+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
-+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
- {"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
- {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
- {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff --git a/percona/5.0.87-b20-20100217/innodb_misc_patch.patch b/percona/5.0.87-b20-20100217/innodb_misc_patch.patch
deleted file mode 100644
index 4f4faf3..0000000
--- a/percona/5.0.87-b20-20100217/innodb_misc_patch.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-diff -ru mysql-5.0.84_p_orig/innobase/row/row0sel.c mysql-5.0.84/innobase/row/row0sel.c
---- mysql-5.0.84_p_orig/innobase/row/row0sel.c 2009-07-07 21:54:10.000000000 +0900
-+++ mysql-5.0.84/innobase/row/row0sel.c 2009-08-28 09:28:56.000000000 +0900
-@@ -2988,6 +2988,15 @@
- return(SEL_FOUND);
- }
-
-+/**********************************************************************
-+Returns true if the thread is executing a SELECT statement.
-+(Prototype for global functions in ha_innodb.cc) */
-+ibool
-+thd_is_select(
-+/*==========*/
-+ /* out: true if thd is executing SELECT */
-+ const void* thd); /* in: thread handle (THD*) */
-+
- /************************************************************************
- Searches for rows in the database. This is used in the interface to
- MySQL. This function opens a cursor, and also implements fetch next
-@@ -3361,20 +3370,12 @@
-
- if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
- && prebuilt->select_lock_type != LOCK_NONE
-- && trx->mysql_query_str) {
--
-- /* Scan the MySQL query string; check if SELECT is the first
-- word there */
-- ibool success;
--
-- dict_accept(*trx->mysql_query_str, "SELECT", &success);
--
-- if (success) {
-+ && trx->mysql_thd != NULL
-+ && thd_is_select(trx->mysql_thd)) {
- /* It is a plain locking SELECT and the isolation
- level is low: do not lock gaps */
-
- set_also_gap_locks = FALSE;
-- }
- }
-
- /* Note that if the search mode was GE or G, then the cursor
-diff -ru mysql-5.0.84_p_orig/sql/ha_innodb.cc mysql-5.0.84/sql/ha_innodb.cc
---- mysql-5.0.84_p_orig/sql/ha_innodb.cc 2009-08-27 16:06:21.000000000 +0900
-+++ mysql-5.0.84/sql/ha_innodb.cc 2009-08-28 09:33:38.000000000 +0900
-@@ -394,6 +394,18 @@
- }
- }
-
-+/**********************************************************************
-+Returns true if the thread is executing a SELECT statement. */
-+extern "C"
-+ibool
-+thd_is_select(
-+/*==========*/
-+ /* out: true if thd is executing SELECT */
-+ const void* thd) /* in: thread handle (THD*) */
-+{
-+ return(((const THD*) thd)->lex->sql_command == SQLCOM_SELECT);
-+}
-+
- /************************************************************************
- Call this function when mysqld passes control to the client. That is to
- avoid deadlocks on the adaptive hash S-latch possibly held by thd. For more
diff --git a/percona/5.0.87-b20-20100217/innodb_recovery_patches.patch b/percona/5.0.87-b20-20100217/innodb_recovery_patches.patch
deleted file mode 100644
index 3d3e567..0000000
--- a/percona/5.0.87-b20-20100217/innodb_recovery_patches.patch
+++ /dev/null
@@ -1,217 +0,0 @@
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-08-04 17:02:36.000000000 +0900
-@@ -85,6 +85,22 @@
- prev_b = NULL;
- b = UT_LIST_GET_FIRST(buf_pool->flush_list);
-
-+ if (srv_fast_recovery) {
-+ /* speed hack */
-+ if (b == NULL || (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0)) {
-+ UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
-+ } else {
-+ b = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ if (ut_dulint_cmp(b->oldest_modification,
-+ block->oldest_modification) < 0) {
-+ /* align oldest_modification not to sort */
-+ block->oldest_modification = b->oldest_modification;
-+ }
-+ UT_LIST_ADD_LAST(flush_list, buf_pool->flush_list, block);
-+ }
-+ } else {
-+ /* normal */
- while (b && (ut_dulint_cmp(b->oldest_modification,
- block->oldest_modification) > 0)) {
- prev_b = b;
-@@ -97,6 +113,7 @@
- UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b,
- block);
- }
-+ }
-
- ut_ad(buf_flush_validate_low());
- }
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-08-04 17:11:41.000000000 +0900
-@@ -127,6 +127,46 @@
- block = buf_page_init_for_read(err, mode, space, tablespace_version,
- offset);
- if (block == NULL) {
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=43948 */
-+ if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
-+ /* hashed log recs must be treated here */
-+ recv_addr_t* recv_addr;
-+
-+ mutex_enter(&(recv_sys->mutex));
-+
-+ if (recv_sys->apply_log_recs == FALSE) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ /* recv_get_fil_addr_struct() */
-+ recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
-+ hash_calc_hash(ut_fold_ulint_pair(space, offset),
-+ recv_sys->addr_hash));
-+ while (recv_addr) {
-+ if ((recv_addr->space == space)
-+ && (recv_addr->page_no == offset)) {
-+ break;
-+ }
-+ recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
-+ }
-+
-+ if ((recv_addr == NULL)
-+ || (recv_addr->state == RECV_BEING_PROCESSED)
-+ || (recv_addr->state == RECV_PROCESSED)) {
-+ mutex_exit(&(recv_sys->mutex));
-+ goto not_to_recover;
-+ }
-+
-+ fprintf(stderr, " (space:%lu is deleted)", space);
-+ recv_addr->state = RECV_PROCESSED;
-+
-+ ut_a(recv_sys->n_addrs);
-+ recv_sys->n_addrs--;
-+
-+ mutex_exit(&(recv_sys->mutex));
-+ }
-+not_to_recover:
-
- return(0);
- }
-@@ -697,11 +737,11 @@
- while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
-
- os_aio_simulated_wake_handler_threads();
-- os_thread_sleep(500000);
-+ os_thread_sleep(10000);
-
- count++;
-
-- if (count > 100) {
-+ if (count > 5000) {
- fprintf(stderr,
- "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
- "InnoDB: reads to the buffer pool to be finished.\n"
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-08-04 17:39:51.000000000 +0900
-@@ -59,6 +59,8 @@
- extern ibool srv_file_per_table;
- extern ibool srv_locks_unsafe_for_binlog;
-
-+extern ibool srv_fast_recovery;
-+
- extern ulint srv_n_data_files;
- extern char** srv_data_file_names;
- extern ulint* srv_data_file_sizes;
-diff -ruN a/innobase/log/log0recv.c b/innobase/log/log0recv.c
---- a/innobase/log/log0recv.c 2009-07-07 21:54:08.000000000 +0900
-+++ b/innobase/log/log0recv.c 2009-08-04 17:15:15.000000000 +0900
-@@ -101,7 +101,7 @@
- use these free frames to read in pages when we start applying the
- log records to the database. */
-
--ulint recv_n_pool_free_frames = 256;
-+ulint recv_n_pool_free_frames = 1024;
-
- /* The maximum lsn we see for a page during the recovery process. If this
- is bigger than the lsn we are able to scan up to, that is an indication that
-@@ -1135,6 +1135,8 @@
- recv_addr = recv_get_fil_addr_struct(space, page_no);
-
- if ((recv_addr == NULL)
-+ /* bugfix: http://bugs.mysql.com/bug.php?id=44140 */
-+ || (recv_addr->state == RECV_BEING_READ && !just_read_in)
- || (recv_addr->state == RECV_BEING_PROCESSED)
- || (recv_addr->state == RECV_PROCESSED)) {
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-04 16:53:42.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-04 17:41:05.000000000 +0900
-@@ -88,6 +88,8 @@
- i.e. do not use next-key locking
- except on duplicate key checking and
- foreign key checking */
-+ibool srv_fast_recovery = FALSE;
-+
- ulint srv_n_data_files = 0;
- char** srv_data_file_names = NULL;
- ulint* srv_data_file_sizes = NULL; /* size in database pages */
-diff -ruN a/patch_info/innodb_recovery_patches.info b/patch_info/innodb_recovery_patches.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_recovery_patches.info 2009-08-04 16:58:07.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_recovery_patches.patch
-+Name=Bugfixes and adjustments about recovery process
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-04 17:35:44.000000000 +0900
-@@ -182,6 +182,7 @@
- my_bool innobase_rollback_on_timeout = FALSE;
- my_bool innobase_create_status_file = FALSE;
- my_bool innobase_adaptive_hash_index = TRUE;
-+my_bool innobase_fast_recovery = FALSE;
-
- static char *internal_innobase_data_file_path = NULL;
-
-@@ -1534,6 +1535,8 @@
- srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
- srv_force_recovery = (ulint) innobase_force_recovery;
-
-+ srv_fast_recovery = (ibool) innobase_fast_recovery;
-+
- srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
- srv_use_checksums = (ibool) innobase_use_checksums;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-08-04 17:37:18.000000000 +0900
-@@ -220,6 +220,7 @@
- innobase_use_large_pages,
- innobase_use_native_aio,
- innobase_file_per_table, innobase_locks_unsafe_for_binlog,
-+ innobase_fast_recovery,
- innobase_rollback_on_timeout,
- innobase_create_status_file,
- innobase_adaptive_hash_index;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/mysqld.cc 2009-08-04 17:48:25.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_USE_SYS_MALLOC,
-+ OPT_INNODB_FAST_RECOVERY,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5347,6 +5348,10 @@
- {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \
- Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
- (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-+ {"innodb_fast_recovery", OPT_INNODB_FAST_RECOVERY,
-+ "Enable to use speed hack of recovery avoiding flush list sorting.",
-+ (gptr*) &innobase_fast_recovery, (gptr*) &innobase_fast_recovery,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
- "Speeds up the shutdown process of the InnoDB storage engine. Possible "
- "values are 0, 1 (faster)"
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-08-04 16:53:42.000000000 +0900
-+++ b/sql/set_var.cc 2009-08-04 17:51:49.000000000 +0900
-@@ -1088,6 +1088,7 @@
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
- {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
-+ {"innodb_fast_recovery", (char*) &innobase_fast_recovery, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20100217/innodb_rw_lock.patch b/percona/5.0.87-b20-20100217/innodb_rw_lock.patch
deleted file mode 100644
index a509f70..0000000
--- a/percona/5.0.87-b20-20100217/innodb_rw_lock.patch
+++ /dev/null
@@ -1,2480 +0,0 @@
-diff -ruN a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
---- a/innobase/btr/btr0cur.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/btr/btr0cur.c 2009-10-22 15:18:44.000000000 +0900
-@@ -313,7 +313,7 @@
- #ifdef UNIV_SEARCH_PERF_STAT
- info->n_searches++;
- #endif
-- if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
-+ if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED
- && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
- && !estimate
- #ifdef PAGE_CUR_LE_OR_EXTENDS
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-10-22 15:18:44.000000000 +0900
-@@ -773,8 +773,8 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-- ut_ad(btr_search_latch.reader_count > 0);
-+ ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
-+ ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-
-diff -ruN a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/buf/buf0buf.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1292,7 +1292,7 @@
-
- if (mode == BUF_GET_NOWAIT) {
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-@@ -1442,7 +1442,7 @@
- ut_ad(!ibuf_inside() || ibuf_page(block->space, block->offset));
-
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-@@ -1596,7 +1596,7 @@
- ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD));
-
- if (rw_latch == RW_S_LATCH) {
-- success = rw_lock_s_lock_func_nowait(&(block->lock),
-+ success = rw_lock_s_lock_nowait(&(block->lock),
- file, line);
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
-diff -ruN a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/include/buf0buf.ic 2009-10-22 16:12:25.000000000 +0900
-@@ -523,7 +523,7 @@
- #ifdef UNIV_SYNC_DEBUG
- ibool ret;
-
-- ret = rw_lock_s_lock_func_nowait(&(block->debug_latch), file, line);
-+ ret = rw_lock_s_lock_nowait(&(block->debug_latch), file, line);
-
- ut_ad(ret == TRUE);
- ut_ad(mutex_own(&block->mutex));
-diff -ruN a/innobase/include/os0sync.h b/innobase/include/os0sync.h
---- a/innobase/include/os0sync.h 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/os0sync.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,11 +1,35 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The interface to the operating system
- synchronization primitives.
-
--(c) 1995 Innobase Oy
--
- Created 9/6/1995 Heikki Tuuri
- *******************************************************/
-+
- #ifndef os0sync_h
- #define os0sync_h
-
-@@ -261,6 +285,23 @@
- /*===============*/
- os_fast_mutex_t* fast_mutex); /* in: mutex to free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/**************************************************************
-+Atomic compare-and-swap for InnoDB. Currently requires GCC atomic builtins.
-+Returns true if swapped, ptr is pointer to target, old_val is value to
-+compare to, new_val is the value to swap in. */
-+#define os_compare_and_swap(ptr, old_val, new_val) \
-+ __sync_bool_compare_and_swap(ptr, old_val, new_val)
-+
-+/**************************************************************
-+Atomic increment for InnoDB. Currently requires GCC atomic builtins.
-+Returns the resulting value, ptr is pointer to target, amount is the
-+amount of increment. */
-+#define os_atomic_increment(ptr, amount) \
-+ __sync_add_and_fetch(ptr, amount)
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
- #ifndef UNIV_NONINL
- #include "os0sync.ic"
- #endif
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for threads, not for database transactions)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -24,6 +47,12 @@
- #define RW_X_LATCH 2
- #define RW_NO_LATCH 3
-
-+/* We decrement lock_word by this amount for each x_lock. It is also the
-+start value for the lock_word, meaning that it limits the maximum number
-+of concurrent read locks before the rw_lock breaks. The current value of
-+0x00100000 allows 1,048,575 concurrent readers and 2047 recursive writers.*/
-+#define X_LOCK_DECR 0x00100000
-+
- typedef struct rw_lock_struct rw_lock_t;
- #ifdef UNIV_SYNC_DEBUG
- typedef struct rw_lock_debug_struct rw_lock_debug_t;
-@@ -47,14 +76,14 @@
- there may be waiters for the event */
- #endif /* UNIV_SYNC_DEBUG */
-
--extern ulint rw_s_system_call_count;
--extern ulint rw_s_spin_wait_count;
--extern ulint rw_s_exit_count;
--extern ulint rw_s_os_wait_count;
--extern ulint rw_x_system_call_count;
--extern ulint rw_x_spin_wait_count;
--extern ulint rw_x_os_wait_count;
--extern ulint rw_x_exit_count;
-+extern ib_longlong rw_s_spin_wait_count;
-+extern ib_longlong rw_s_spin_round_count;
-+extern ib_longlong rw_s_exit_count;
-+extern ib_longlong rw_s_os_wait_count;
-+extern ib_longlong rw_x_spin_wait_count;
-+extern ib_longlong rw_x_spin_round_count;
-+extern ib_longlong rw_x_os_wait_count;
-+extern ib_longlong rw_x_exit_count;
-
- /**********************************************************************
- Creates, or rather, initializes an rw-lock object in a specified memory
-@@ -116,8 +145,22 @@
- NOTE! The following macros should be used in rw s-locking, not the
- corresponding function. */
-
--#define rw_lock_s_lock_nowait(M) rw_lock_s_lock_func_nowait(\
-- (M), __FILE__, __LINE__)
-+#define rw_lock_s_lock_nowait(M, F, L) rw_lock_s_lock_low(\
-+ (M), 0, (F), (L))
-+/**********************************************************************
-+Low-level function which tries to lock an rw-lock in s-mode. Performs no
-+spinning. */
-+UNIV_INLINE
-+ibool
-+rw_lock_s_lock_low(
-+/*===============*/
-+ /* out: TRUE if success */
-+ rw_lock_t* lock, /* in: pointer to rw-lock */
-+ ulint pass __attribute__((unused)),
-+ /* in: pass value; != 0, if the lock will be
-+ passed to another thread to unlock */
-+ const char* file_name, /* in: file name where lock requested */
-+ ulint line); /* in: line where requested */
- /**********************************************************************
- NOTE! Use the corresponding macro, not directly this function, except if
- you supply the file name and line number. Lock an rw-lock in shared mode
-@@ -135,18 +178,6 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line); /* in: line where requested */
- /**********************************************************************
--NOTE! Use the corresponding macro, not directly this function, except if
--you supply the file name and line number. Lock an rw-lock in shared mode
--for the current thread if the lock can be acquired immediately. */
--UNIV_INLINE
--ibool
--rw_lock_s_lock_func_nowait(
--/*=======================*/
-- /* out: TRUE if success */
-- rw_lock_t* lock, /* in: pointer to rw-lock */
-- const char* file_name,/* in: file name where lock requested */
-- ulint line); /* in: line where requested */
--/**********************************************************************
- NOTE! Use the corresponding macro, not directly this function! Lock an
- rw-lock in exclusive mode for the current thread if the lock can be
- obtained immediately. */
-@@ -338,6 +369,41 @@
- rw_lock_get_reader_count(
- /*=====================*/
- rw_lock_t* lock);
-+/**********************************************************************
-+Decrements lock_word the specified amount if it is greater than 0.
-+This is used by both s_lock and x_lock operations. */
-+UNIV_INLINE
-+ibool
-+rw_lock_lock_word_decr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount); /* in: amount to decrement */
-+/**********************************************************************
-+Increments lock_word the specified amount and returns new value. */
-+UNIV_INLINE
-+lint
-+rw_lock_lock_word_incr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock,
-+ ulint amount); /* in: rw-lock */
-+/**********************************************************************
-+This function sets the lock->writer_thread and lock->recursive fields.
-+For platforms where we are using atomic builtins instead of lock->mutex
-+it sets the lock->writer_thread field using atomics to ensure memory
-+ordering. Note that it is assumed that the caller of this function
-+effectively owns the lock i.e.: nobody else is allowed to modify
-+lock->writer_thread at this point in time.
-+The protocol is that lock->writer_thread MUST be updated BEFORE the
-+lock->recursive flag is set. */
-+UNIV_INLINE
-+void
-+rw_lock_set_writer_id_and_recursion_flag(
-+/*=====================================*/
-+ rw_lock_t* lock, /* in/out: lock to work on */
-+ ibool recursive); /* in: TRUE if recursion
-+ allowed */
- #ifdef UNIV_SYNC_DEBUG
- /**********************************************************************
- Checks if the thread has locked the rw-lock in the specified mode, with
-@@ -417,47 +483,33 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-+ volatile lint lock_word;
-+ /* Holds the state of the lock. */
-+ volatile ulint waiters;/* 1: there are waiters */
-+ volatile ibool recursive;/* Default value FALSE which means the lock
-+ is non-recursive. The value is typically set
-+ to TRUE making normal rw_locks recursive. In
-+ case of asynchronous IO, when a non-zero
-+ value of 'pass' is passed then we keep the
-+ lock non-recursive.
-+ This flag also tells us about the state of
-+ writer_thread field. If this flag is set
-+ then writer_thread MUST contain the thread
-+ id of the current x-holder or wait-x thread.
-+ This flag must be reset in x_unlock
-+ functions before incrementing the lock_word */
-+ volatile os_thread_id_t writer_thread;
-+ /* Thread id of writer thread. Is only
-+ guaranteed to have sane and non-stale
-+ value iff recursive flag is set. */
- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-- os_event_t wait_ex_event; /* This windows specific event is
-- used by the thread which has set the
-- lock state to RW_LOCK_WAIT_EX. The
-- rw_lock design guarantees that this
-- thread will be the next one to proceed
-- once the current the event gets
-- signalled. See LEMMA 2 in sync0sync.c */
--#endif
--
-- ulint reader_count; /* Number of readers who have locked this
-- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-- is a writer owning the lock (in exclusive
-- mode), RW_LOCK_WAIT_EX if a writer is
-- queueing for the lock, and
-- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-- recursively locked the lock in the exclusive
-- mode */
-+ os_event_t wait_ex_event;
-+ /* Event for next-writer to wait on. A thread
-+ must decrement lock_word before waiting. */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-- ulint pass; /* Default value 0. This is set to some
-- value != 0 given by the caller of an x-lock
-- operation, if the x-lock is to be passed to
-- another thread to unlock (which happens in
-- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-- /* This is TRUE if the writer field is
-- RW_LOCK_WAIT_EX; this field is located far
-- from the memory update hotspot fields which
-- are at the start of this struct, thus we can
-- peek this field without causing much memory
-- bus traffic */
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
- UT_LIST_NODE_T(rw_lock_t) list;
- /* All allocated rw locks are put into a
- list */
-@@ -465,15 +517,23 @@
- UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list;
- /* In the debug version: pointer to the debug
- info list of the lock */
-+ ulint level; /* Level in the global latching order. */
- #endif /* UNIV_SYNC_DEBUG */
-- ulint level; /* Level in the global latching
-- order; default SYNC_LEVEL_NONE */
-+ ulint count_os_wait; /* Count of os_waits. May not be accurate */
- const char* cfile_name;/* File name where lock created */
-- ulint cline; /* Line where created */
-+ /* last s-lock file/line is not guaranteed to be correct */
- const char* last_s_file_name;/* File name where last s-locked */
- const char* last_x_file_name;/* File name where last x-locked */
-- ulint last_s_line; /* Line number where last time s-locked */
-- ulint last_x_line; /* Line number where last time x-locked */
-+ ibool writer_is_wait_ex;
-+ /* This is TRUE if the writer field is
-+ RW_LOCK_WAIT_EX; this field is located far
-+ from the memory update hotspot fields which
-+ are at the start of this struct, thus we can
-+ peek this field without causing much memory
-+ bus traffic */
-+ unsigned cline:14; /* Line where created */
-+ unsigned last_s_line:14; /* Line number where last time s-locked */
-+ unsigned last_x_line:14; /* Line number where last time x-locked */
- ulint magic_n;
- };
-
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for threads)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -49,53 +72,88 @@
- ulint
- rw_lock_get_waiters(
- /*================*/
-- rw_lock_t* lock)
-+ /* out: 1 if waiters, 0 otherwise */
-+ rw_lock_t* lock) /* in: rw-lock */
- {
- return(lock->waiters);
- }
-+
-+/************************************************************************
-+Sets lock->waiters to 1. It is not an error if lock->waiters is already
-+1. On platforms where ATOMIC builtins are used this function enforces a
-+memory barrier. */
- UNIV_INLINE
- void
--rw_lock_set_waiters(
--/*================*/
-- rw_lock_t* lock,
-- ulint flag)
-+rw_lock_set_waiter_flag(
-+/*====================*/
-+ rw_lock_t* lock) /* in: rw-lock */
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_compare_and_swap(&lock->waiters, 0, 1);
-+#else /* HAVE_ATOMIC_BUILTINS */
-+ lock->waiters = 1;
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-+
-+/************************************************************************
-+Resets lock->waiters to 0. It is not an error if lock->waiters is already
-+0. On platforms where ATOMIC builtins are used this function enforces a
-+memory barrier. */
- UNIV_INLINE
--ulint
--rw_lock_get_writer(
--/*===============*/
-- rw_lock_t* lock)
-+void
-+rw_lock_reset_waiter_flag(
-+/*======================*/
-+ rw_lock_t* lock) /* in: rw-lock */
- {
-- return(lock->writer);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_compare_and_swap(&lock->waiters, 1, 0);
-+#else /* HAVE_ATOMIC_BUILTINS */
-+ lock->waiters = 0;
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-+
-+/**********************************************************************
-+Returns the write-status of the lock - this function made more sense
-+with the old rw_lock implementation. */
- UNIV_INLINE
--void
--rw_lock_set_writer(
-+ulint
-+rw_lock_get_writer(
- /*===============*/
-- rw_lock_t* lock,
-- ulint flag)
-+ rw_lock_t* lock)
- {
-- lock->writer = flag;
-+ lint lock_word = lock->lock_word;
-+ if(lock_word > 0) {
-+ /* return NOT_LOCKED in s-lock state, like the writer
-+ member of the old lock implementation. */
-+ return(RW_LOCK_NOT_LOCKED);
-+ } else if (((-lock_word) % X_LOCK_DECR) == 0) {
-+ return(RW_LOCK_EX);
-+ } else {
-+ ut_ad(lock_word > -X_LOCK_DECR);
-+ return(RW_LOCK_WAIT_EX);
-+ }
- }
-+
-+/**********************************************************************
-+Returns number of readers. */
- UNIV_INLINE
- ulint
- rw_lock_get_reader_count(
- /*=====================*/
- rw_lock_t* lock)
- {
-- return(lock->reader_count);
--}
--UNIV_INLINE
--void
--rw_lock_set_reader_count(
--/*=====================*/
-- rw_lock_t* lock,
-- ulint count)
--{
-- lock->reader_count = count;
-+ lint lock_word = lock->lock_word;
-+ if(lock_word > 0) {
-+ /* s-locked, no x-waiters */
-+ return(X_LOCK_DECR - lock_word);
-+ } else if (lock_word < 0 && lock_word > -X_LOCK_DECR) {
-+ /* s-locked, with x-waiters */
-+ return((ulint)(-lock_word));
-+ }
-+ return(0);
- }
-+
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +162,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -115,7 +174,126 @@
- /* out: value of writer_count */
- rw_lock_t* lock) /* in: rw-lock */
- {
-- return(lock->writer_count);
-+ lint lock_copy = lock->lock_word;
-+ /* If there is a reader, lock_word is not divisible by X_LOCK_DECR */
-+ if(lock_copy > 0 || (-lock_copy) % X_LOCK_DECR != 0) {
-+ return(0);
-+ }
-+ return(((-lock_copy) / X_LOCK_DECR) + 1);
-+}
-+
-+/**********************************************************************
-+Two different implementations for decrementing the lock_word of a rw_lock:
-+one for systems supporting atomic operations, one for others. This does
-+does not support recusive x-locks: they should be handled by the caller and
-+need not be atomic since they are performed by the current lock holder.
-+Returns true if the decrement was made, false if not. */
-+UNIV_INLINE
-+ibool
-+rw_lock_lock_word_decr(
-+/*===================*/
-+ /* out: TRUE if decr occurs */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount) /* in: amount of decrement */
-+{
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+
-+ lint local_lock_word = lock->lock_word;
-+ while (local_lock_word > 0) {
-+ if(os_compare_and_swap(&(lock->lock_word),
-+ local_lock_word,
-+ local_lock_word - amount)) {
-+ return(TRUE);
-+ }
-+ local_lock_word = lock->lock_word;
-+ }
-+ return(FALSE);
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ ibool success = FALSE;
-+ mutex_enter(&(lock->mutex));
-+ if(lock->lock_word > 0) {
-+ lock->lock_word -= amount;
-+ success = TRUE;
-+ }
-+ mutex_exit(&(lock->mutex));
-+ return(success);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+}
-+
-+/**********************************************************************
-+Two different implementations for incrementing the lock_word of a rw_lock:
-+one for systems supporting atomic operations, one for others.
-+Returns the value of lock_word after increment. */
-+UNIV_INLINE
-+lint
-+rw_lock_lock_word_incr(
-+/*===================*/
-+ /* out: lock->lock_word after increment */
-+ rw_lock_t* lock, /* in: rw-lock */
-+ ulint amount) /* in: amount of increment */
-+{
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+
-+ return(os_atomic_increment(&(lock->lock_word), amount));
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ lint local_lock_word;
-+
-+ mutex_enter(&(lock->mutex));
-+
-+ lock->lock_word += amount;
-+ local_lock_word = lock->lock_word;
-+
-+ mutex_exit(&(lock->mutex));
-+
-+ return(local_lock_word);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+}
-+
-+/**********************************************************************
-+This function sets the lock->writer_thread and lock->recursive fields.
-+For platforms where we are using atomic builtins instead of lock->mutex
-+it sets the lock->writer_thread field using atomics to ensure memory
-+ordering. Note that it is assumed that the caller of this function
-+effectively owns the lock i.e.: nobody else is allowed to modify
-+lock->writer_thread at this point in time.
-+The protocol is that lock->writer_thread MUST be updated BEFORE the
-+lock->recursive flag is set. */
-+UNIV_INLINE
-+void
-+rw_lock_set_writer_id_and_recursion_flag(
-+/*=====================================*/
-+ rw_lock_t* lock, /* in/out: lock to work on */
-+ ibool recursive) /* in: TRUE if recursion
-+ allowed */
-+{
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t local_thread;
-+ ibool success;
-+
-+ local_thread = lock->writer_thread;
-+ success = os_compare_and_swap(&lock->writer_thread,
-+ local_thread, curr_thread);
-+ ut_a(success);
-+ lock->recursive = recursive;
-+
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
-+ mutex_enter(&lock->mutex);
-+ lock->writer_thread = curr_thread;
-+ lock->recursive = recursive;
-+ mutex_exit(&lock->mutex);
-+
-+#endif /* HAVE_ATOMIC_BUILTINS */
- }
-
- /**********************************************************************
-@@ -133,26 +311,21 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
--#endif /* UNIV_SYNC_DEBUG */
-- /* Check if the writer field is free */
--
-- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
-+ if (!rw_lock_lock_word_decr(lock, 1)) {
-+ /* Locking did not succeed */
-+ return(FALSE);
-+ }
-
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-- line);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, line);
- #endif
-- lock->last_s_file_name = file_name;
-- lock->last_s_line = line;
--
-- return(TRUE); /* locking succeeded */
-- }
-+ /* These debugging values are not set safely: they may be incorrect
-+ or even refer to a line that is invalid for the file name. */
-+ lock->last_s_file_name = file_name;
-+ lock->last_s_line = line;
-
-- return(FALSE); /* locking did not succeed */
-+ return(TRUE); /* locking succeeded */
- }
-
- /**********************************************************************
-@@ -167,11 +340,10 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-- ut_ad(rw_lock_get_reader_count(lock) == 0);
-+ ut_ad(lock->lock_word == X_LOCK_DECR);
-
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ /* Indicate there is a new reader by decrementing lock_word */
-+ lock->lock_word--;
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -194,13 +366,11 @@
- ulint line) /* in: line where lock requested */
- {
- ut_ad(rw_lock_validate(lock));
-- ut_ad(rw_lock_get_reader_count(lock) == 0);
-- ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-+ ut_ad(lock->lock_word == X_LOCK_DECR);
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-+ lock->lock_word -= X_LOCK_DECR;
- lock->writer_thread = os_thread_get_curr_id();
-- lock->writer_count++;
-- lock->pass = 0;
-+ lock->recursive = TRUE;
-
- lock->last_x_file_name = file_name;
- lock->last_x_line = line;
-@@ -241,15 +411,12 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */
-+ if (rw_lock_s_lock_low(lock, pass, file_name, line)) {
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-- mutex_exit(rw_lock_get_mutex(lock));
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -259,86 +426,60 @@
-
- /**********************************************************************
- NOTE! Use the corresponding macro, not directly this function! Lock an
--rw-lock in shared mode for the current thread if the lock can be acquired
--immediately. */
-+rw-lock in exclusive mode for the current thread if the lock can be
-+obtained immediately. */
- UNIV_INLINE
- ibool
--rw_lock_s_lock_func_nowait(
-+rw_lock_x_lock_func_nowait(
- /*=======================*/
- /* out: TRUE if success */
- rw_lock_t* lock, /* in: pointer to rw-lock */
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-- ibool success = FALSE;
--
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- if (lock->writer == RW_LOCK_NOT_LOCKED) {
-- /* Set the shared lock by incrementing the reader count */
-- lock->reader_count++;
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-
--#ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-- line);
--#endif
-+ ibool success;
-
-- lock->last_s_file_name = file_name;
-- lock->last_s_line = line;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ success = os_compare_and_swap(&(lock->lock_word), X_LOCK_DECR, 0);
-+#else
-
-+ success = FALSE;
-+ mutex_enter(&(lock->mutex));
-+ if (lock->lock_word == X_LOCK_DECR) {
-+ lock->lock_word = 0;
- success = TRUE;
- }
-+ mutex_exit(&(lock->mutex));
-
-- mutex_exit(rw_lock_get_mutex(lock));
--
-- return(success);
--}
-+#endif
-+ if (success) {
-+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
-
--/**********************************************************************
--NOTE! Use the corresponding macro, not directly this function! Lock an
--rw-lock in exclusive mode for the current thread if the lock can be
--obtained immediately. */
--UNIV_INLINE
--ibool
--rw_lock_x_lock_func_nowait(
--/*=======================*/
-- /* out: TRUE if success */
-- rw_lock_t* lock, /* in: pointer to rw-lock */
-- const char* file_name,/* in: file name where lock requested */
-- ulint line) /* in: line where requested */
--{
-- ibool success = FALSE;
-- os_thread_id_t curr_thread = os_thread_get_curr_id();
-- mutex_enter(rw_lock_get_mutex(lock));
-+ } else if (lock->recursive
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ /* Relock: this lock_word modification is safe since no other
-+ threads can modify (lock, unlock, or reserve) lock_word while
-+ there is an exclusive writer and this is the writer thread. */
-+ lock->lock_word -= X_LOCK_DECR;
-
-- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-- } else if (UNIV_LIKELY(rw_lock_get_writer(lock)
-- == RW_LOCK_NOT_LOCKED)) {
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_thread = curr_thread;
-- lock->pass = 0;
-- relock:
-- lock->writer_count++;
-+ ut_ad(((-lock->lock_word) % X_LOCK_DECR) == 0);
-
-+ } else {
-+ /* Failure */
-+ return(FALSE);
-+ }
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
- #endif
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- success = TRUE;
-- } else if (rw_lock_get_writer(lock) == RW_LOCK_EX
-- && lock->pass == 0
-- && os_thread_eq(lock->writer_thread, curr_thread)) {
-- goto relock;
-- }
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-
- ut_ad(rw_lock_validate(lock));
-
-- return(success);
-+ return(TRUE);
- }
-
- /**********************************************************************
-@@ -354,39 +495,21 @@
- #endif
- )
- {
-- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
--
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter(mutex);
--
-- /* Reset the shared lock by decrementing the reader count */
--
-- ut_a(lock->reader_count > 0);
-- lock->reader_count--;
-+ ut_ad((lock->lock_word % X_LOCK_DECR) != 0);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
- #endif
-
-- /* If there may be waiters and this was the last s-lock,
-- signal the object */
-+ /* Increment lock_word to indicate 1 less reader */
-+ if (rw_lock_lock_word_incr(lock, 1) == 0) {
-
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->reader_count == 0) {
-- sg = TRUE;
--
-- rw_lock_set_waiters(lock, 0);
-- }
--
-- mutex_exit(mutex);
--
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ /* wait_ex waiter exists. It may not be asleep, but we signal
-+ anyway. We do not wake other waiters, because they can't
-+ exist without wait_ex waiter and wait_ex waiter goes first.*/
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
- sync_array_object_signalled(sync_primary_wait_array);
-+
- }
-
- ut_ad(rw_lock_validate(lock));
-@@ -405,16 +528,15 @@
- /*====================*/
- rw_lock_t* lock) /* in: rw-lock */
- {
-- /* Reset the shared lock by decrementing the reader count */
--
-- ut_ad(lock->reader_count > 0);
--
-- lock->reader_count--;
-+ ut_ad(lock->lock_word < X_LOCK_DECR);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+ /* Decrease reader count by incrementing lock_word */
-+ lock->lock_word++;
-+
- ut_ad(!lock->waiters);
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
-@@ -435,42 +557,32 @@
- #endif
- )
- {
-- ibool sg = FALSE;
--
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter(&(lock->mutex));
--
-- /* Reset the exclusive lock if this thread no longer has an x-mode
-- lock */
--
-- ut_ad(lock->writer_count > 0);
-+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
-
-- lock->writer_count--;
--
-- if (lock->writer_count == 0) {
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-+ /* lock->recursive flag also indicates if lock->writer_thread is
-+ valid or stale. If we are the last of the recursive callers
-+ then we must unset lock->recursive flag to indicate that the
-+ lock->writer_thread is now stale.
-+ Note that since we still hold the x-lock we can safely read the
-+ lock_word. */
-+ if (lock->lock_word == 0) {
-+ /* Last caller in a possible recursive chain. */
-+ lock->recursive = FALSE;
- }
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
-- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-- }
--
-- mutex_exit(&(lock->mutex));
--
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-- sync_array_object_signalled(sync_primary_wait_array);
-+ if (rw_lock_lock_word_incr(lock, X_LOCK_DECR) == X_LOCK_DECR) {
-+ /* Lock is now free. May have to signal read/write waiters.
-+ We do not need to signal wait_ex waiters, since they cannot
-+ exist when there is a writer. */
-+ if (lock->waiters) {
-+ rw_lock_reset_waiter_flag(lock);
-+ os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
- }
-
- ut_ad(rw_lock_validate(lock));
-@@ -492,18 +604,18 @@
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
-- ut_ad(lock->writer_count > 0);
--
-- lock->writer_count--;
--
-- if (lock->writer_count == 0) {
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-- }
-+ ut_ad((lock->lock_word % X_LOCK_DECR) == 0);
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+ if (lock->lock_word == 0) {
-+ lock->recursive = FALSE;
-+ }
-+
-+ lock->lock_word += X_LOCK_DECR;
-+
- ut_ad(!lock->waiters);
- ut_ad(rw_lock_validate(lock));
-
-diff -ruN a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/include/sync0sync.h 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -465,8 +488,11 @@
- struct mutex_struct {
- os_event_t event; /* Used by sync0arr.c for the wait queue */
- ulint lock_word; /* This ulint is the target of the atomic
-- test-and-set instruction in Win32 */
--#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+ test-and-set instruction in Win32 and
-+ x86 32/64 with GCC 4.1.0 or later version */
-+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+#else
- os_fast_mutex_t
- os_fast_mutex; /* In other systems we use this OS mutex
- in place of lock_word */
-@@ -525,8 +551,7 @@
- /* The number of system calls made in this module. Intended for performance
- monitoring. */
-
--extern ulint mutex_system_call_count;
--extern ulint mutex_exit_count;
-+extern ib_longlong mutex_exit_count;
-
- /* Latching order checks start when this is set TRUE */
- extern ibool sync_order_checks_on;
-diff -ruN a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic
---- a/innobase/include/sync0sync.ic 2009-09-10 04:02:59.000000000 +0900
-+++ b/innobase/include/sync0sync.ic 2009-10-22 15:18:44.000000000 +0900
-@@ -1,21 +1,34 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
--#if defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
--/* %z0: Use the size of operand %0 which in our case is *m to determine
--instruction size, it should end up as xchgl. "1" in the input constraint,
--says that "in" has to go in the same place as "out".*/
--#define TAS(m, in, out) \
-- asm volatile ("xchg%z0 %2, %0" \
-- : "=g" (*(m)), "=r" (out) \
-- : "1" (in)) /* Note: "1" here refers to "=r" (out) */
--#endif
--
- /**********************************************************************
- Sets the waiters field in a mutex. */
-
-@@ -94,12 +107,8 @@
- /* mutex_fence(); */
-
- return(res);
--#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
-- ulint res;
--
-- TAS(&mutex->lock_word, 1, res);
--
-- return(res);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ return __sync_lock_test_and_set(&(mutex->lock_word), 1);
- #else
- ibool ret;
-
-@@ -136,10 +145,11 @@
- __asm MOV EDX, 0
- __asm MOV ECX, lw
- __asm XCHG EDX, DWORD PTR [ECX]
--#elif defined(not_defined) && defined(__GNUC__) && defined(UNIV_INTEL_X86)
-- ulint res;
--
-- TAS(&mutex->lock_word, 0, res);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ /* In theory __sync_lock_release should be used to release the lock.
-+ Unfortunately, it does not work properly alone. The workaround is
-+ that more conservative __sync_lock_test_and_set is used instead. */
-+ __sync_lock_test_and_set(&(mutex->lock_word), 0);
- #else
- mutex->lock_word = 0;
-
-diff -ruN a/innobase/row/row0sel.c b/innobase/row/row0sel.c
---- a/innobase/row/row0sel.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/row/row0sel.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1178,7 +1178,7 @@
- rw_lock_s_lock(&btr_search_latch);
-
- search_latch_locked = TRUE;
-- } else if (btr_search_latch.writer_is_wait_ex) {
-+ } else if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_WAIT_EX) {
-
- /* There is an x-latch request waiting: release the
- s-latch for a moment; as an s-latch here is often
-@@ -3123,7 +3123,7 @@
- /* PHASE 0: Release a possible s-latch we are holding on the
- adaptive hash index latch if there is someone waiting behind */
-
-- if (UNIV_UNLIKELY(btr_search_latch.writer != RW_LOCK_NOT_LOCKED)
-+ if (UNIV_UNLIKELY(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_NOT_LOCKED)
- && trx->has_search_latch) {
-
- /* There is an x-latch request on the adaptive hash index:
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-09-10 04:03:01.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The wait array used in synchronization primitives
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -297,25 +320,21 @@
- }
-
- /***********************************************************************
--Puts the cell event in reset state. */
-+Returns the event that the thread owning the cell waits for. */
- static
--ib_longlong
--sync_cell_event_reset(
--/*==================*/
-- /* out: value of signal_count
-- at the time of reset. */
-- ulint type, /* in: lock type mutex/rw_lock */
-- void* object) /* in: the rw_lock/mutex object */
-+os_event_t
-+sync_cell_get_event(
-+/*================*/
-+ sync_cell_t* cell) /* in: non-empty sync array cell */
- {
-+ ulint type = cell->request_type;
-+
- if (type == SYNC_MUTEX) {
-- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
-+ return(((mutex_t *) cell->wait_object)->event);
- } else if (type == RW_LOCK_WAIT_EX) {
-- return(os_event_reset(
-- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ return(((rw_lock_t *) cell->wait_object)->wait_ex_event);
-+ } else { /* RW_LOCK_SHARED and RW_LOCK_EX wait on the same event */
-+ return(((rw_lock_t *) cell->wait_object)->event);
- }
- }
-
-@@ -334,6 +353,7 @@
- ulint* index) /* out: index of the reserved cell */
- {
- sync_cell_t* cell;
-+ os_event_t event;
- ulint i;
-
- ut_a(object);
-@@ -372,8 +392,8 @@
- /* Make sure the event is reset and also store
- the value of signal_count at which the event
- was reset. */
-- cell->signal_count = sync_cell_event_reset(type,
-- object);
-+ event = sync_cell_get_event(cell);
-+ cell->signal_count = os_event_reset(event);
-
- cell->reservation_time = time(NULL);
-
-@@ -413,19 +433,7 @@
- ut_a(!cell->waiting);
- ut_ad(os_thread_get_curr_id() == cell->thread);
-
-- if (cell->request_type == SYNC_MUTEX) {
-- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
-- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
-- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-- }
--
-+ event = sync_cell_get_event(cell);
- cell->waiting = TRUE;
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -464,6 +472,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,9 +501,7 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-@@ -505,21 +512,24 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, waiters flag %lu, "
-+ "lock_word: %lx\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
-- (ulong) rwlock->reader_count,
-+ (ulong) rw_lock_get_reader_count(rwlock),
- (ulong) rwlock->waiters,
-+ rwlock->lock_word,
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -773,28 +783,30 @@
- return(TRUE);
- }
-
-- } else if (cell->request_type == RW_LOCK_EX
-- || cell->request_type == RW_LOCK_WAIT_EX) {
-+ } else if (cell->request_type == RW_LOCK_EX) {
-
- lock = cell->wait_object;
-
-- if (rw_lock_get_reader_count(lock) == 0
-- && rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ if (lock->lock_word > 0) {
-+ /* Either unlocked or only read locked. */
-
- return(TRUE);
- }
-
-- if (rw_lock_get_reader_count(lock) == 0
-- && rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX
-- && os_thread_eq(lock->writer_thread, cell->thread)) {
-+ } else if (cell->request_type == RW_LOCK_WAIT_EX) {
-+
-+ lock = cell->wait_object;
-+
-+ /* lock_word == 0 means all readers have left */
-+ if (lock->lock_word == 0) {
-
- return(TRUE);
- }
--
- } else if (cell->request_type == RW_LOCK_SHARED) {
- lock = cell->wait_object;
-
-- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* lock_word > 0 means no writer or reserved writer */
-+ if (lock->lock_word > 0) {
-
- return(TRUE);
- }
-@@ -839,11 +851,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ (void) os_atomic_increment(&arr->sg_count, 1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -859,6 +875,7 @@
- sync_cell_t* cell;
- ulint count;
- ulint i;
-+ os_event_t event;
-
- sync_array_enter(arr);
-
-@@ -868,36 +885,20 @@
- while (count < arr->n_reserved) {
-
- cell = sync_array_get_nth_cell(arr, i);
-+ i++;
-
-- if (cell->wait_object != NULL) {
--
-+ if (cell->wait_object == NULL) {
-+ continue;
-+ }
- count++;
-
- if (sync_arr_cell_can_wake_up(cell)) {
-
-- if (cell->request_type == SYNC_MUTEX) {
-- mutex_t* mutex;
-+ event = sync_cell_get_event(cell);
-
-- mutex = cell->wait_object;
-- os_event_set(mutex->event);
--#ifdef __WIN__
-- } else if (cell->request_type
-- == RW_LOCK_WAIT_EX) {
-- rw_lock_t* lock;
--
-- lock = cell->wait_object;
-- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-- rw_lock_t* lock;
--
-- lock = cell->wait_object;
-- os_event_set(lock->event);
-- }
-- }
-+ os_event_set(event);
- }
-
-- i++;
- }
-
- sync_array_exit(arr);
-@@ -1014,4 +1015,3 @@
-
- sync_array_exit(arr);
- }
--
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-09-10 04:03:01.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- The read-write lock (for thread synchronization)
-
--(c) 1995 Innobase Oy
--
- Created 9/11/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -15,17 +38,110 @@
- #include "mem0mem.h"
- #include "srv0srv.h"
-
--ulint rw_s_system_call_count = 0;
--ulint rw_s_spin_wait_count = 0;
--ulint rw_s_os_wait_count = 0;
-+/*
-+ IMPLEMENTATION OF THE RW_LOCK
-+ =============================
-+The status of a rw_lock is held in lock_word. The initial value of lock_word is
-+X_LOCK_DECR. lock_word is decremented by 1 for each s-lock and by X_LOCK_DECR
-+for each x-lock. This describes the lock state for each value of lock_word:
-+
-+lock_word == X_LOCK_DECR: Unlocked.
-+0 < lock_word < X_LOCK_DECR: Read locked, no waiting writers.
-+ (X_LOCK_DECR - lock_word) is the
-+ number of readers that hold the lock.
-+lock_word == 0: Write locked
-+-X_LOCK_DECR < lock_word < 0: Read locked, with a waiting writer.
-+ (-lock_word) is the number of readers
-+ that hold the lock.
-+lock_word <= -X_LOCK_DECR: Recursively write locked. lock_word has been
-+ decremented by X_LOCK_DECR once for each lock,
-+ so the number of locks is:
-+ ((-lock_word) / X_LOCK_DECR) + 1
-+When lock_word <= -X_LOCK_DECR, we also know that lock_word % X_LOCK_DECR == 0:
-+other values of lock_word are invalid.
-+
-+The lock_word is always read and updated atomically and consistently, so that
-+it always represents the state of the lock, and the state of the lock changes
-+with a single atomic operation. This lock_word holds all of the information
-+that a thread needs in order to determine if it is eligible to gain the lock
-+or if it must spin or sleep. The one exception to this is that writer_thread
-+must be verified before recursive write locks: to solve this scenario, we make
-+writer_thread readable by all threads, but only writeable by the x-lock holder.
-+
-+The other members of the lock obey the following rules to remain consistent:
-+
-+recursive: This and the writer_thread field together control the
-+ behaviour of recursive x-locking.
-+ lock->recursive must be FALSE in following states:
-+ 1) The writer_thread contains garbage i.e.: the
-+ lock has just been initialized.
-+ 2) The lock is not x-held and there is no
-+ x-waiter waiting on WAIT_EX event.
-+ 3) The lock is x-held or there is an x-waiter
-+ waiting on WAIT_EX event but the 'pass' value
-+ is non-zero.
-+ lock->recursive is TRUE iff:
-+ 1) The lock is x-held or there is an x-waiter
-+ waiting on WAIT_EX event and the 'pass' value
-+ is zero.
-+ This flag must be set after the writer_thread field
-+ has been updated with a memory ordering barrier.
-+ It is unset before the lock_word has been incremented.
-+writer_thread: Is used only in recursive x-locking. Can only be safely
-+ read iff lock->recursive flag is TRUE.
-+ This field is uninitialized at lock creation time and
-+ is updated atomically when x-lock is acquired or when
-+ move_ownership is called. A thread is only allowed to
-+ set the value of this field to it's thread_id i.e.: a
-+ thread cannot set writer_thread to some other thread's
-+ id.
-+waiters: May be set to 1 anytime, but to avoid unnecessary wake-up
-+ signals, it should only be set to 1 when there are threads
-+ waiting on event. Must be 1 when a writer starts waiting to
-+ ensure the current x-locking thread sends a wake-up signal
-+ during unlock. May only be reset to 0 immediately before a
-+ a wake-up signal is sent to event. On most platforms, a
-+ memory barrier is required after waiters is set, and before
-+ verifying lock_word is still held, to ensure some unlocker
-+ really does see the flags new value.
-+event: Threads wait on event for read or writer lock when another
-+ thread has an x-lock or an x-lock reservation (wait_ex). A
-+ thread may only wait on event after performing the following
-+ actions in order:
-+ (1) Record the counter value of event (with os_event_reset).
-+ (2) Set waiters to 1.
-+ (3) Verify lock_word <= 0.
-+ (1) must come before (2) to ensure signal is not missed.
-+ (2) must come before (3) to ensure a signal is sent.
-+ These restrictions force the above ordering.
-+ Immediately before sending the wake-up signal, we should:
-+ (1) Verify lock_word == X_LOCK_DECR (unlocked)
-+ (2) Reset waiters to 0.
-+wait_ex_event: A thread may only wait on the wait_ex_event after it has
-+ performed the following actions in order:
-+ (1) Decrement lock_word by X_LOCK_DECR.
-+ (2) Record counter value of wait_ex_event (os_event_reset,
-+ called from sync_array_reserve_cell).
-+ (3) Verify that lock_word < 0.
-+ (1) must come first to ensures no other threads become reader
-+ or next writer, and notifies unlocker that signal must be sent.
-+ (2) must come before (3) to ensure the signal is not missed.
-+ These restrictions force the above ordering.
-+ Immediately before sending the wake-up signal, we should:
-+ Verify lock_word == 0 (waiting thread holds x_lock)
-+*/
-+
-+ib_longlong rw_s_spin_wait_count = 0;
-+ib_longlong rw_s_spin_round_count = 0;
-+ib_longlong rw_s_os_wait_count = 0;
-+
-+ib_longlong rw_s_exit_count = 0;
-+
-+ib_longlong rw_x_spin_wait_count = 0;
-+ib_longlong rw_x_spin_round_count = 0;
-+ib_longlong rw_x_os_wait_count = 0;
-
--ulint rw_s_exit_count = 0;
--
--ulint rw_x_system_call_count = 0;
--ulint rw_x_spin_wait_count = 0;
--ulint rw_x_os_wait_count = 0;
--
--ulint rw_x_exit_count = 0;
-+ib_longlong rw_x_exit_count = 0;
-
- /* The global list of rw-locks */
- rw_lock_list_t rw_lock_list;
-@@ -99,22 +215,30 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
- lock->mutex.cfile_name = cfile_name;
- lock->mutex.cline = cline;
--#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
-+# if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
--#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+# endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-
-- rw_lock_set_waiters(lock, 0);
-- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
-- lock->writer_count = 0;
-- rw_lock_set_reader_count(lock, 0);
--
-- lock->writer_is_wait_ex = FALSE;
-+#else /* HAVE_ATOMIC_BUILTINS */
-+# ifdef UNIV_DEBUG
-+ UT_NOT_USED(cmutex_name);
-+# endif
-+#endif /* HAVE_ATOMIC_BUILTINS */
-+
-+ lock->lock_word = X_LOCK_DECR;
-+ lock->waiters = 0;
-+
-+ /* We set this value to signify that lock->writer_thread
-+ contains garbage at initialization and cannot be used for
-+ recursive x-locking. */
-+ lock->recursive = FALSE;
-
- #ifdef UNIV_SYNC_DEBUG
- UT_LIST_INIT(lock->debug_list);
-@@ -126,15 +250,13 @@
- lock->cfile_name = cfile_name;
- lock->cline = cline;
-
-+ lock->count_os_wait = 0;
- lock->last_s_file_name = "not yet reserved";
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -158,23 +280,17 @@
- /*=========*/
- rw_lock_t* lock) /* in: rw-lock */
- {
--#ifdef UNIV_DEBUG
- ut_a(rw_lock_validate(lock));
--#endif /* UNIV_DEBUG */
-- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-- ut_a(rw_lock_get_reader_count(lock) == 0);
-+ ut_a(lock->lock_word == X_LOCK_DECR);
-
-- lock->magic_n = 0;
--
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- mutex_enter(&rw_lock_list_mutex);
- os_event_free(lock->event);
-
--#ifdef __WIN__
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -186,6 +302,8 @@
- UT_LIST_REMOVE(list, rw_lock_list, lock);
-
- mutex_exit(&rw_lock_list_mutex);
-+
-+ lock->magic_n = 0;
- }
-
- /**********************************************************************
-@@ -199,19 +317,12 @@
- {
- ut_a(lock);
-
-- mutex_enter(rw_lock_get_mutex(lock));
-+ ulint waiters = rw_lock_get_waiters(lock);
-+ lint lock_word = lock->lock_word;
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-- ut_a((rw_lock_get_reader_count(lock) == 0)
-- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ ut_a(waiters == 0 || waiters == 1);
-+ ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0);
-
- return(TRUE);
- }
-@@ -232,18 +343,15 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint i; /* spin round count */
-+ ulint i = 0; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
-+ rw_s_spin_wait_count++; /* Count calls to this function */
- lock_loop:
-- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
--
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS && lock->lock_word <= 0) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,28 +370,32 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-- mutex_enter(rw_lock_get_mutex(lock));
--
- /* We try once again to obtain the lock */
--
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-- mutex_exit(rw_lock_get_mutex(lock));
-+ rw_s_spin_round_count += i;
-
- return; /* Success */
- } else {
-- /* If we get here, locking did not succeed, we may
-- suspend the thread to wait in the wait array */
-
-- rw_s_system_call_count++;
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto lock_loop;
-+ }
-+
-+ rw_s_spin_round_count += i;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock, RW_LOCK_SHARED,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* Set waiters before checking lock_word to ensure wake-up
-+ signal is sent. This may lead to some unnecessary signals. */
-+ rw_lock_set_waiter_flag(lock);
-+
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -292,11 +404,13 @@
- lock, lock->cfile_name, (ulong) lock->cline);
- }
-
-- rw_s_system_call_count++;
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
- rw_s_os_wait_count++;
-
- sync_array_wait_event(sync_primary_wait_array, index);
-
-+ i = 0;
- goto lock_loop;
- }
- }
-@@ -318,114 +432,130 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-- mutex_enter(&(lock->mutex));
--
-- lock->writer_thread = os_thread_get_curr_id();
--
-- lock->pass = 0;
--
-- mutex_exit(&(lock->mutex));
-+ rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
- }
-
- /**********************************************************************
--Low-level function for acquiring an exclusive lock. */
-+Function for the next writer to call. Waits for readers to exit.
-+The caller must have already decremented lock_word by X_LOCK_DECR.*/
- UNIV_INLINE
--ulint
--rw_lock_x_lock_low(
--/*===============*/
-- /* out: RW_LOCK_NOT_LOCKED if did
-- not succeed, RW_LOCK_EX if success,
-- RW_LOCK_WAIT_EX, if got wait reservation */
-+void
-+rw_lock_x_lock_wait(
-+/*================*/
- rw_lock_t* lock, /* in: pointer to rw-lock */
-+#ifdef UNIV_SYNC_DEBUG
- ulint pass, /* in: pass value; != 0, if the lock will
- be passed to another thread to unlock */
-+#endif
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
--#endif /* UNIV_SYNC_DEBUG */
-- if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ ulint index;
-+ ulint i = 0;
-
-- if (rw_lock_get_reader_count(lock) == 0) {
-+ ut_ad(lock->lock_word <= 0);
-+
-+ while (lock->lock_word < 0) {
-+ if (srv_spin_wait_delay) {
-+ ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
-+ }
-+ if(i < SYNC_SPIN_ROUNDS) {
-+ i++;
-+ continue;
-+ }
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_thread = os_thread_get_curr_id();
-- lock->writer_count++;
-- lock->pass = pass;
-+ /* If there is still a reader, then go to sleep.*/
-+ rw_x_spin_round_count += i;
-+ i = 0;
-+ sync_array_reserve_cell(sync_primary_wait_array,
-+ lock,
-+ RW_LOCK_WAIT_EX,
-+ file_name, line,
-+ &index);
-+ /* Check lock_word to ensure wake-up isn't missed.*/
-+ if(lock->lock_word < 0) {
-
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
-+ rw_x_os_wait_count++;
-+
-+ /* Add debug info as it is needed to detect possible
-+ deadlock. We must add info for WAIT_EX thread for
-+ deadlock detection to work properly. */
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
- file_name, line);
- #endif
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-- } else {
-- /* There are readers, we have to wait */
-- rw_lock_set_writer(lock, RW_LOCK_WAIT_EX);
-- lock->writer_thread = os_thread_get_curr_id();
-- lock->pass = pass;
-- lock->writer_is_wait_ex = TRUE;
-
-+ sync_array_wait_event(sync_primary_wait_array,
-+ index);
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-- file_name, line);
-+ rw_lock_remove_debug_info(lock, pass,
-+ RW_LOCK_WAIT_EX);
- #endif
--
-- return(RW_LOCK_WAIT_EX);
-+ /* It is possible to wake when lock_word < 0.
-+ We must pass the while-loop check to proceed.*/
-+ } else {
-+ sync_array_free_cell(sync_primary_wait_array,
-+ index);
- }
-+ }
-+ rw_x_spin_round_count += i;
-+}
-
-- } else if ((rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- && os_thread_eq(lock->writer_thread,
-- os_thread_get_curr_id())) {
-+/**********************************************************************
-+Low-level function for acquiring an exclusive lock. */
-+UNIV_INLINE
-+ibool
-+rw_lock_x_lock_low(
-+/*===============*/
-+ /* out: RW_LOCK_NOT_LOCKED if did
-+ not succeed, RW_LOCK_EX if success. */
-+ rw_lock_t* lock, /* in: pointer to rw-lock */
-+ ulint pass, /* in: pass value; != 0, if the lock will
-+ be passed to another thread to unlock */
-+ const char* file_name,/* in: file name where lock requested */
-+ ulint line) /* in: line where requested */
-+{
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-
-- if (rw_lock_get_reader_count(lock) == 0) {
-+ if (rw_lock_lock_word_decr(lock, X_LOCK_DECR)) {
-
-- rw_lock_set_writer(lock, RW_LOCK_EX);
-- lock->writer_count++;
-- lock->pass = pass;
-- lock->writer_is_wait_ex = FALSE;
-+ /* lock->recursive also tells us if the writer_thread
-+ field is stale or active. As we are going to write
-+ our own thread id in that field it must be that the
-+ current writer_thread value is not active. */
-+ ut_a(!lock->recursive);
-
-+ /* Decrement occurred: we are writer or next-writer. */
-+ rw_lock_set_writer_id_and_recursion_flag(lock,
-+ pass ? FALSE : TRUE);
-+
-+ rw_lock_x_lock_wait(lock,
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-- file_name, line);
-+ pass,
- #endif
-+ file_name, line);
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-+ } else {
-+ /* Decrement failed: relock or failed lock */
-+ if (!pass && lock->recursive
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ /* Relock */
-+ lock->lock_word -= X_LOCK_DECR;
-+ } else {
-+ /* Another thread locked before us */
-+ return(FALSE);
- }
--
-- return(RW_LOCK_WAIT_EX);
--
-- } else if ((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- && os_thread_eq(lock->writer_thread,
-- os_thread_get_curr_id())
-- && (lock->pass == 0)
-- && (pass == 0)) {
--
-- lock->writer_count++;
--
-+ }
- #ifdef UNIV_SYNC_DEBUG
-- rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-- line);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
- #endif
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = (unsigned int) line;
-
-- lock->last_x_file_name = file_name;
-- lock->last_x_line = line;
--
-- /* Locking succeeded, we may return */
-- return(RW_LOCK_EX);
-- }
--
-- /* Locking did not succeed */
-- return(RW_LOCK_NOT_LOCKED);
-+ return(TRUE);
- }
-
- /**********************************************************************
-@@ -448,47 +578,30 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
- ulint i; /* spin round count */
-+ ibool spinning = FALSE;
-
- ut_ad(rw_lock_validate(lock));
-
--lock_loop:
-- /* Acquire the mutex protecting the rw-lock fields */
-- mutex_enter_fast(&(lock->mutex));
--
-- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ i = 0;
-
-- mutex_exit(&(lock->mutex));
-+lock_loop:
-
-- if (state == RW_LOCK_EX) {
-+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
-+ rw_x_spin_round_count += i;
-
- return; /* Locking succeeded */
-
-- } else if (state == RW_LOCK_NOT_LOCKED) {
--
-- /* Spin waiting for the writer field to become free */
-- i = 0;
--
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-- if (srv_spin_wait_delay) {
-- ut_delay(ut_rnd_interval(0,
-- srv_spin_wait_delay));
-- }
-+ } else {
-
-- i++;
-- }
-- if (i == SYNC_SPIN_ROUNDS) {
-- os_thread_yield();
-+ if (!spinning) {
-+ spinning = TRUE;
-+ rw_x_spin_wait_count++;
- }
-- } else if (state == RW_LOCK_WAIT_EX) {
-
-- /* Spin waiting for the reader count field to become zero */
-- i = 0;
--
-- while (rw_lock_get_reader_count(lock) != 0
-- && i < SYNC_SPIN_ROUNDS) {
-+ /* Spin waiting for the lock_word to become free */
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word <= 0) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -498,12 +611,13 @@
- }
- if (i == SYNC_SPIN_ROUNDS) {
- os_thread_yield();
-+ } else {
-+ goto lock_loop;
- }
-- } else {
-- i = 0; /* Eliminate a compiler warning */
-- ut_error;
- }
-
-+ rw_x_spin_round_count += i;
-+
- if (srv_print_latch_waits) {
- fprintf(stderr,
- "Thread %lu spin wait rw-x-lock at %p cfile %s cline %lu rnds %lu\n",
-@@ -511,39 +625,20 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-- rw_x_spin_wait_count++;
--
-- /* We try once again to obtain the lock. Acquire the mutex protecting
-- the rw-lock fields */
--
-- mutex_enter(rw_lock_get_mutex(lock));
--
-- state = rw_lock_x_lock_low(lock, pass, file_name, line);
--
-- if (state == RW_LOCK_EX) {
-- mutex_exit(rw_lock_get_mutex(lock));
--
-- return; /* Locking succeeded */
-- }
--
-- rw_x_system_call_count++;
--
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
-- (state == RW_LOCK_WAIT_EX)
-- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
--
-- mutex_exit(rw_lock_get_mutex(lock));
-+ /* Waiters must be set before checking lock_word, to ensure signal
-+ is sent. This could lead to a few unnecessary wake-up signals. */
-+ rw_lock_set_waiter_flag(lock);
-+
-+ if (rw_lock_x_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -552,11 +647,13 @@
- lock->cfile_name, (ulong) lock->cline);
- }
-
-- rw_x_system_call_count++;
-+ /* these stats may not be accurate */
-+ lock->count_os_wait++;
- rw_x_os_wait_count++;
-
- sync_array_wait_event(sync_primary_wait_array, index);
-
-+ i = 0;
- goto lock_loop;
- }
-
-@@ -697,7 +794,9 @@
- rw_lock_t* lock, /* in: rw-lock */
- ulint level) /* in: level */
- {
-+#ifdef UNIV_SYNC_DEBUG
- lock->level = level;
-+#endif /* UNIV_SYNC_DEBUG */
- }
-
- #ifdef UNIV_SYNC_DEBUG
-@@ -718,7 +817,7 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-- mutex_enter(&(lock->mutex));
-+ rw_lock_debug_mutex_enter();
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +827,7 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-- mutex_exit(&(lock->mutex));
-+ rw_lock_debug_mutex_exit();
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +835,7 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-- mutex_exit(&(lock->mutex));
-+ rw_lock_debug_mutex_exit();
-
- return(FALSE);
- }
-@@ -758,22 +857,18 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-- mutex_enter(&(lock->mutex));
--
- if (lock_type == RW_LOCK_SHARED) {
-- if (lock->reader_count > 0) {
-+ if (rw_lock_get_reader_count(lock) > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-- mutex_exit(&(lock->mutex));
--
- return(ret);
- }
-
-@@ -801,11 +896,10 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
--
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+#endif
-+ if (lock->lock_word != X_LOCK_DECR) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-@@ -821,8 +915,10 @@
- info = UT_LIST_GET_NEXT(list, info);
- }
- }
--
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-+
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -845,9 +941,10 @@
- "RW-LATCH INFO\n"
- "RW-LATCH: %p ", lock);
-
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
-+ mutex_enter(&(lock->mutex));
-+#endif
-+ if (lock->lock_word != X_LOCK_DECR) {
-
- if (rw_lock_get_waiters(lock)) {
- fputs(" Waiters for the lock exist\n", stderr);
-@@ -861,6 +958,9 @@
- info = UT_LIST_GET_NEXT(list, info);
- }
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
-+ mutex_exit(&(lock->mutex));
-+#endif
- }
-
- /*************************************************************************
-@@ -909,14 +1009,11 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-- mutex_enter(rw_lock_get_mutex(lock));
-
-- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
-- || (rw_lock_get_reader_count(lock) != 0)) {
-+ if (lock->lock_word != X_LOCK_DECR) {
- count++;
- }
-
-- mutex_exit(rw_lock_get_mutex(lock));
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c 2009-10-22 15:15:05.000000000 +0900
-+++ b/innobase/sync/sync0sync.c 2009-10-22 15:18:44.000000000 +0900
-@@ -1,8 +1,31 @@
-+/*****************************************************************************
-+
-+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
-+Copyright (c) 2008, Google Inc.
-+
-+Portions of this file contain modifications contributed and copyrighted by
-+Google, Inc. Those modifications are gratefully acknowledged and are described
-+briefly in the InnoDB documentation. The contributions by Google are
-+incorporated with their permission, and subject to the conditions contained in
-+the file COPYING.Google.
-+
-+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
-+
-+*****************************************************************************/
-+
- /******************************************************
- Mutex, the basic synchronization primitive
-
--(c) 1995 Innobase Oy
--
- Created 9/5/1995 Heikki Tuuri
- *******************************************************/
-
-@@ -140,17 +163,12 @@
-
- ulint sync_dummy = 0;
-
--/* The number of system calls made in this module. Intended for performance
--monitoring. */
--
--ulint mutex_system_call_count = 0;
--
- /* Number of spin waits on mutexes: for performance monitoring */
-
--ulint mutex_spin_round_count = 0;
--ulint mutex_spin_wait_count = 0;
--ulint mutex_os_wait_count = 0;
--ulint mutex_exit_count = 0;
-+ib_longlong mutex_spin_round_count = 0;
-+ib_longlong mutex_spin_wait_count = 0;
-+ib_longlong mutex_os_wait_count = 0;
-+ib_longlong mutex_exit_count = 0;
-
- /* The global array of wait cells for implementation of the database's own
- mutexes and read-write locks */
-@@ -240,6 +258,8 @@
- {
- #if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
- mutex_reset_lock_word(mutex);
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+ mutex_reset_lock_word(mutex);
- #else
- os_fast_mutex_init(&(mutex->os_fast_mutex));
- mutex->lock_word = 0;
-@@ -325,7 +345,9 @@
-
- os_event_free(mutex->event);
-
--#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
-+#elif defined(HAVE_ATOMIC_BUILTINS)
-+#else
- os_fast_mutex_free(&(mutex->os_fast_mutex));
- #endif
- /* If we free the mutex protecting the mutex list (freeing is
-@@ -421,6 +443,12 @@
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
- ut_ad(mutex);
-
-+ /* This update is not thread safe, but we don't mind if the count
-+ isn't exact. Moved out of ifdef that follows because we are willing
-+ to sacrifice the cost of counting this as the data is valuable.
-+ Count the number of calls to mutex_spin_wait. */
-+ mutex_spin_wait_count++;
-+
- mutex_loop:
-
- i = 0;
-@@ -433,7 +461,6 @@
-
- spin_loop:
- #if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
-- mutex_spin_wait_count++;
- mutex->count_spin_loop++;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-
-@@ -502,8 +529,6 @@
- sync_array_reserve_cell(sync_primary_wait_array, mutex,
- SYNC_MUTEX, file_name, line, &index);
-
-- mutex_system_call_count++;
--
- /* The memory order of the array reservation and the change in the
- waiters field is important: when we suspend a thread, we first
- reserve the cell and then set waiters field to 1. When threads are
-@@ -551,7 +576,6 @@
- mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
- #endif
-
-- mutex_system_call_count++;
- mutex_os_wait_count++;
-
- #ifndef UNIV_HOTBACKUP
-@@ -1368,20 +1392,31 @@
- FILE* file) /* in: file where to print */
- {
- #ifdef UNIV_SYNC_DEBUG
-- fprintf(stderr, "Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
-+ fprintf(file, "Mutex exits %llu, rws exits %llu, rwx exits %llu\n",
- mutex_exit_count, rw_s_exit_count, rw_x_exit_count);
- #endif
-
- fprintf(file,
--"Mutex spin waits %lu, rounds %lu, OS waits %lu\n"
--"RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n",
-- (ulong) mutex_spin_wait_count,
-- (ulong) mutex_spin_round_count,
-- (ulong) mutex_os_wait_count,
-- (ulong) rw_s_spin_wait_count,
-- (ulong) rw_s_os_wait_count,
-- (ulong) rw_x_spin_wait_count,
-- (ulong) rw_x_os_wait_count);
-+ "Mutex spin waits %llu, rounds %llu, OS waits %llu\n"
-+ "RW-shared spins %llu, OS waits %llu;"
-+ " RW-excl spins %llu, OS waits %llu\n",
-+ mutex_spin_wait_count,
-+ mutex_spin_round_count,
-+ mutex_os_wait_count,
-+ rw_s_spin_wait_count,
-+ rw_s_os_wait_count,
-+ rw_x_spin_wait_count,
-+ rw_x_os_wait_count);
-+
-+ fprintf(file,
-+ "Spin rounds per wait: %.2f mutex, %.2f RW-shared, "
-+ "%.2f RW-excl\n",
-+ (double) mutex_spin_round_count /
-+ (mutex_spin_wait_count ? mutex_spin_wait_count : 1),
-+ (double) rw_s_spin_round_count /
-+ (rw_s_spin_wait_count ? rw_s_spin_wait_count : 1),
-+ (double) rw_x_spin_round_count /
-+ (rw_x_spin_wait_count ? rw_x_spin_wait_count : 1));
- }
-
- /***********************************************************************
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-10-22 15:18:30.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks ported from InnoDB Plugin
-+Version=1.0
-+Author=InnoBase Oy.
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20100217/innodb_rw_lock_old.patch b/percona/5.0.87-b20-20100217/innodb_rw_lock_old.patch
deleted file mode 100644
index b4a1a79..0000000
--- a/percona/5.0.87-b20-20100217/innodb_rw_lock_old.patch
+++ /dev/null
@@ -1,1357 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-05-20 14:21:44.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-05-20 14:39:34.000000000 +0900
-@@ -773,7 +773,7 @@
- rw_lock_s_lock(&btr_search_latch);
- }
-
-- ut_ad(btr_search_latch.writer != RW_LOCK_EX);
-+ ut_ad(btr_search_latch.writer_count == 0);
- ut_ad(btr_search_latch.reader_count > 0);
-
- rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
-diff -ruN a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
---- a/innobase/include/sync0rw.h 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.h 2009-04-16 16:15:28.000000000 +0900
-@@ -325,7 +325,17 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_x_waiters(
-+/*==================*/
-+ rw_lock_t* lock);
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
- /*================*/
- rw_lock_t* lock);
- UNIV_INLINE
-@@ -408,6 +418,17 @@
- rw_lock_debug_t* info); /* in: debug struct */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+/* This value means NOT_LOCKED */
-+#define RW_LOCK_BIAS 0x00100000
-+#else
-+#error HAVE_ATOMIC_BUILTINS is not defined. Do you use enough new GCC or compatibles?
-+#error Or do you use exact options for CFLAGS?
-+#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
-+#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
-+#error Otherwise, this build may be slower than normal version.
-+#endif
-+
- /* NOTE! The structure appears here only for the compiler to know its size.
- Do not use its fields directly! The structure used in the spin lock
- implementation of a read-write lock. Several threads may have a shared lock
-@@ -417,9 +438,9 @@
- field. Then no new readers are allowed in. */
-
- struct rw_lock_struct {
-- os_event_t event; /* Used by sync0arr.c for thread queueing */
--
--#ifdef __WIN__
-+ /* Used by sync0arr.c for thread queueing */
-+ os_event_t s_event; /* Used for s_lock */
-+ os_event_t x_event; /* Used for x_lock */
- os_event_t wait_ex_event; /* This windows specific event is
- used by the thread which has set the
- lock state to RW_LOCK_WAIT_EX. The
-@@ -427,31 +448,35 @@
- thread will be the next one to proceed
- once the current the event gets
- signalled. See LEMMA 2 in sync0sync.c */
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ volatile lint lock_word; /* Used by using atomic builtin */
- #endif
-
-- ulint reader_count; /* Number of readers who have locked this
-+ volatile ulint reader_count; /* Number of readers who have locked this
- lock in the shared mode */
-- ulint writer; /* This field is set to RW_LOCK_EX if there
-+ volatile ulint writer; /* This field is set to RW_LOCK_EX if there
- is a writer owning the lock (in exclusive
- mode), RW_LOCK_WAIT_EX if a writer is
- queueing for the lock, and
- RW_LOCK_NOT_LOCKED, otherwise. */
-- os_thread_id_t writer_thread;
-+ volatile os_thread_id_t writer_thread;
- /* Thread id of a possible writer thread */
-- ulint writer_count; /* Number of times the same thread has
-+ volatile ulint writer_count; /* Number of times the same thread has
- recursively locked the lock in the exclusive
- mode */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t mutex; /* The mutex protecting rw_lock_struct */
-+#endif
- ulint pass; /* Default value 0. This is set to some
- value != 0 given by the caller of an x-lock
- operation, if the x-lock is to be passed to
- another thread to unlock (which happens in
- asynchronous i/o). */
-- ulint waiters; /* This ulint is set to 1 if there are
-- waiters (readers or writers) in the global
-- wait array, waiting for this rw_lock.
-- Otherwise, == 0. */
-- ibool writer_is_wait_ex;
-+ volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
-+ volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
-+ volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
-+ volatile ibool writer_is_wait_ex;
- /* This is TRUE if the writer field is
- RW_LOCK_WAIT_EX; this field is located far
- from the memory update hotspot fields which
-diff -ruN a/innobase/include/sync0rw.ic b/innobase/include/sync0rw.ic
---- a/innobase/include/sync0rw.ic 2009-01-30 06:42:20.000000000 +0900
-+++ b/innobase/include/sync0rw.ic 2009-04-16 17:06:53.000000000 +0900
-@@ -47,20 +47,64 @@
- Accessor functions for rw lock. */
- UNIV_INLINE
- ulint
--rw_lock_get_waiters(
-+rw_lock_get_s_waiters(
- /*================*/
- rw_lock_t* lock)
- {
-- return(lock->waiters);
-+ return(lock->s_waiters);
- }
- UNIV_INLINE
--void
--rw_lock_set_waiters(
-+ulint
-+rw_lock_get_x_waiters(
- /*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->x_waiters);
-+}
-+UNIV_INLINE
-+ulint
-+rw_lock_get_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock)
-+{
-+ return(lock->wait_ex_waiters);
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_s_waiters(
- rw_lock_t* lock,
- ulint flag)
- {
-- lock->waiters = flag;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->s_waiters, flag);
-+#else
-+ lock->s_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_x_waiters(
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->x_waiters, flag);
-+#else
-+ lock->x_waiters = flag;
-+#endif
-+}
-+UNIV_INLINE
-+void
-+rw_lock_set_wx_waiters(
-+/*================*/
-+ rw_lock_t* lock,
-+ ulint flag)
-+{
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_lock_test_and_set(&lock->wait_ex_waiters, flag);
-+#else
-+ lock->wait_ex_waiters = flag;
-+#endif
- }
- UNIV_INLINE
- ulint
-@@ -68,7 +112,19 @@
- /*===============*/
- rw_lock_t* lock)
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->writer == RW_LOCK_NOT_LOCKED) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ if (lock->writer_is_wait_ex) {
-+ return(RW_LOCK_WAIT_EX);
-+ } else {
-+ return(RW_LOCK_EX);
-+ }
-+#else
- return(lock->writer);
-+#endif
- }
- UNIV_INLINE
- void
-@@ -96,6 +152,7 @@
- {
- lock->reader_count = count;
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- UNIV_INLINE
- mutex_t*
- rw_lock_get_mutex(
-@@ -104,6 +161,7 @@
- {
- return(&(lock->mutex));
- }
-+#endif
-
- /**********************************************************************
- Returns the value of writer_count for the lock. Does not reserve the lock
-@@ -133,14 +191,26 @@
- const char* file_name, /* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
--#ifdef UNIV_SYNC_DEBUG
-+#if defined(UNIV_SYNC_DEBUG) && !defined(HAVE_ATOMIC_BUILTINS)
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
- /* Check if the writer field is free */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_LIKELY(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- if (UNIV_LIKELY(lock->writer == RW_LOCK_NOT_LOCKED)) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
-@@ -167,11 +237,15 @@
- const char* file_name, /* in: file name where requested */
- ulint line) /* in: line where lock requested */
- {
-- ut_ad(lock->writer == RW_LOCK_NOT_LOCKED);
-+ ut_ad(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
- ut_ad(rw_lock_get_reader_count(lock) == 0);
-
- /* Set the shared lock by incrementing the reader count */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- lock->reader_count++;
-+#endif
-
- lock->last_s_file_name = file_name;
- lock->last_s_line = line;
-@@ -199,7 +273,11 @@
-
- rw_lock_set_writer(lock, RW_LOCK_EX);
- lock->writer_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+#else
- lock->writer_count++;
-+#endif
- lock->pass = 0;
-
- lock->last_x_file_name = file_name;
-@@ -241,15 +319,21 @@
- ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */
- #endif /* UNIV_SYNC_DEBUG */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if (UNIV_LIKELY(rw_lock_s_lock_low(lock, pass, file_name, line))) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
- /* Did not succeed, try spin wait */
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- rw_lock_s_lock_spin(lock, pass, file_name, line);
-
-@@ -272,11 +356,23 @@
- {
- ibool success = FALSE;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED) {
-+ /* try s-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),1) <= 0) {
-+ /* fail */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+ return(FALSE); /* locking did not succeed */
-+ }
-+ /* success */
-+ __sync_fetch_and_add(&(lock->reader_count),1);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (lock->writer == RW_LOCK_NOT_LOCKED) {
- /* Set the shared lock by incrementing the reader count */
- lock->reader_count++;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
-@@ -289,7 +385,9 @@
- success = TRUE;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(success);
- }
-@@ -309,6 +407,54 @@
- {
- ibool success = FALSE;
- os_thread_id_t curr_thread = os_thread_get_curr_id();
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (lock->reader_count == 0) {
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = 0;
-+ lock->writer_is_wait_ex = FALSE;
-+ /* next function may work as memory barrier */
-+ relock:
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ ut_ad(rw_lock_validate(lock));
-+
-+ return(TRUE);
-+ } else {
-+ /* fail (x-lock) */
-+ if (__sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS)
-+ == 0)
-+ goto retry_x_lock;
-+ }
-+
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+ }
-+
-+ if (lock->pass == 0
-+ && os_thread_eq(lock->writer_thread, curr_thread)) {
-+ goto relock;
-+ }
-+
-+ //ut_ad(rw_lock_validate(lock));
-+
-+ return(FALSE);
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-
- if (UNIV_UNLIKELY(rw_lock_get_reader_count(lock) != 0)) {
-@@ -339,6 +485,7 @@
- ut_ad(rw_lock_validate(lock));
-
- return(success);
-+#endif
- }
-
- /**********************************************************************
-@@ -354,16 +501,33 @@
- #endif
- )
- {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_t* mutex = &(lock->mutex);
-- ibool sg = FALSE;
-+#endif
-+ ibool x_sg = FALSE;
-+ ibool wx_sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(mutex);
-+#endif
-
- /* Reset the shared lock by decrementing the reader count */
-
- ut_a(lock->reader_count > 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),1);
-+
-+ if(__sync_sub_and_fetch(&(lock->reader_count),1) == 0) {
-+ last = TRUE;
-+ }
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
-@@ -372,22 +536,39 @@
- /* If there may be waiters and this was the last s-lock,
- signal the object */
-
-- if (UNIV_UNLIKELY(lock->waiters)
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0))) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ else if (UNIV_UNLIKELY(last && __sync_lock_test_and_set(&lock->x_waiters, 0))) {
-+ os_event_set(lock->x_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
-+ if (UNIV_UNLIKELY(lock->wait_ex_waiters)
- && lock->reader_count == 0) {
-- sg = TRUE;
-+ wx_sg = TRUE;
-
-- rw_lock_set_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
-+ }
-+ else if (UNIV_UNLIKELY(lock->x_waiters)
-+ && lock->reader_count == 0) {
-+ x_sg = TRUE;
-+
-+ rw_lock_set_x_waiters(lock, 0);
- }
-
- mutex_exit(mutex);
-
-- if (UNIV_UNLIKELY(sg)) {
--#ifdef __WIN__
-+ if (UNIV_UNLIKELY(wx_sg)) {
- os_event_set(lock->wait_ex_event);
--#endif
-- os_event_set(lock->event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ } else if (UNIV_UNLIKELY(x_sg)) {
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-+#endif
-
- ut_ad(rw_lock_validate(lock));
-
-@@ -409,13 +590,22 @@
-
- ut_ad(lock->reader_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_sub_and_fetch(&(lock->reader_count),1);
-+#else
- lock->reader_count--;
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
- #ifdef UNIV_SYNC_PERF_STAT
- rw_s_exit_count++;
-@@ -435,41 +625,83 @@
- #endif
- )
- {
-- ibool sg = FALSE;
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ibool last = FALSE;
-+#endif
-+ ibool s_sg = FALSE;
-+ ibool x_sg = FALSE;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter(&(lock->mutex));
-+#endif
-
- /* Reset the exclusive lock if this thread no longer has an x-mode
- lock */
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+ last = TRUE;
-+ }
-+
-+ if (last) {
-+ /* unlock lock_word */
-+ __sync_fetch_and_add(&(lock->lock_word),RW_LOCK_BIAS);
-+
-+ /* FIXME: It is a value of bad manners for pthread.
-+ But we shouldn't keep an ID of not-owner. */
-+ lock->writer_thread = -1;
-+ __sync_lock_test_and_set(&(lock->writer),RW_LOCK_NOT_LOCKED);
-+ }
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-+#endif
-
- #ifdef UNIV_SYNC_DEBUG
- rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
- #endif
-
- /* If there may be waiters, signal the lock */
-- if (UNIV_UNLIKELY(lock->waiters)
-- && lock->writer_count == 0) {
--
-- sg = TRUE;
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (last) {
-+ if(__sync_lock_test_and_set(&lock->s_waiters, 0)){
-+ s_sg = TRUE;
-+ }
-+ if(__sync_lock_test_and_set(&lock->x_waiters, 0)){
-+ x_sg = TRUE;
-+ }
-+ }
-+#else
-+ if (lock->writer_count == 0) {
-+ if(lock->s_waiters){
-+ s_sg = TRUE;
-+ rw_lock_set_s_waiters(lock, 0);
-+ }
-+ if(lock->x_waiters){
-+ x_sg = TRUE;
-+ rw_lock_set_x_waiters(lock, 0);
-+ }
- }
-
- mutex_exit(&(lock->mutex));
-+#endif
-
-- if (UNIV_UNLIKELY(sg)) {
-+ if (UNIV_UNLIKELY(s_sg)) {
-+ os_event_set(lock->s_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+ if (UNIV_UNLIKELY(x_sg)) {
- #ifdef __WIN__
-+ /* I doubt the necessity of it. */
- os_event_set(lock->wait_ex_event);
- #endif
-- os_event_set(lock->event);
-+ os_event_set(lock->x_event);
- sync_array_object_signalled(sync_primary_wait_array);
- }
-
-@@ -494,9 +726,13 @@
-
- ut_ad(lock->writer_count > 0);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if(__sync_sub_and_fetch(&(lock->writer_count),1) == 0) {
-+#else
- lock->writer_count--;
-
- if (lock->writer_count == 0) {
-+#endif
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- }
-
-@@ -504,7 +740,12 @@
- rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
- #endif
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ut_ad(!lock->s_waiters);
-+ ut_ad(!lock->x_waiters);
-+#else
- ut_ad(!lock->waiters);
-+#endif
- ut_ad(rw_lock_validate(lock));
-
- #ifdef UNIV_SYNC_PERF_STAT
-diff -ruN a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
---- a/innobase/sync/sync0arr.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0arr.c 2009-04-16 16:15:28.000000000 +0900
-@@ -309,13 +309,13 @@
- {
- if (type == SYNC_MUTEX) {
- return(os_event_reset(((mutex_t *) object)->event));
--#ifdef __WIN__
- } else if (type == RW_LOCK_WAIT_EX) {
- return(os_event_reset(
- ((rw_lock_t *) object)->wait_ex_event));
--#endif
-- } else {
-- return(os_event_reset(((rw_lock_t *) object)->event));
-+ } else if (type == RW_LOCK_SHARED) {
-+ return(os_event_reset(((rw_lock_t *) object)->s_event));
-+ } else { /* RW_LOCK_EX */
-+ return(os_event_reset(((rw_lock_t *) object)->x_event));
- }
- }
-
-@@ -415,15 +415,12 @@
-
- if (cell->request_type == SYNC_MUTEX) {
- event = ((mutex_t*) cell->wait_object)->event;
--#ifdef __WIN__
-- /* On windows if the thread about to wait is the one which
-- has set the state of the rw_lock to RW_LOCK_WAIT_EX, then
-- it waits on a special event i.e.: wait_ex_event. */
- } else if (cell->request_type == RW_LOCK_WAIT_EX) {
- event = ((rw_lock_t*) cell->wait_object)->wait_ex_event;
--#endif
-- } else {
-- event = ((rw_lock_t*) cell->wait_object)->event;
-+ } else if (cell->request_type == RW_LOCK_SHARED) {
-+ event = ((rw_lock_t*) cell->wait_object)->s_event;
-+ } else {
-+ event = ((rw_lock_t*) cell->wait_object)->x_event;
- }
-
- cell->waiting = TRUE;
-@@ -464,6 +461,7 @@
- mutex_t* mutex;
- rw_lock_t* rwlock;
- ulint type;
-+ ulint writer;
-
- type = cell->request_type;
-
-@@ -492,12 +490,10 @@
- (ulong) mutex->waiters);
-
- } else if (type == RW_LOCK_EX
--#ifdef __WIN__
- || type == RW_LOCK_WAIT_EX
--#endif
- || type == RW_LOCK_SHARED) {
-
-- fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
-+ fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
-
- rwlock = cell->old_wait_rw_lock;
-
-@@ -505,21 +501,23 @@
- " RW-latch at %p created in file %s line %lu\n",
- rwlock, rwlock->cfile_name,
- (ulong) rwlock->cline);
-- if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
-+ writer = rw_lock_get_writer(rwlock);
-+ if (writer != RW_LOCK_NOT_LOCKED) {
- fprintf(file,
- "a writer (thread id %lu) has reserved it in mode %s",
- (ulong) os_thread_pf(rwlock->writer_thread),
-- rwlock->writer == RW_LOCK_EX
-+ writer == RW_LOCK_EX
- ? " exclusive\n"
- : " wait exclusive\n");
- }
-
- fprintf(file,
-- "number of readers %lu, waiters flag %lu\n"
-+ "number of readers %lu, s_waiters flag %lu, x_waiters flag %lu\n"
- "Last time read locked in file %s line %lu\n"
- "Last time write locked in file %s line %lu\n",
- (ulong) rwlock->reader_count,
-- (ulong) rwlock->waiters,
-+ (ulong) rwlock->s_waiters,
-+ (ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
- rwlock->last_s_file_name,
- (ulong) rwlock->last_s_line,
- rwlock->last_x_file_name,
-@@ -839,11 +837,15 @@
- /*========================*/
- sync_array_t* arr) /* in: wait array */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ __sync_fetch_and_add(&(arr->sg_count),1);
-+#else
- sync_array_enter(arr);
-
- arr->sg_count++;
-
- sync_array_exit(arr);
-+#endif
- }
-
- /**************************************************************************
-@@ -880,19 +882,23 @@
-
- mutex = cell->wait_object;
- os_event_set(mutex->event);
--#ifdef __WIN__
- } else if (cell->request_type
- == RW_LOCK_WAIT_EX) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
- os_event_set(lock->wait_ex_event);
--#endif
-- } else {
-+ } else if (cell->request_type
-+ == RW_LOCK_SHARED) {
- rw_lock_t* lock;
-
- lock = cell->wait_object;
-- os_event_set(lock->event);
-+ os_event_set(lock->s_event);
-+ } else {
-+ rw_lock_t* lock;
-+
-+ lock = cell->wait_object;
-+ os_event_set(lock->x_event);
- }
- }
- }
-diff -ruN a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
---- a/innobase/sync/sync0rw.c 2009-01-30 06:42:24.000000000 +0900
-+++ b/innobase/sync/sync0rw.c 2009-04-16 17:33:59.000000000 +0900
-@@ -99,6 +99,7 @@
- object is created, then the following call initializes
- the sync system. */
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_create(rw_lock_get_mutex(lock));
- mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
-
-@@ -108,8 +109,14 @@
- lock->mutex.cmutex_name = cmutex_name;
- lock->mutex.mutex_type = 1;
- #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
-+#endif /* !HAVE_ATOMIC_BUILTINS */
-
-- rw_lock_set_waiters(lock, 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ lock->lock_word = RW_LOCK_BIAS;
-+#endif
-+ rw_lock_set_s_waiters(lock, 0);
-+ rw_lock_set_x_waiters(lock, 0);
-+ rw_lock_set_wx_waiters(lock, 0);
- rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
- lock->writer_count = 0;
- rw_lock_set_reader_count(lock, 0);
-@@ -130,11 +137,9 @@
- lock->last_x_file_name = "not yet reserved";
- lock->last_s_line = 0;
- lock->last_x_line = 0;
-- lock->event = os_event_create(NULL);
--
--#ifdef __WIN__
-+ lock->s_event = os_event_create(NULL);
-+ lock->x_event = os_event_create(NULL);
- lock->wait_ex_event = os_event_create(NULL);
--#endif
-
- mutex_enter(&rw_lock_list_mutex);
-
-@@ -162,19 +167,21 @@
- ut_a(rw_lock_validate(lock));
- #endif /* UNIV_DEBUG */
- ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
-- ut_a(rw_lock_get_waiters(lock) == 0);
-+ ut_a(rw_lock_get_s_waiters(lock) == 0);
-+ ut_a(rw_lock_get_x_waiters(lock) == 0);
-+ ut_a(rw_lock_get_wx_waiters(lock) == 0);
- ut_a(rw_lock_get_reader_count(lock) == 0);
-
- lock->magic_n = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_free(rw_lock_get_mutex(lock));
-+#endif
-
- mutex_enter(&rw_lock_list_mutex);
-- os_event_free(lock->event);
--
--#ifdef __WIN__
-+ os_event_free(lock->s_event);
-+ os_event_free(lock->x_event);
- os_event_free(lock->wait_ex_event);
--#endif
-
- if (UT_LIST_GET_PREV(list, lock)) {
- ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
-@@ -192,26 +199,43 @@
- Checks that the rw-lock has been initialized and that there are no
- simultaneous shared and exclusive locks. */
-
-+/* MEMO: If HAVE_ATOMIC_BUILTINS, we should use this function statically. */
-+
- ibool
- rw_lock_validate(
- /*=============*/
- rw_lock_t* lock)
- {
-+ ulint test;
- ut_a(lock);
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((rw_lock_get_reader_count(lock) == 0)
- || (rw_lock_get_writer(lock) != RW_LOCK_EX));
-- ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX)
-- || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED));
-- ut_a((rw_lock_get_waiters(lock) == 0)
-- || (rw_lock_get_waiters(lock) == 1));
-+#endif
-+ test = rw_lock_get_writer(lock);
-+ ut_a((test == RW_LOCK_EX)
-+ || (test == RW_LOCK_WAIT_EX)
-+ || (test == RW_LOCK_NOT_LOCKED));
-+ test = rw_lock_get_s_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_x_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+ test = rw_lock_get_wx_waiters(lock);
-+ ut_a((test == 0)
-+ || (test == 1));
-+#ifndef HAVE_ATOMIC_BUILTINS
- ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0));
-
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return(TRUE);
- }
-@@ -237,13 +261,14 @@
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+spin_loop:
- rw_s_spin_wait_count++;
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
- }
-@@ -262,15 +287,27 @@
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- /* We try once again to obtain the lock */
-
- if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Success */
- } else {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
- /* If we get here, locking did not succeed, we may
- suspend the thread to wait in the wait array */
-
-@@ -281,9 +318,26 @@
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ rw_lock_set_s_waiters(lock, 1);
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ if (TRUE == rw_lock_s_lock_low(lock, pass, file_name, line)) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Success */
-+ }
-+ }
-
-+ /* If wait_ex_waiter stalls, wakes it. */
-+ if (lock->reader_count == 0
-+ && __sync_lock_test_and_set(&lock->wait_ex_waiters, 0)) {
-+ os_event_set(lock->wait_ex_event);
-+ sync_array_object_signalled(sync_primary_wait_array);
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -318,13 +372,19 @@
- {
- ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- lock->writer_thread = os_thread_get_curr_id();
-
- lock->pass = 0;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#else
-+ __sync_synchronize();
-+#endif
- }
-
- /**********************************************************************
-@@ -342,6 +402,89 @@
- const char* file_name,/* in: file name where lock requested */
- ulint line) /* in: line where requested */
- {
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ os_thread_id_t curr_thread = os_thread_get_curr_id();
-+retry_writer:
-+ /* try to lock writer */
-+ if(__sync_lock_test_and_set(&(lock->writer),RW_LOCK_EX)
-+ == RW_LOCK_NOT_LOCKED) {
-+ /* success */
-+ /* obtain RW_LOCK_WAIT_EX right */
-+ lock->writer_thread = curr_thread;
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = TRUE;
-+ /* atomic operation may be safer about memory order. */
-+ __sync_synchronize();
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
-+ file_name, line);
-+#endif
-+ }
-+
-+ if (!os_thread_eq(lock->writer_thread, curr_thread)) {
-+ return(RW_LOCK_NOT_LOCKED);
-+ }
-+
-+ switch(rw_lock_get_writer(lock)) {
-+ case RW_LOCK_WAIT_EX:
-+ /* have right to try x-lock */
-+retry_x_lock:
-+ /* try x-lock */
-+ if(__sync_sub_and_fetch(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* success */
-+ lock->pass = pass;
-+ lock->writer_is_wait_ex = FALSE;
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
-+ file_name, line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ } else if(__sync_fetch_and_add(&(lock->lock_word),
-+ RW_LOCK_BIAS) == 0) {
-+ /* retry x-lock */
-+ goto retry_x_lock;
-+ }
-+
-+ /* There are readers, we have to wait */
-+ return(RW_LOCK_WAIT_EX);
-+
-+ break;
-+
-+ case RW_LOCK_EX:
-+ /* already have x-lock */
-+ if ((lock->pass == 0)&&(pass == 0)) {
-+ __sync_fetch_and_add(&(lock->writer_count),1);
-+
-+#ifdef UNIV_SYNC_DEBUG
-+ rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
-+ line);
-+#endif
-+
-+ lock->last_x_file_name = file_name;
-+ lock->last_x_line = line;
-+
-+ /* Locking succeeded, we may return */
-+ return(RW_LOCK_EX);
-+ }
-+
-+ return(RW_LOCK_NOT_LOCKED);
-+
-+ break;
-+
-+ default: /* RW_LOCK_NOT_LOCKED? maybe impossible */
-+ goto retry_writer;
-+ }
-+#else /* HAVE_ATOMIC_BUILTINS */
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(rw_lock_get_mutex(lock)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -423,6 +566,7 @@
- /* Locking succeeded, we may return */
- return(RW_LOCK_EX);
- }
-+#endif /* HAVE_ATOMIC_BUILTINS */
-
- /* Locking did not succeed */
- return(RW_LOCK_NOT_LOCKED);
-@@ -448,19 +592,33 @@
- ulint line) /* in: line where requested */
- {
- ulint index; /* index of the reserved wait cell */
-- ulint state; /* lock state acquired */
-+ ulint state = RW_LOCK_NOT_LOCKED; /* lock state acquired */
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ ulint prev_state = RW_LOCK_NOT_LOCKED;
-+#endif
- ulint i; /* spin round count */
-
- ut_ad(rw_lock_validate(lock));
-
- lock_loop:
-+ i = 0;
-+
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- /* Acquire the mutex protecting the rw-lock fields */
- mutex_enter_fast(&(lock->mutex));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#else
- mutex_exit(&(lock->mutex));
-+#endif
-
-+spin_loop:
- if (state == RW_LOCK_EX) {
-
- return; /* Locking succeeded */
-@@ -468,10 +626,9 @@
- } else if (state == RW_LOCK_NOT_LOCKED) {
-
- /* Spin waiting for the writer field to become free */
-- i = 0;
-
-- while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED
-- && i < SYNC_SPIN_ROUNDS) {
-+ while (i < SYNC_SPIN_ROUNDS
-+ && lock->lock_word != RW_LOCK_BIAS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
- srv_spin_wait_delay));
-@@ -485,9 +642,12 @@
- } else if (state == RW_LOCK_WAIT_EX) {
-
- /* Spin waiting for the reader count field to become zero */
-- i = 0;
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ while (lock->lock_word != RW_LOCK_BIAS
-+#else
- while (rw_lock_get_reader_count(lock) != 0
-+#endif
- && i < SYNC_SPIN_ROUNDS) {
- if (srv_spin_wait_delay) {
- ut_delay(ut_rnd_interval(0,
-@@ -500,7 +660,6 @@
- os_thread_yield();
- }
- } else {
-- i = 0; /* Eliminate a compiler warning */
- ut_error;
- }
-
-@@ -516,34 +675,69 @@
- /* We try once again to obtain the lock. Acquire the mutex protecting
- the rw-lock fields */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ prev_state = state;
-+#else
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- state = rw_lock_x_lock_low(lock, pass, file_name, line);
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (state != prev_state) i=0; /* if progress, reset counter. */
-+#endif
-+
- if (state == RW_LOCK_EX) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- return; /* Locking succeeded */
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ i++;
-+
-+ if (i < SYNC_SPIN_ROUNDS) {
-+ goto spin_loop;
-+ }
-+#endif
-+
- rw_x_system_call_count++;
-
- sync_array_reserve_cell(sync_primary_wait_array,
- lock,
--#ifdef __WIN__
-- /* On windows RW_LOCK_WAIT_EX signifies
-- that this thread should wait on the
-- special wait_ex_event. */
- (state == RW_LOCK_WAIT_EX)
- ? RW_LOCK_WAIT_EX :
--#endif
- RW_LOCK_EX,
- file_name, line,
- &index);
-
-- rw_lock_set_waiters(lock, 1);
-+ if (state == RW_LOCK_WAIT_EX) {
-+ rw_lock_set_wx_waiters(lock, 1);
-+ } else {
-+ rw_lock_set_x_waiters(lock, 1);
-+ }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ /* like sync0sync.c doing */
-+ for (i = 0; i < 4; i++) {
-+ prev_state = state;
-+ state = rw_lock_x_lock_low(lock, pass, file_name, line);
-+ if (state == RW_LOCK_EX) {
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ return; /* Locking succeeded */
-+ }
-+ if (state != prev_state) {
-+ /* retry! */
-+ sync_array_free_cell(sync_primary_wait_array, index);
-+ goto lock_loop;
-+ }
-+ }
-+#else
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
-
- if (srv_print_latch_waits) {
- fprintf(stderr,
-@@ -718,7 +912,9 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- info = UT_LIST_GET_FIRST(lock->debug_list);
-
-@@ -728,7 +924,9 @@
- && (info->pass == 0)
- && (info->lock_type == lock_type)) {
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- /* Found! */
-
- return(TRUE);
-@@ -736,7 +934,9 @@
-
- info = UT_LIST_GET_NEXT(list, info);
- }
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(FALSE);
- }
-@@ -758,21 +958,25 @@
- ut_ad(lock);
- ut_ad(rw_lock_validate(lock));
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if (lock_type == RW_LOCK_SHARED) {
- if (lock->reader_count > 0) {
- ret = TRUE;
- }
- } else if (lock_type == RW_LOCK_EX) {
-- if (lock->writer == RW_LOCK_EX) {
-+ if (rw_lock_get_writer(lock) == RW_LOCK_EX) {
- ret = TRUE;
- }
- } else {
- ut_error;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
-
- return(ret);
- }
-@@ -801,16 +1005,26 @@
-
- count++;
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(&(lock->mutex));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
- fprintf(stderr, "RW-LOCK: %p ", lock);
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -822,7 +1036,9 @@
- }
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(&(lock->mutex));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-@@ -847,10 +1063,18 @@
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)
-- || (rw_lock_get_waiters(lock) != 0)) {
-+ || (rw_lock_get_s_waiters(lock) != 0)
-+ || (rw_lock_get_x_waiters(lock) != 0)
-+ || (rw_lock_get_wx_waiters(lock) != 0)) {
-
-- if (rw_lock_get_waiters(lock)) {
-- fputs(" Waiters for the lock exist\n", stderr);
-+ if (rw_lock_get_s_waiters(lock)) {
-+ fputs(" s_waiters for the lock exist,", stderr);
-+ }
-+ if (rw_lock_get_x_waiters(lock)) {
-+ fputs(" x_waiters for the lock exist\n", stderr);
-+ }
-+ if (rw_lock_get_wx_waiters(lock)) {
-+ fputs(" wait_ex_waiters for the lock exist\n", stderr);
- } else {
- putc('\n', stderr);
- }
-@@ -909,14 +1133,18 @@
- lock = UT_LIST_GET_FIRST(rw_lock_list);
-
- while (lock != NULL) {
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_enter(rw_lock_get_mutex(lock));
-+#endif
-
- if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
- || (rw_lock_get_reader_count(lock) != 0)) {
- count++;
- }
-
-+#ifndef HAVE_ATOMIC_BUILTINS
- mutex_exit(rw_lock_get_mutex(lock));
-+#endif
- lock = UT_LIST_GET_NEXT(list, lock);
- }
-
-diff -ruN a/patch_info/innodb_rw_lock.info b/patch_info/innodb_rw_lock.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_rw_lock.info 2009-04-16 16:15:28.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_rw_lock.patch
-+Name=Fix of InnoDB rw_locks
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=
diff --git a/percona/5.0.87-b20-20100217/innodb_show_bp.patch b/percona/5.0.87-b20-20100217/innodb_show_bp.patch
deleted file mode 100644
index 766a3b7..0000000
--- a/percona/5.0.87-b20-20100217/innodb_show_bp.patch
+++ /dev/null
@@ -1,453 +0,0 @@
-diff -r fe944d2c6e1f innobase/btr/btr0btr.c
---- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2989,3 +2989,11 @@
-
- return(TRUE);
- }
-+
-+dulint
-+btr_page_get_index_id_noninline(
-+/*============*/
-+ page_t* page) /* in: index page */
-+{
-+ return btr_page_get_index_id(page);
-+}
-diff -r fe944d2c6e1f innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800
-@@ -2629,3 +2629,13 @@
- buf_block_print(block);
- }
-
-+buf_block_t*
-+buf_pool_get_nth_block_no_inline(
-+/*===================*/
-+ /* out: pointer to block */
-+ buf_pool_t* buf_pool,/* in: buf_pool */
-+ ulint i) /* in: index of the block */{
-+
-+return buf_pool_get_nth_block(buf_pool, i);
-+
-+}
-diff -r fe944d2c6e1f innobase/include/btr0btr.h
---- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800
-@@ -69,6 +69,12 @@
- UNIV_INLINE
- dulint
- btr_page_get_index_id(
-+/*==================*/
-+ /* out: index id */
-+ page_t* page); /* in: index page */
-+
-+dulint
-+btr_page_get_index_id_noninline(
- /*==================*/
- /* out: index id */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800
-@@ -703,6 +703,8 @@
- buf_get_free_list_len(void);
- /*=======================*/
-
-+void buf_pool_dump(void);
-+buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i);
-
-
- /* The buffer control block structure */
-diff -r fe944d2c6e1f innobase/include/page0page.h
---- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800
-@@ -260,6 +260,12 @@
- /*============*/
- /* out: number of user records */
- page_t* page); /* in: index page */
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page); /* in: index page */
- /*******************************************************************
- Returns the number of records before the given record in chain.
- The number includes infimum and supremum records. */
-@@ -519,6 +525,12 @@
- UNIV_INLINE
- ulint
- page_get_data_size(
-+/*===============*/
-+ /* out: data in bytes */
-+ page_t* page); /* in: index page */
-+
-+ulint
-+page_get_data_size_noninline(
- /*===============*/
- /* out: data in bytes */
- page_t* page); /* in: index page */
-diff -r fe944d2c6e1f innobase/page/page0page.c
---- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800
-+++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800
-@@ -1994,3 +1994,25 @@
- page_cur_move_to_next(&cur);
- }
- }
-+
-+ulint
-+page_get_n_recs_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_n_recs(page);
-+}
-+
-+
-+ulint
-+page_get_data_size_noninline(
-+/*============*/
-+ /* out: number of user records */
-+ page_t* page) /* in: index page */
-+{
-+ return page_get_data_size(page);
-+}
-+
-+
-+
-diff -r fe944d2c6e1f mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800
-@@ -42,6 +42,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-@@ -741,7 +742,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--107
-+108
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -802,6 +803,7 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INNODB_BUFFER_POOL_CONTENT TABLE_NAME select
- INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
-@@ -815,7 +817,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 22
-+information_schema 23
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1243,6 +1246,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROCESSLIST ID
-@@ -1332,6 +1336,7 @@
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
-+INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
-diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800
-@@ -11,6 +11,7 @@
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INNODB_BUFFER_POOL_CONTENT
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROCESSLIST
-diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800
-+++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800
-@@ -85,6 +85,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-@@ -112,6 +113,7 @@
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INNODB_BUFFER_POOL_CONTENT |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROCESSLIST |
-diff -r fe944d2c6e1f patch_info/innodb_show_bp.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800
-@@ -0,0 +1,6 @@
-+File=innodb_show_bp.patch
-+Name=show innodb buffer pool content
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r fe944d2c6e1f sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -128,10 +128,12 @@
- #include "../innobase/include/lock0lock.h"
- #include "../innobase/include/dict0crea.h"
- #include "../innobase/include/btr0cur.h"
-+#include "../innobase/include/buf0buf.h"
- #include "../innobase/include/btr0btr.h"
- #include "../innobase/include/fsp0fsp.h"
- #include "../innobase/include/sync0sync.h"
- #include "../innobase/include/fil0fil.h"
-+#include "../innobase/include/page0page.h"
- #include "../innobase/include/trx0xa.h"
- }
-
-@@ -6483,6 +6485,116 @@
- DBUG_RETURN(FALSE);
- }
-
-+bool
-+innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables)
-+{
-+ ulint size;
-+ ulint i;
-+ dulint id;
-+ ulint n_found;
-+ buf_frame_t* frame;
-+ dict_index_t* index;
-+ buf_block_t* block;
-+
-+ char *p;
-+ char db_name_raw[NAME_LEN*5+1];
-+ char table_name_raw[NAME_LEN*5+1];
-+
-+ DBUG_ENTER("innodb_I_S_buffer_pool_content");
-+
-+
-+ size = buf_pool->curr_size;
-+
-+ n_found = 0;
-+
-+ TABLE *table= tables->table;
-+
-+
-+ //buf_pool_dump();
-+
-+
-+ for (i = 0; i < size; i++) {
-+ block = buf_pool_get_nth_block_no_inline(buf_pool, i);
-+ frame = block->frame;
-+ if (fil_page_get_type(frame)==0) continue;
-+
-+ char page_type[64];
-+
-+ switch(fil_page_get_type(frame))
-+ {
-+ case FIL_PAGE_INDEX:
-+ strcpy(page_type, "index");
-+ break;
-+ case FIL_PAGE_UNDO_LOG:
-+ strcpy(page_type, "undo_log");
-+ break;
-+ case FIL_PAGE_INODE:
-+ strcpy(page_type, "inode");
-+ break;
-+ case FIL_PAGE_IBUF_FREE_LIST:
-+ strcpy(page_type, "ibuf_free_list");
-+ break;
-+ default:
-+ sprintf(page_type, "unknown", fil_page_get_type(frame));
-+ }
-+
-+ table->field[0]->store((longlong)i, TRUE);
-+ table->field[1]->store((longlong)block->space, TRUE);
-+ table->field[2]->store((longlong)block->offset, TRUE);
-+ table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE);
-+ table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE);
-+ table->field[5]->store((longlong)block->flush_type, TRUE);
-+ table->field[6]->store((longlong)block->buf_fix_count, TRUE);
-+ table->field[7]->store((longlong)block->LRU_position, TRUE);
-+ table->field[8]->store((longlong)fil_page_get_type(frame), TRUE);
-+
-+ table->field[9]->store(page_type, strlen(page_type), system_charset_info);
-+
-+ //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position);
-+
-+ // flush_type, buf_fix_count, LRU_position
-+
-+ if (fil_page_get_type(frame) == FIL_PAGE_INDEX) {
-+
-+ id = btr_page_get_index_id_noninline(frame);
-+ index = dict_index_get_if_in_cache(id);
-+ if (index) {
-+ table->field[10]->store(index->name, strlen(index->name), system_charset_info);
-+ // fprintf(stderr, " index %s, table %s", index->name, index->table_name);
-+
-+ if((p = strchr(index->table_name, '/')))
-+ {
-+ strncpy(db_name_raw, index->table_name, p-index->table_name);
-+ db_name_raw[p-index->table_name] = 0;
-+ table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info);
-+ p++;
-+ } else {
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ p = (char *)index->table_name;
-+ }
-+ strcpy(table_name_raw, p);
-+
-+ table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info);
-+ } else {
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ }else{
-+ table->field[10]->store(NULL, 0, system_charset_info);
-+ table->field[11]->store(NULL, 0, system_charset_info);
-+ table->field[12]->store(NULL, 0, system_charset_info);
-+ }
-+ //fprintf(stderr, "\n");
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_RETURN(1);
-+ }
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /****************************************************************************
- Implements the SHOW MUTEX STATUS command. . */
-
-diff -r fe944d2c6e1f sql/ha_innodb.h
---- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800
-@@ -263,6 +263,7 @@
-
- int innobase_drop_database(char *path);
- bool innodb_show_status(THD* thd);
-+bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
- bool innodb_mutex_show_status(THD* thd);
- void innodb_export_status(void);
-
-diff -r fe944d2c6e1f sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -2926,6 +2926,7 @@
- case SCH_COLUMN_PRIVILEGES:
- case SCH_TABLE_CONSTRAINTS:
- case SCH_KEY_COLUMN_USAGE:
-+ case SCH_INNODB_I_S_BUFFER_POOL_CONTENT:
- default:
- break;
- }
-diff -r fe944d2c6e1f sql/sql_show.cc
---- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800
-@@ -27,6 +27,10 @@
-
- #ifdef HAVE_BERKELEY_DB
- #include "ha_berkeley.h" // For berkeley_show_logs
-+#endif
-+
-+#ifdef HAVE_INNOBASE_DB
-+#include "ha_innodb.h"
- #endif
-
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-@@ -4042,6 +4046,19 @@
- DBUG_RETURN(res);
- }
-
-+int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond)
-+{
-+ DBUG_ENTER("fill_innodb_bp_content");
-+ int res= 0;
-+
-+ /* deny access to non-superusers */
-+ if (check_global_access(thd, PROCESS_ACL)) {
-+ DBUG_RETURN(0);
-+ }
-+
-+ innodb_I_S_buffer_pool_content(thd, tables);
-+ DBUG_RETURN(res);
-+}
-
- /*
- Find schema_tables elment by name
-@@ -4951,6 +4962,24 @@
- };
-
-
-+ST_FIELD_INFO innodb_bp_content_fields_info[]=
-+{
-+ {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"},
-+ {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"},
-+ {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"},
-+ {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"},
-+ {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"},
-+ {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"},
-+ {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"},
-+ {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"},
-+ {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"},
-+ {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4969,6 +4998,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table,
-+ fill_innodb_bp_content, 0, 0, -1, -1, 0},
- {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
- fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-diff -r fe944d2c6e1f sql/table.h
---- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800
-+++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800
-@@ -375,6 +375,7 @@
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INNODB_I_S_BUFFER_POOL_CONTENT,
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
diff --git a/percona/5.0.87-b20-20100217/innodb_show_hashed_memory.patch b/percona/5.0.87-b20-20100217/innodb_show_hashed_memory.patch
deleted file mode 100644
index 191193e..0000000
--- a/percona/5.0.87-b20-20100217/innodb_show_hashed_memory.patch
+++ /dev/null
@@ -1,275 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,91 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ io_counter_subtotal = ((buf_pool->io_counter_heap)
-+ ? mem_heap_get_size(buf_pool->io_counter_heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n"
-+ " innodb_io_pattern %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes(),
-+
-+ (ulong) (((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + io_counter_subtotal),
-+ (ulong) ((buf_pool->io_counter_hash) /* needs &(buf_pool->mutex) ? */
-+ ? (buf_pool->io_counter_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) io_counter_subtotal);
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20100217/innodb_show_hashed_memory_standalone.patch b/percona/5.0.87-b20-20100217/innodb_show_hashed_memory_standalone.patch
deleted file mode 100644
index bf8f6b4..0000000
--- a/percona/5.0.87-b20-20100217/innodb_show_hashed_memory_standalone.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-diff -ruN mysql-5.0.67_highperf/innobase/buf/buf0buf.c mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c
---- mysql-5.0.67_highperf/innobase/buf/buf0buf.c 2008-11-12 09:25:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/buf/buf0buf.c 2008-11-12 09:27:52.000000000 +0900
-@@ -2454,13 +2454,15 @@
- (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped));
- }
- fprintf(file,
-- "Buffer pool size %lu\n"
-- "Free buffers %lu\n"
-- "Database pages %lu\n"
-- "Modified db pages %lu\n"
-+ "Buffer pool size %lu\n"
-+ "Buffer pool size, bytes %lu\n"
-+ "Free buffers %lu\n"
-+ "Database pages %lu\n"
-+ "Modified db pages %lu\n"
- "Pending reads %lu\n"
- "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
- (ulong) size,
-+ (ulong) size * UNIV_PAGE_SIZE,
- (ulong) UT_LIST_GET_LEN(buf_pool->free),
- (ulong) UT_LIST_GET_LEN(buf_pool->LRU),
- (ulong) UT_LIST_GET_LEN(buf_pool->flush_list),
-diff -ruN mysql-5.0.67_highperf/innobase/fil/fil0fil.c mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c
---- mysql-5.0.67_highperf/innobase/fil/fil0fil.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/fil/fil0fil.c 2008-11-12 09:27:52.000000000 +0900
-@@ -4472,3 +4472,30 @@
-
- return(mach_read_from_2(page + FIL_PAGE_TYPE));
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (fil_system->spaces->n_cells
-+ + fil_system->name_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+fil_system_hash_nodes(void)
-+/*=======================*/
-+{
-+ if (fil_system) {
-+ return (UT_LIST_GET_LEN(fil_system->space_list)
-+ * (sizeof(fil_space_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/innobase/include/fil0fil.h mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h
---- mysql-5.0.67_highperf/innobase/include/fil0fil.h 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/fil0fil.h 2008-11-12 09:27:52.000000000 +0900
-@@ -701,6 +701,16 @@
- written to page, the return value not defined */
- byte* page); /* in: file page */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+fil_system_hash_cells(void);
-+/*========================*/
-+
-+ulint
-+fil_system_hash_nodes(void);
-+/*========================*/
-
- typedef struct fil_space_struct fil_space_t;
-
-diff -ruN mysql-5.0.67_highperf/innobase/include/thr0loc.h mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h
---- mysql-5.0.67_highperf/innobase/include/thr0loc.h 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/include/thr0loc.h 2008-11-12 09:27:52.000000000 +0900
-@@ -77,6 +77,17 @@
- /*=============================*/
- /* out: pointer to the in_ibuf field */
-
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void);
-+/*=======================*/
-+
-+ulint
-+thr_local_hash_nodes(void);
-+/*=======================*/
-+
- #ifndef UNIV_NONINL
- #include "thr0loc.ic"
- #endif
-diff -ruN mysql-5.0.67_highperf/innobase/srv/srv0srv.c mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c
---- mysql-5.0.67_highperf/innobase/srv/srv0srv.c 2008-11-12 09:26:07.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/srv/srv0srv.c 2008-11-12 09:54:19.000000000 +0900
-@@ -1645,6 +1645,14 @@
- time_t current_time;
- ulint n_reserved;
-
-+ ulint btr_search_sys_subtotal;
-+ ulint lock_sys_subtotal;
-+ ulint recv_sys_subtotal;
-+ ulint io_counter_subtotal;
-+
-+ ulint i;
-+ trx_t* trx;
-+
- mutex_enter(&srv_innodb_monitor_mutex);
-
- current_time = time(NULL);
-@@ -1747,6 +1755,80 @@
- ut_total_allocated_memory,
- mem_pool_get_reserved(mem_comm_pool));
-
-+ /* Calcurate reserved memories */
-+ if (btr_search_sys && btr_search_sys->hash_index->heap) {
-+ btr_search_sys_subtotal = mem_heap_get_size(btr_search_sys->hash_index->heap);
-+ } else {
-+ btr_search_sys_subtotal = 0;
-+ for (i=0; i < btr_search_sys->hash_index->n_mutexes; i++) {
-+ btr_search_sys_subtotal += mem_heap_get_size(btr_search_sys->hash_index->heaps[i]);
-+ }
-+ }
-+
-+ lock_sys_subtotal = 0;
-+ if (trx_sys) {
-+ mutex_enter(&kernel_mutex);
-+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
-+ while (trx) {
-+ lock_sys_subtotal += ((trx->lock_heap) ? mem_heap_get_size(trx->lock_heap) : 0);
-+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
-+ }
-+ mutex_exit(&kernel_mutex);
-+ }
-+
-+ recv_sys_subtotal = ((recv_sys && recv_sys->addr_hash)
-+ ? mem_heap_get_size(recv_sys->heap) : 0);
-+
-+ fprintf(file,
-+ "Internal hash tables (constant factor + variable factor)\n"
-+ " Adaptive hash index %lu \t(%lu + %lu)\n"
-+ " Page hash %lu\n"
-+ " Dictionary cache %lu \t(%lu + %lu)\n"
-+ " File system %lu \t(%lu + %lu)\n"
-+ " Lock system %lu \t(%lu + %lu)\n"
-+ " Recovery system %lu \t(%lu + %lu)\n"
-+ " Threads %lu \t(%lu + %lu)\n",
-+
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0)
-+ + btr_search_sys_subtotal,
-+ (ulong) (btr_search_sys
-+ ? (btr_search_sys->hash_index->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) btr_search_sys_subtotal,
-+
-+ (ulong) (buf_pool->page_hash->n_cells * sizeof(hash_cell_t)),
-+
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)
-+ + dict_sys->size) : 0),
-+ (ulong) (dict_sys ? ((dict_sys->table_hash->n_cells
-+ + dict_sys->table_id_hash->n_cells
-+ + dict_sys->col_hash->n_cells) * sizeof(hash_cell_t)) : 0),
-+ (ulong) (dict_sys ? (dict_sys->size) : 0),
-+
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)
-+ + fil_system_hash_nodes()),
-+ (ulong) (fil_system_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) fil_system_hash_nodes(),
-+
-+ (ulong) ((lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + lock_sys_subtotal),
-+ (ulong) (lock_sys ? (lock_sys->rec_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) lock_sys_subtotal,
-+
-+ (ulong) (((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0)
-+ + recv_sys_subtotal),
-+ (ulong) ((recv_sys && recv_sys->addr_hash)
-+ ? (recv_sys->addr_hash->n_cells * sizeof(hash_cell_t)) : 0),
-+ (ulong) recv_sys_subtotal,
-+
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)
-+ + thr_local_hash_nodes()),
-+ (ulong) (thr_local_hash_cells() * sizeof(hash_cell_t)),
-+ (ulong) thr_local_hash_nodes());
-+
- if (srv_use_awe) {
- fprintf(file,
- "In addition to that %lu MB of AWE memory allocated\n",
-diff -ruN mysql-5.0.67_highperf/innobase/thr/thr0loc.c mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c
---- mysql-5.0.67_highperf/innobase/thr/thr0loc.c 2008-11-12 09:24:58.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/innobase/thr/thr0loc.c 2008-11-12 09:27:52.000000000 +0900
-@@ -32,6 +32,7 @@
-
- /* The hash table. The module is not yet initialized when it is NULL. */
- hash_table_t* thr_local_hash = NULL;
-+ulint thr_local_hash_n_nodes = 0;
-
- /* The private data for each thread should be put to
- the structure below and the accessor functions written
-@@ -223,6 +224,7 @@
- HASH_INSERT(thr_local_t, hash, thr_local_hash,
- os_thread_pf(os_thread_get_curr_id()),
- local);
-+ thr_local_hash_n_nodes++;
-
- mutex_exit(&thr_local_mutex);
- }
-@@ -251,6 +253,7 @@
-
- HASH_DELETE(thr_local_t, hash, thr_local_hash,
- os_thread_pf(id), local);
-+ thr_local_hash_n_nodes--;
-
- mutex_exit(&thr_local_mutex);
-
-@@ -274,3 +277,29 @@
- mutex_create(&thr_local_mutex);
- mutex_set_level(&thr_local_mutex, SYNC_THR_LOCAL);
- }
-+
-+/*************************************************************************
-+Return local hash table informations. */
-+
-+ulint
-+thr_local_hash_cells(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash->n_cells);
-+ } else {
-+ return 0;
-+ }
-+}
-+
-+ulint
-+thr_local_hash_nodes(void)
-+/*======================*/
-+{
-+ if (thr_local_hash) {
-+ return (thr_local_hash_n_nodes
-+ * (sizeof(thr_local_t) + MEM_BLOCK_HEADER_SIZE));
-+ } else {
-+ return 0;
-+ }
-+}
-diff -ruN mysql-5.0.67_highperf/patch_info/innodb_show_hashed_memory.info mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ mysql-5.0.67_highperf_tmp/patch_info/innodb_show_hashed_memory.info 2008-11-12 09:27:52.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_show_hashed_memory.patch
-+Name=Adds additional information of InnoDB internal hash table memories in SHOW INNODB STATUS
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
diff --git a/percona/5.0.87-b20-20100217/innodb_split_buf_pool_mutex.patch b/percona/5.0.87-b20-20100217/innodb_split_buf_pool_mutex.patch
deleted file mode 100644
index 11a39c5..0000000
--- a/percona/5.0.87-b20-20100217/innodb_split_buf_pool_mutex.patch
+++ /dev/null
@@ -1,1895 +0,0 @@
-diff -ruN a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
---- a/innobase/btr/btr0sea.c 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/btr/btr0sea.c 2009-08-28 11:06:20.000000000 +0900
-@@ -1101,7 +1101,7 @@
- ulint* offsets;
-
- rw_lock_x_lock(&btr_search_latch);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- table = btr_search_sys->hash_index;
-
-@@ -1186,7 +1186,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- rw_lock_x_unlock(&btr_search_latch);
-
- if (UNIV_LIKELY_NULL(heap)) {
-diff -ruN a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/buf/buf0buf.c 2009-08-28 11:06:30.000000000 +0900
-@@ -549,6 +549,17 @@
- mutex_create(&(buf_pool->mutex));
- mutex_set_level(&(buf_pool->mutex), SYNC_BUF_POOL);
-
-+ mutex_create(&(buf_pool->LRU_mutex));
-+ mutex_set_level(&(buf_pool->LRU_mutex), SYNC_BUF_LRU_LIST);
-+ rw_lock_create(&(buf_pool->hash_latch));
-+ rw_lock_set_level(&(buf_pool->hash_latch), SYNC_BUF_PAGE_HASH);
-+ mutex_create(&(buf_pool->free_mutex));
-+ mutex_set_level(&(buf_pool->free_mutex), SYNC_BUF_FREE_LIST);
-+ mutex_create(&(buf_pool->flush_list_mutex));
-+ mutex_set_level(&(buf_pool->flush_list_mutex), SYNC_BUF_FLUSH_LIST);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&(buf_pool->mutex));
-
- if (srv_use_awe) {
-@@ -724,6 +735,8 @@
- block->in_free_list = TRUE;
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
- mutex_exit(&(buf_pool->mutex));
-
- if (srv_use_adaptive_hash_indexes) {
-@@ -753,6 +766,7 @@
- {
- buf_block_t* bck;
-
-+ ut_error; /* don't support AWE */
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -851,7 +865,7 @@
- buf_block_t* block) /* in: block to make younger */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(!mutex_own(&(buf_pool->mutex)));
-+ ut_ad(!mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Note that we read freed_page_clock's without holding any mutex:
-@@ -860,12 +874,12 @@
- if (buf_pool->freed_page_clock >= block->freed_page_clock
- + 1 + (buf_pool->curr_size / 4)) {
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- /* There has been freeing activity in the LRU list:
- best to move to the head of the LRU list */
-
- buf_LRU_make_block_young(block);
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
- }
- }
-
-@@ -881,7 +895,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- block = buf_block_align(frame);
-
-@@ -889,7 +903,7 @@
-
- buf_LRU_make_block_young(block);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /************************************************************************
-@@ -900,7 +914,7 @@
- /*===========*/
- buf_block_t* block) /* in, own: block to be freed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- mutex_enter(&block->mutex);
-
-@@ -910,7 +924,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- }
-
- /*************************************************************************
-@@ -951,11 +965,11 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -972,7 +986,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -980,7 +994,7 @@
- block->check_index_page_at_flush = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- /************************************************************************
-@@ -999,7 +1013,7 @@
- buf_block_t* block;
- ibool is_hashed;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1009,7 +1023,7 @@
- is_hashed = block->is_hashed;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(is_hashed);
- }
-@@ -1051,7 +1065,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1059,7 +1073,7 @@
- block->file_page_was_freed = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1080,7 +1094,7 @@
- {
- buf_block_t* block;
-
-- mutex_enter_fast(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1088,7 +1102,7 @@
- block->file_page_was_freed = FALSE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(block);
- }
-@@ -1167,26 +1181,33 @@
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-- mutex_enter_fast(&(buf_pool->mutex));
-+ //mutex_enter_fast(&(buf_pool->mutex));
-
- if (guess) {
- block = buf_block_align(guess);
-
-+ mutex_enter(&block->mutex);
- if ((offset != block->offset) || (space != block->space)
- || (block->state != BUF_BLOCK_FILE_PAGE)) {
-
-+ mutex_exit(&block->mutex);
- block = NULL;
- }
- }
-
- if (block == NULL) {
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-+ if(block) {
-+ mutex_enter(&block->mutex);
-+ }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- }
-
- if (block == NULL) {
- /* Page not in buf_pool: needs to be read from file */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (mode == BUF_GET_IF_IN_POOL) {
-
-@@ -1205,7 +1226,7 @@
- goto loop;
- }
-
-- mutex_enter(&block->mutex);
-+ //mutex_enter(&block->mutex);
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-@@ -1217,7 +1238,7 @@
-
- if (mode == BUF_GET_IF_IN_POOL) {
- /* The page is only being read to buffer */
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
- mutex_exit(&block->mutex);
-
- return(NULL);
-@@ -1242,7 +1263,7 @@
- #else
- buf_block_buf_fix_inc(block);
- #endif
-- mutex_exit(&buf_pool->mutex);
-+ //mutex_exit(&buf_pool->mutex);
-
- /* Check if this is the first access to the page */
-
-@@ -1685,7 +1706,7 @@
- buf_block_t* block) /* in: block to init */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
-@@ -1792,7 +1813,8 @@
-
- ut_a(block);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
- mutex_enter(&block->mutex);
-
- if (fil_tablespace_deleted_or_being_deleted_in_mem(space,
-@@ -1807,7 +1829,8 @@
- being deleted, or the page is already in buf_pool, return */
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(block);
-
-@@ -1822,10 +1845,14 @@
- ut_ad(block);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list, to the old blocks */
-
- buf_LRU_add_block(block, TRUE); /* TRUE == to old blocks */
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+
-+ mutex_enter(&(buf_pool->mutex)); /* for consistency about aio */
-
- block->io_fix = BUF_IO_READ;
-
-@@ -1874,7 +1901,8 @@
-
- free_block = buf_LRU_get_free_block();
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
-@@ -1885,7 +1913,8 @@
- block->file_page_was_freed = FALSE;
-
- /* Page can be found in buf_pool */
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- buf_block_free(free_block);
-
-@@ -1908,6 +1937,7 @@
- mutex_enter(&block->mutex);
-
- buf_page_init(space, offset, block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* The block must be put to the LRU list */
- buf_LRU_add_block(block, FALSE);
-@@ -1919,7 +1949,7 @@
- #endif
- buf_pool->n_pages_created++;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
-
-@@ -1933,7 +1963,7 @@
- ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- frame = block->frame;
-
-@@ -1969,6 +1999,7 @@
- {
- ulint io_type;
- ulint read_page_no;
-+ ulint flush_type;
-
- buf_io_counter_t* io_counter;
- ulint fold;
-@@ -2051,9 +2082,6 @@
- }
- }
-
-- mutex_enter(&(buf_pool->mutex));
-- mutex_enter(&block->mutex);
--
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-@@ -2062,9 +2090,12 @@
- removes the newest lock debug record, without checking the thread
- id. */
-
-- block->io_fix = 0;
--
- if (io_type == BUF_IO_READ) {
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* NOTE that the call to ibuf may have moved the ownership of
- the x-latch to this OS thread: do not let this confuse you in
- debugging! */
-@@ -2095,6 +2126,8 @@
- }
- }
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has read ", stderr);
-@@ -2103,11 +2136,24 @@
- } else {
- ut_ad(io_type == BUF_IO_WRITE);
-
-+ flush_type = block->flush_type;
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-+ mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+
-+ block->io_fix = 0;
-+
- /* Write means a flush operation: call the completion
- routine in the flush system */
-
- buf_flush_write_complete(block);
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
- rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE);
- /* io_counter here */
- if (srv_io_pattern && srv_io_pattern_trace_running) {
-@@ -2132,6 +2178,9 @@
-
- buf_pool->n_pages_written++;
-
-+ mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-+
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fputs("Has written ", stderr);
-@@ -2139,9 +2188,6 @@
- #endif /* UNIV_DEBUG */
- }
-
-- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
--
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
- fprintf(stderr, "page space %lu page no %lu\n",
-@@ -2169,11 +2215,11 @@
- freed = buf_LRU_search_and_free_block(100);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-
- /*************************************************************************
-@@ -2195,7 +2241,10 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ /* for keep the new latch order, it cannot validate correctly... */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2256,18 +2305,26 @@
- }
-
- ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
-+ /* because of latching order with block->mutex, we cannot get free_mutex before that */
-+/*
- if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
- fprintf(stderr, "Free list len %lu, free blocks %lu\n",
- (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free);
- ut_error;
- }
-+*/
-+ /* because of latching order with block->mutex, we cannot get flush_list_mutex before that */
-+/*
- ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
-
- ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
- ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
-+*/
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- ut_a(buf_LRU_validate());
- ut_a(buf_flush_validate());
-@@ -2299,7 +2356,9 @@
- index_ids = mem_alloc(sizeof(dulint) * size);
- counts = mem_alloc(sizeof(ulint) * size);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- fprintf(stderr,
- "buf_pool size %lu\n"
-@@ -2352,7 +2411,9 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- for (i = 0; i < n_found; i++) {
- index = dict_index_get_if_in_cache(index_ids[i]);
-@@ -2387,7 +2448,7 @@
- ulint i;
- ulint fixed_pages_number = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex));
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2404,7 +2465,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
- return fixed_pages_number;
- }
- #endif /* UNIV_DEBUG */
-@@ -2432,7 +2493,7 @@
- {
- ulint ratio;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list))
- / (1 + UT_LIST_GET_LEN(buf_pool->LRU)
-@@ -2440,7 +2501,7 @@
-
- /* 1 + is there to avoid division by zero */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(ratio);
- }
-@@ -2460,7 +2521,10 @@
- ut_ad(buf_pool);
- size = buf_pool->curr_size;
-
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- if (srv_use_awe) {
- fprintf(stderr,
-@@ -2533,7 +2597,10 @@
- buf_pool->n_pages_written_old = buf_pool->n_pages_written;
- buf_pool->n_pages_awe_remapped_old = buf_pool->n_pages_awe_remapped;
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- }
-
- /**************************************************************************
-@@ -2563,7 +2630,7 @@
-
- ut_ad(buf_pool);
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- for (i = 0; i < buf_pool->curr_size; i++) {
-
-@@ -2586,7 +2653,7 @@
- mutex_exit(&block->mutex);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- return(TRUE);
- }
-@@ -2626,11 +2693,11 @@
- {
- ulint len;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->free);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(len);
- }
-diff -ruN a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
---- a/innobase/buf/buf0flu.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/buf/buf0flu.c 2009-08-28 11:06:30.000000000 +0900
-@@ -49,7 +49,9 @@
- buf_block_t* block) /* in: block which is modified */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -79,7 +81,9 @@
- buf_block_t* b;
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&block->mutex));
-+ ut_ad(mutex_own(&(buf_pool->flush_list_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- prev_b = NULL;
-@@ -130,16 +134,18 @@
- BUF_BLOCK_FILE_PAGE and in the LRU list */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
-- if (block->state != BUF_BLOCK_FILE_PAGE) {
-+ if (!block->in_LRU_list || block->state != BUF_BLOCK_FILE_PAGE) {
-+ /* permited not to own LRU_mutex.. */
-+/*
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: buffer block state %lu in the LRU list!\n",
- (ulong)block->state);
- ut_print_buf(stderr, (byte*)block, sizeof(buf_block_t));
--
-+*/
- return(FALSE);
- }
-
-@@ -165,12 +171,13 @@
- ulint flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&(block->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-+ //ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
-+ if (block->state == BUF_BLOCK_FILE_PAGE
-+ && (ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0)
- && (block->io_fix == 0)) {
- if (flush_type != BUF_FLUSH_LRU) {
-
-@@ -199,15 +206,17 @@
- {
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block->oldest_modification = ut_dulint_zero;
-
- UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
-
- ut_d(UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- (buf_pool->n_flush[block->flush_type])--;
-
-@@ -553,18 +562,20 @@
- ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST
- || flush_type == BUF_FLUSH_SINGLE_PAGE);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- block = buf_page_hash_get(space, offset);
-
- ut_a(!block || block->state == BUF_BLOCK_FILE_PAGE);
-
- if (!block) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
- return(0);
- }
-
- mutex_enter(&block->mutex);
-+ mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (flush_type == BUF_FLUSH_LIST
- && buf_flush_ready_for_flush(block, flush_type)) {
-@@ -761,7 +772,7 @@
- high = fil_space_get_size(space);
- }
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- for (i = low; i < high; i++) {
-
-@@ -795,7 +806,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- /* Note: as we release the buf_pool mutex
- above, in buf_flush_try_page we cannot be sure
-@@ -806,14 +817,14 @@
- count += buf_flush_try_page(space, i,
- flush_type);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- } else {
- mutex_exit(&block->mutex);
- }
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(count);
- }
-@@ -848,6 +859,7 @@
- ulint space;
- ulint offset;
- ibool found;
-+ ulint remaining = 0;
-
- ut_ad((flush_type == BUF_FLUSH_LRU)
- || (flush_type == BUF_FLUSH_LIST));
-@@ -866,6 +878,12 @@
- }
-
- (buf_pool->init_flush)[flush_type] = TRUE;
-+
-+ mutex_exit(&(buf_pool->mutex));
-+
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- for (;;) {
- /* If we have flushed enough, leave the loop */
-@@ -882,7 +900,10 @@
- } else {
- ut_ad(flush_type == BUF_FLUSH_LIST);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-+ remaining = UT_LIST_GET_LEN(buf_pool->flush_list);
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- if (!block
- || (ut_dulint_cmp(block->oldest_modification,
- lsn_limit) >= 0)) {
-@@ -912,7 +933,9 @@
- offset = block->offset;
-
- mutex_exit(&block->mutex);
-- mutex_exit(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-
- old_page_count = page_count;
-
-@@ -932,7 +955,9 @@
- flush_type, offset,
- page_count - old_page_count); */
-
-- mutex_enter(&(buf_pool->mutex));
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ }
-
- } else if (flush_type == BUF_FLUSH_LRU) {
-
-@@ -944,17 +969,26 @@
-
- mutex_exit(&block->mutex);
-
-+ mutex_enter(&(buf_pool->flush_list_mutex));
- block = UT_LIST_GET_PREV(flush_list, block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ remaining--;
- }
- }
-
- /* If we could not find anything to flush, leave the loop */
-
-- if (!found) {
-+ if (!found && !remaining) {
- break;
- }
- }
-
-+ if (flush_type == BUF_FLUSH_LRU) {
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ }
-+
-+ mutex_enter(&(buf_pool->mutex));
-+
- (buf_pool->init_flush)[flush_type] = FALSE;
-
- if ((buf_pool->n_flush[flush_type] == 0)
-@@ -1014,7 +1048,7 @@
- ulint n_replaceable;
- ulint distance = 0;
-
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
-
-@@ -1025,6 +1059,12 @@
- + BUF_FLUSH_EXTRA_MARGIN)
- && (distance < BUF_LRU_FREE_SEARCH_LEN)) {
-
-+ if (!block->in_LRU_list) {
-+ /* reatart. but it is very optimistic */
-+ block = UT_LIST_GET_LAST(buf_pool->LRU);
-+ continue;
-+ }
-+
- mutex_enter(&block->mutex);
-
- if (buf_flush_ready_for_replace(block)) {
-@@ -1038,7 +1078,7 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex)); /* optimistic */
-
- if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
-
-@@ -1057,8 +1097,9 @@
- immediately, without waiting. */
-
- void
--buf_flush_free_margin(void)
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait)
- {
- ulint n_to_flush;
- ulint n_flushed;
-@@ -1068,7 +1109,7 @@
- if (n_to_flush > 0) {
- n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush,
- ut_dulint_zero);
-- if (n_flushed == ULINT_UNDEFINED) {
-+ if (wait && n_flushed == ULINT_UNDEFINED) {
- /* There was an LRU type flush batch already running;
- let us wait for it to end */
-
-@@ -1118,11 +1159,11 @@
- {
- ibool ret;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- ret = buf_flush_validate_low();
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(ret);
- }
-diff -ruN a/innobase/buf/buf0lru.c b/innobase/buf/buf0lru.c
---- a/innobase/buf/buf0lru.c 2009-07-07 21:53:57.000000000 +0900
-+++ b/innobase/buf/buf0lru.c 2009-08-28 11:06:30.000000000 +0900
-@@ -108,7 +108,7 @@
-
- page_arr = ut_malloc(sizeof(ulint)
- * BUF_LRU_DROP_SEARCH_HASH_SIZE);
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
-
- scan_again:
- num_entries = 0;
-@@ -147,12 +147,12 @@
- }
- /* Array full. We release the buf_pool->mutex to
- obey the latching order. */
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- buf_LRU_drop_page_hash_batch(id, page_arr,
- num_entries);
- num_entries = 0;
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&buf_pool->LRU_mutex);
- } else {
- mutex_exit(&block->mutex);
- }
-@@ -177,7 +177,7 @@
- }
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&buf_pool->LRU_mutex);
-
- /* Drop any remaining batch of search hashed pages. */
- buf_LRU_drop_page_hash_batch(id, page_arr, num_entries);
-@@ -206,7 +206,8 @@
- buf_LRU_drop_page_hash_for_tablespace(id);
-
- scan_again:
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-
- all_freed = TRUE;
-
-@@ -244,7 +245,8 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- /* Note that the following call will acquire
- an S-latch on the page */
-@@ -274,7 +276,8 @@
- block = UT_LIST_GET_PREV(LRU, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
- if (!all_freed) {
- os_thread_sleep(20000);
-@@ -297,14 +300,14 @@
- ulint len;
- ulint limit;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- len = UT_LIST_GET_LEN(buf_pool->LRU);
-
- if (len < BUF_LRU_OLD_MIN_LEN) {
- /* The LRU list is too short to do read-ahead */
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(0);
- }
-@@ -313,7 +316,7 @@
-
- limit = block->LRU_position - len / BUF_LRU_INITIAL_RATIO;
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-
- return(limit);
- }
-@@ -337,13 +340,15 @@
- ulint distance = 0;
- ibool freed;
-
-- mutex_enter(&(buf_pool->mutex));
-+ /* optimistic search... */
-+ //mutex_enter(&(buf_pool->mutex));
-
-+retry:
- freed = FALSE;
- block = UT_LIST_GET_LAST(buf_pool->LRU);
-
- while (block != NULL) {
-- ut_a(block->in_LRU_list);
-+ //ut_a(block->in_LRU_list); /* optimistic */
-
- mutex_enter(&block->mutex);
-
-@@ -358,9 +363,17 @@
- }
- #endif /* UNIV_DEBUG */
-
-+ mutex_exit(&block->mutex);
-+
-+ mutex_enter(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_lock(&(buf_pool->hash_latch));
-+ mutex_enter(&block->mutex);
-+ if(block->in_LRU_list && buf_flush_ready_for_replace(block)) {
- buf_LRU_block_remove_hashed_page(block);
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- mutex_exit(&block->mutex);
-
- /* Remove possible adaptive hash index built on the
-@@ -373,7 +386,6 @@
-
- ut_a(block->buf_fix_count == 0);
-
-- mutex_enter(&(buf_pool->mutex));
- mutex_enter(&block->mutex);
-
- buf_LRU_block_free_hashed_page(block);
-@@ -381,6 +393,16 @@
- mutex_exit(&block->mutex);
-
- break;
-+ } else { /* someone may interrupt...??? */
-+ mutex_exit(&(buf_pool->LRU_mutex));/* optimistic */
-+
-+ rw_lock_x_unlock(&(buf_pool->hash_latch));
-+
-+ if (!(block->in_LRU_list)) {
-+ mutex_exit(&block->mutex);
-+ goto retry;
-+ }
-+ }
- }
-
- mutex_exit(&block->mutex);
-@@ -391,6 +413,7 @@
- if (!freed && n_iterations <= 10
- && distance > 100 + (n_iterations * buf_pool->curr_size)
- / 10) {
-+ mutex_enter(&(buf_pool->mutex));
- buf_pool->LRU_flush_ended = 0;
-
- mutex_exit(&(buf_pool->mutex));
-@@ -398,6 +421,8 @@
- return(FALSE);
- }
- }
-+
-+ mutex_enter(&(buf_pool->mutex));
- if (buf_pool->LRU_flush_ended > 0) {
- buf_pool->LRU_flush_ended--;
- }
-@@ -449,7 +474,8 @@
- {
- ibool ret = FALSE;
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
-@@ -457,7 +483,8 @@
- ret = TRUE;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
-
- return(ret);
- }
-@@ -480,7 +507,7 @@
- ibool mon_value_was = FALSE;
- ibool started_monitor = FALSE;
- loop:
-- mutex_enter(&(buf_pool->mutex));
-+ //mutex_enter(&(buf_pool->mutex)); /* optimistic */
-
- if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
- + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
-@@ -536,10 +563,16 @@
- /* If there is a block in the free list, take it */
- if (UT_LIST_GET_LEN(buf_pool->free) > 0) {
-
-- block = UT_LIST_GET_FIRST(buf_pool->free);
-+ mutex_enter(&(buf_pool->free_mutex));
-+ block = UT_LIST_GET_LAST(buf_pool->free);
-+ if (!block) {
-+ mutex_exit(&(buf_pool->free_mutex));
-+ goto no_block;
-+ }
- ut_a(block->in_free_list);
- UT_LIST_REMOVE(free, buf_pool->free, block);
- block->in_free_list = FALSE;
-+ mutex_exit(&(buf_pool->free_mutex));
- ut_a(block->state != BUF_BLOCK_FILE_PAGE);
- ut_a(!block->in_LRU_list);
-
-@@ -564,7 +597,7 @@
-
- mutex_exit(&block->mutex);
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- if (started_monitor) {
- srv_print_innodb_monitor = mon_value_was;
-@@ -572,11 +605,12 @@
-
- return(block);
- }
-+no_block:
-
- /* If no block was in the free list, search from the end of the LRU
- list and try to free a block there */
-
-- mutex_exit(&(buf_pool->mutex));
-+ //mutex_exit(&(buf_pool->mutex));
-
- freed = buf_LRU_search_and_free_block(n_iterations);
-
-@@ -613,7 +647,7 @@
-
- /* No free block was found: try to flush the LRU list */
-
-- buf_flush_free_margin();
-+ buf_flush_free_margin(TRUE);
- ++srv_buf_pool_wait_free;
-
- os_aio_simulated_wake_handler_threads();
-@@ -655,7 +689,7 @@
-
- ut_a(buf_pool->LRU_old);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5);
-
-@@ -730,7 +764,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -796,7 +830,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -861,7 +895,7 @@
- ut_ad(buf_pool);
- ut_ad(block);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-@@ -964,7 +998,7 @@
- buf_block_t* block) /* in: block, must not contain a file page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -981,8 +1015,10 @@
- /* Wipe contents of page to reveal possible stale pointers to it */
- memset(block->frame, '\0', UNIV_PAGE_SIZE);
- #endif
-+ mutex_enter(&(buf_pool->free_mutex));
- UT_LIST_ADD_FIRST(free, buf_pool->free, block);
- block->in_free_list = TRUE;
-+ mutex_exit(&(buf_pool->free_mutex));
-
- if (srv_use_awe && block->frame) {
- /* Add to the list of mapped pages */
-@@ -1004,7 +1040,7 @@
- may or may not be a hash index to the page */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_ad(block);
-@@ -1062,7 +1098,7 @@
- be in a state where it can be freed */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- ut_ad(mutex_own(&block->mutex));
- #endif /* UNIV_SYNC_DEBUG */
- ut_a(block->state == BUF_BLOCK_REMOVE_HASH);
-@@ -1085,7 +1121,7 @@
- ulint LRU_pos;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) {
-
-@@ -1130,6 +1166,9 @@
- ut_a(buf_pool->LRU_old_len == old_len);
- }
-
-+ mutex_exit(&(buf_pool->LRU_mutex));
-+ mutex_enter(&(buf_pool->free_mutex));
-+
- UT_LIST_VALIDATE(free, buf_block_t, buf_pool->free);
-
- block = UT_LIST_GET_FIRST(buf_pool->free);
-@@ -1140,7 +1179,7 @@
- block = UT_LIST_GET_NEXT(free, block);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->free_mutex));
- return(TRUE);
- }
-
-@@ -1156,7 +1195,7 @@
- ulint len;
-
- ut_ad(buf_pool);
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&(buf_pool->LRU_mutex));
-
- fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock);
-
-@@ -1200,5 +1239,5 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->LRU_mutex));
- }
-diff -ruN a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/buf/buf0rea.c 2009-08-28 11:06:30.000000000 +0900
-@@ -277,10 +277,12 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Count how many blocks in the area have been recently accessed,
- that is, reside near the start of the LRU list. */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -292,7 +294,7 @@
- }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) {
- /* Do nothing */
-@@ -388,7 +390,7 @@
- }
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- return(count + count2);
- }
-@@ -491,6 +493,7 @@
-
- return(0);
- }
-+ mutex_exit(&(buf_pool->mutex));
-
- /* Check that almost all pages in the area have been accessed; if
- offset == low, the accesses must be in a descending order, otherwise,
-@@ -504,6 +507,7 @@
-
- fail_count = 0;
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- for (i = low; i < high; i++) {
- block = buf_page_hash_get(space, i);
-
-@@ -520,23 +524,23 @@
- pred_block = block;
- }
- }
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if (fail_count > BUF_READ_AHEAD_LINEAR_AREA -
- BUF_READ_AHEAD_LINEAR_THRESHOLD) {
- /* Too many failures: return */
-
-- mutex_exit(&(buf_pool->mutex));
--
- return(0);
- }
-
- /* If we got this far, we know that enough pages in the area have
- been accessed in the right order: linear read-ahead can be sensible */
-
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
- block = buf_page_hash_get(space, offset);
-
- if (block == NULL) {
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- return(0);
- }
-@@ -552,7 +556,7 @@
- pred_offset = fil_page_get_prev(frame);
- succ_offset = fil_page_get_next(frame);
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- if ((offset == low) && (succ_offset == offset + 1)) {
-
-@@ -628,7 +632,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints && (count > 0)) {
-@@ -696,7 +700,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-@@ -768,7 +772,7 @@
- os_aio_simulated_wake_handler_threads();
-
- /* Flush pages from the end of the LRU list if necessary */
-- buf_flush_free_margin();
-+ buf_flush_free_margin(FALSE);
-
- #ifdef UNIV_DEBUG
- if (buf_debug_prints) {
-diff -ruN a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
---- a/innobase/include/buf0buf.h 2009-08-28 11:08:16.000000000 +0900
-+++ b/innobase/include/buf0buf.h 2009-08-28 11:06:30.000000000 +0900
-@@ -946,6 +946,7 @@
- mem_heap_t* io_counter_heap;
- ulint io_counters;
- hash_table_t* page_hash; /* hash table of the file pages */
-+ rw_lock_t hash_latch;
-
- ulint n_pend_reads; /* number of pending read operations */
-
-@@ -978,6 +979,7 @@
- UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
- /* base node of the modified block
- list */
-+ mutex_t flush_list_mutex;
- ibool init_flush[BUF_FLUSH_LIST + 1];
- /* this is TRUE when a flush of the
- given type is being initialized */
-@@ -1011,8 +1013,10 @@
- in the case of AWE, at the start are
- always free blocks for which the
- physical memory is mapped to a frame */
-+ mutex_t free_mutex;
- UT_LIST_BASE_NODE_T(buf_block_t) LRU;
- /* base node of the LRU list */
-+ mutex_t LRU_mutex;
- buf_block_t* LRU_old; /* pointer to the about 3/8 oldest
- blocks in the LRU list; NULL if LRU
- length less than BUF_LRU_OLD_MIN_LEN */
-diff -ruN a/innobase/include/buf0buf.ic b/innobase/include/buf0buf.ic
---- a/innobase/include/buf0buf.ic 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0buf.ic 2009-08-28 11:06:30.000000000 +0900
-@@ -112,7 +112,8 @@
- buf_block_t* block;
- dulint lsn;
-
-- mutex_enter(&(buf_pool->mutex));
-+try_again:
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block = UT_LIST_GET_LAST(buf_pool->flush_list);
-
-@@ -120,9 +121,13 @@
- lsn = ut_dulint_zero;
- } else {
- lsn = block->oldest_modification;
-+ if (ut_dulint_cmp(lsn, ut_dulint_zero) == 0) {
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-+ goto try_again;
-+ }
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- return(lsn);
- }
-@@ -137,7 +142,7 @@
- /* out: new clock value */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(mutex_own(&(buf_pool->LRU_mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- buf_pool->ulint_clock++;
-@@ -392,18 +397,18 @@
- /* out: TRUE if io going on */
- buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
- {
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
-
- if (block->io_fix != 0) {
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(TRUE);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(FALSE);
- }
-@@ -425,7 +430,7 @@
-
- block = buf_block_align(frame);
-
-- mutex_enter(&(buf_pool->mutex));
-+ mutex_enter(&block->mutex);
-
- if (block->state == BUF_BLOCK_FILE_PAGE) {
- lsn = block->newest_modification;
-@@ -433,7 +438,7 @@
- lsn = ut_dulint_zero;
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&block->mutex);
-
- return(lsn);
- }
-@@ -456,7 +461,7 @@
- block = buf_block_align(frame);
-
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /*UNIV_SYNC_DEBUG */
-
-@@ -477,7 +482,7 @@
- buf_block_t* block) /* in: block */
- {
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad((mutex_own(&(buf_pool->mutex)) && (block->buf_fix_count == 0))
-+ ut_ad((mutex_own(&(buf_pool->LRU_mutex)) && (block->buf_fix_count == 0))
- || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
- #endif /* UNIV_SYNC_DEBUG */
-
-@@ -555,7 +560,8 @@
-
- ut_ad(buf_pool);
- #ifdef UNIV_SYNC_DEBUG
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ ut_ad(rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_EX)
-+ || rw_lock_own(&(buf_pool->hash_latch), RW_LOCK_SHARED));
- #endif /* UNIV_SYNC_DEBUG */
-
- /* Look for the page in the hash table */
-@@ -631,11 +637,14 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-+ /* buf_flush_note_modification() should be called before this function. */
-+/*
- if (rw_latch == RW_X_LATCH && mtr->modifications) {
- mutex_enter(&buf_pool->mutex);
- buf_flush_note_modification(block, mtr);
- mutex_exit(&buf_pool->mutex);
- }
-+*/
-
- mutex_enter(&block->mutex);
-
-diff -ruN a/innobase/include/buf0flu.h b/innobase/include/buf0flu.h
---- a/innobase/include/buf0flu.h 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0flu.h 2009-08-28 11:06:30.000000000 +0900
-@@ -26,8 +26,9 @@
- a margin of replaceable pages there. */
-
- void
--buf_flush_free_margin(void);
-+buf_flush_free_margin(
- /*=======================*/
-+ ibool wait);
- /************************************************************************
- Initializes a page for writing to the tablespace. */
-
-diff -ruN a/innobase/include/buf0flu.ic b/innobase/include/buf0flu.ic
---- a/innobase/include/buf0flu.ic 2009-07-07 21:54:00.000000000 +0900
-+++ b/innobase/include/buf0flu.ic 2009-08-28 11:06:30.000000000 +0900
-@@ -38,11 +38,14 @@
- mtr_t* mtr) /* in: mtr */
- {
- ut_ad(block);
-+
-+ mutex_enter(&block->mutex);
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
-- ut_ad(mutex_own(&(buf_pool->mutex)));
-+ //ut_ad(mutex_own(&(buf_pool->mutex)));
- #endif /* UNIV_SYNC_DEBUG */
-
- ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0);
-@@ -52,16 +55,20 @@
- block->newest_modification = mtr->end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = mtr->start_lsn;
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- mtr->start_lsn) <= 0);
- }
-
-+ mutex_exit(&block->mutex);
-+
- ++srv_buf_pool_write_requests;
- }
-
-@@ -78,29 +85,32 @@
- set of mtr's */
- {
- ut_ad(block);
-+
-+ mutex_enter(&(block->mutex));
-+
- ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
- ut_ad(block->buf_fix_count > 0);
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
- #endif /* UNIV_SYNC_DEBUG */
-
-- mutex_enter(&(buf_pool->mutex));
--
- ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0);
-
- block->newest_modification = end_lsn;
-
- if (ut_dulint_is_zero(block->oldest_modification)) {
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- block->oldest_modification = start_lsn;
-
- ut_ad(!ut_dulint_is_zero(block->oldest_modification));
-
- buf_flush_insert_sorted_into_flush_list(block);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
- } else {
- ut_ad(ut_dulint_cmp(block->oldest_modification,
- start_lsn) <= 0);
- }
-
-- mutex_exit(&(buf_pool->mutex));
-+ mutex_exit(&(block->mutex));
- }
-diff -ruN a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
---- a/innobase/include/sync0sync.h 2009-07-07 21:54:06.000000000 +0900
-+++ b/innobase/include/sync0sync.h 2009-08-28 11:06:30.000000000 +0900
-@@ -438,8 +438,12 @@
- SYNC_SEARCH_SYS, as memory allocation
- can call routines there! Otherwise
- the level is SYNC_MEM_HASH. */
-+#define SYNC_BUF_LRU_LIST 157
-+#define SYNC_BUF_PAGE_HASH 156
-+#define SYNC_BUF_BLOCK 155
-+#define SYNC_BUF_FREE_LIST 153
- #define SYNC_BUF_POOL 150
--#define SYNC_BUF_BLOCK 149
-+#define SYNC_BUF_FLUSH_LIST 149
- #define SYNC_DOUBLEWRITE 140
- #define SYNC_ANY_LATCH 135
- #define SYNC_THR_LOCAL 133
-diff -ruN a/innobase/log/log0recv.c b/innobase/log/log0recv.c
---- a/innobase/log/log0recv.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/log/log0recv.c 2009-08-28 11:06:30.000000000 +0900
-@@ -1695,11 +1695,11 @@
-
- mtr_start(&mtr);
-
-- mutex_enter(&(buf_pool->mutex));
-+ rw_lock_s_lock(&(buf_pool->hash_latch));
-
- page = buf_page_hash_get(space, page_no)->frame;
-
-- mutex_exit(&(buf_pool->mutex));
-+ rw_lock_s_unlock(&(buf_pool->hash_latch));
-
- replica = buf_page_get(space + RECV_REPLICA_SPACE_ADD, page_no,
- RW_X_LATCH, &mtr);
-diff -ruN a/innobase/mtr/mtr0mtr.c b/innobase/mtr/mtr0mtr.c
---- a/innobase/mtr/mtr0mtr.c 2009-07-07 21:54:08.000000000 +0900
-+++ b/innobase/mtr/mtr0mtr.c 2009-08-28 11:06:30.000000000 +0900
-@@ -103,6 +103,38 @@
- }
- }
-
-+UNIV_INLINE
-+void
-+mtr_memo_note_modification_all(
-+/*===========================*/
-+ mtr_t* mtr) /* in: mtr */
-+{
-+ mtr_memo_slot_t* slot;
-+ dyn_array_t* memo;
-+ ulint offset;
-+
-+ ut_ad(mtr);
-+ ut_ad(mtr->magic_n == MTR_MAGIC_N);
-+ ut_ad(mtr->state == MTR_COMMITTING); /* Currently only used in
-+ commit */
-+ ut_ad(mtr->modifications);
-+
-+ memo = &(mtr->memo);
-+
-+ offset = dyn_array_get_data_size(memo);
-+
-+ while (offset > 0) {
-+ offset -= sizeof(mtr_memo_slot_t);
-+ slot = dyn_array_get_element(memo, offset);
-+
-+ if (UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-+ }
-+}
-+
- /****************************************************************
- Writes the contents of a mini-transaction log, if any, to the database log. */
- static
-@@ -177,6 +209,8 @@
- #endif
- if (mtr->modifications) {
- mtr_log_reserve_and_write(mtr);
-+
-+ mtr_memo_note_modification_all(mtr);
- }
-
- /* We first update the modification info to buffer pages, and only
-@@ -187,12 +221,13 @@
- required when we insert modified buffer pages in to the flush list
- which must be sorted on oldest_modification. */
-
-- mtr_memo_pop_all(mtr);
--
- if (mtr->modifications) {
- log_release();
- }
-
-+ /* All unlocking has been moved here, after log_sys mutex release. */
-+ mtr_memo_pop_all(mtr);
-+
- #ifdef UNIV_DEBUG
- mtr->state = MTR_COMMITTED;
- #endif
-@@ -262,6 +297,12 @@
- slot = dyn_array_get_element(memo, offset);
-
- if ((object == slot->object) && (type == slot->type)) {
-+ if (mtr->modifications &&
-+ UNIV_LIKELY(slot->object != NULL) &&
-+ slot->type == MTR_MEMO_PAGE_X_FIX) {
-+ buf_flush_note_modification(
-+ (buf_block_t*)slot->object, mtr);
-+ }
-
- mtr_memo_slot_release(mtr, slot);
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-08-28 11:08:17.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-08-28 11:06:30.000000000 +0900
-@@ -370,6 +370,7 @@
- ulong srv_n_free_tickets_to_enter = 500;
- ulong srv_thread_sleep_delay = 10000;
- ulint srv_spin_wait_delay = 5;
-+ulint srv_spins_microsec = 50;
- ibool srv_priority_boost = TRUE;
-
- ibool srv_print_thread_releases = FALSE;
-@@ -676,6 +677,47 @@
- ulint srv_n_threads_active[SRV_MASTER + 1];
- ulint srv_n_threads[SRV_MASTER + 1];
-
-+static
-+void
-+srv_align_spins_microsec(void)
-+{
-+ ulint start_sec, end_sec;
-+ ulint start_usec, end_usec;
-+ ib_longlong usecs;
-+
-+ /* change temporary */
-+ srv_spins_microsec = 1;
-+
-+ if (ut_usectime(&start_sec, &start_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ ut_delay(100000);
-+
-+ if (ut_usectime(&end_sec, &end_usec)) {
-+ srv_spins_microsec = 50;
-+ goto end;
-+ }
-+
-+ usecs = (end_sec - start_sec) * 1000000LL + (end_usec - start_usec);
-+
-+ if (usecs) {
-+ srv_spins_microsec = 100000 / usecs;
-+ if (srv_spins_microsec == 0)
-+ srv_spins_microsec = 1;
-+ if (srv_spins_microsec > 50)
-+ srv_spins_microsec = 50;
-+ } else {
-+ srv_spins_microsec = 50;
-+ }
-+end:
-+ if (srv_spins_microsec != 50)
-+ fprintf(stderr,
-+ "InnoDB: unit of spin count at ut_delay() is aligned to %lu\n",
-+ srv_spins_microsec);
-+}
-+
- /*************************************************************************
- Sets the info describing an i/o thread current state. */
-
-@@ -909,6 +951,8 @@
- dict_table_t* table;
- ulint i;
-
-+ srv_align_spins_microsec();
-+
- srv_sys = mem_alloc(sizeof(srv_sys_t));
-
- kernel_mutex_temp = mem_alloc(sizeof(mutex_t));
-@@ -2665,7 +2709,7 @@
- ib_longlong level, bpl;
- buf_block_t* bpage;
-
-- mutex_enter(&buf_pool->mutex);
-+ mutex_enter(&(buf_pool->flush_list_mutex));
-
- level = 0;
- bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
-@@ -2687,7 +2731,7 @@
- bpl = 0;
- }
-
-- mutex_exit(&buf_pool->mutex);
-+ mutex_exit(&(buf_pool->flush_list_mutex));
-
- if (!srv_use_doublewrite_buf) {
- /* flush is faster than when doublewrite */
-diff -ruN a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
---- a/innobase/sync/sync0sync.c 2009-07-07 21:54:10.000000000 +0900
-+++ b/innobase/sync/sync0sync.c 2009-08-28 11:06:30.000000000 +0900
-@@ -1105,11 +1105,19 @@
- } else if (level == SYNC_DOUBLEWRITE) {
- ut_a(sync_thread_levels_g(array, SYNC_DOUBLEWRITE));
- } else if (level == SYNC_BUF_BLOCK) {
-- ut_a((sync_thread_levels_contain(array, SYNC_BUF_POOL)
-+ ut_a((sync_thread_levels_contain(array, SYNC_BUF_LRU_LIST)
- && sync_thread_levels_g(array, SYNC_BUF_BLOCK - 1))
- || sync_thread_levels_g(array, SYNC_BUF_BLOCK));
- } else if (level == SYNC_BUF_POOL) {
- ut_a(sync_thread_levels_g(array, SYNC_BUF_POOL));
-+ } else if (level == SYNC_BUF_FLUSH_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FLUSH_LIST));
-+ } else if (level == SYNC_BUF_FREE_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_FREE_LIST));
-+ } else if (level == SYNC_BUF_PAGE_HASH) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_PAGE_HASH));
-+ } else if (level == SYNC_BUF_LRU_LIST) {
-+ ut_a(sync_thread_levels_g(array, SYNC_BUF_LRU_LIST));
- } else if (level == SYNC_SEARCH_SYS) {
- ut_a(sync_thread_levels_g(array, SYNC_SEARCH_SYS));
- } else if (level == SYNC_TRX_LOCK_HEAP) {
-diff -ruN a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c
---- a/innobase/ut/ut0ut.c 2009-07-07 21:54:12.000000000 +0900
-+++ b/innobase/ut/ut0ut.c 2009-08-28 11:06:30.000000000 +0900
-@@ -347,6 +347,7 @@
- /*****************************************************************
- Runs an idle loop on CPU. The argument gives the desired delay
- in microseconds on 100 MHz Pentium + Visual C++. */
-+extern ulint srv_spins_microsec;
-
- ulint
- ut_delay(
-@@ -358,7 +359,11 @@
-
- j = 0;
-
-- for (i = 0; i < delay * 50; i++) {
-+ for (i = 0; i < delay * srv_spins_microsec; i++) {
-+#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__)
-+ /* it is equal to the instruction 'pause' */
-+ __asm__ __volatile__ ("rep; nop");
-+#endif
- j += i;
- }
-
-diff -ruN a/patch_info/innodb_split_buf_pool_mutex.info b/patch_info/innodb_split_buf_pool_mutex.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_split_buf_pool_mutex.info 2009-08-28 11:06:30.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_split_buf_pool_mutex.patch
-+Name=InnoDB patch to fix buffer pool scalability
-+Version=1.0
-+Author=Yasufumi Kinoshita
-+License=BSD
-+Comment=Backport from XtraDB
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-08-28 11:08:17.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-08-28 11:06:30.000000000 +0900
-@@ -1507,6 +1507,13 @@
- /* We set srv_pool_size here in units of 1 kB. InnoDB internally
- changes the value so that it becomes the number of database pages. */
-
-+ if (innobase_buffer_pool_awe_mem_mb) {
-+ /* split_buf_pool_mutex.patch don't support AWE */
-+ fputs("InnoDB: Warning: split_buf_pool_mutex.patch don't support AWE. Disabled.\n",
-+ stderr);
-+ innobase_buffer_pool_awe_mem_mb = 0;
-+ }
-+
- if (innobase_buffer_pool_awe_mem_mb == 0) {
- /* Careful here: we first convert the signed long int to ulint
- and only after that divide */
diff --git a/percona/5.0.87-b20-20100217/innodb_thread_concurrency_timer_based.patch b/percona/5.0.87-b20-20100217/innodb_thread_concurrency_timer_based.patch
deleted file mode 100644
index 3b8f659..0000000
--- a/percona/5.0.87-b20-20100217/innodb_thread_concurrency_timer_based.patch
+++ /dev/null
@@ -1,389 +0,0 @@
-diff -ruN a/innobase/configure b/innobase/configure
---- a/innobase/configure 2009-01-30 06:56:31.000000000 +0900
-+++ b/innobase/configure 2009-05-06 15:40:47.000000000 +0900
-@@ -21306,6 +21306,88 @@
- fi
- done
-
-+
-+# as http://lists.mysql.com/commits/40686 does
-+{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5
-+echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; }
-+if test "${mysql_cv_atomic_builtins+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ if test "$cross_compiling" = yes; then
-+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&5
-+echo "$as_me: error: cannot run test program while cross compiling
-+See \`config.log' for more details." >&2;}
-+ { (exit 1); exit 1; }; }
-+else
-+ cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+
-+_ACEOF
-+rm -f conftest$ac_exeext
-+if { (ac_try="$ac_link"
-+case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_link") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-+ { (case "(($ac_try" in
-+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-+ *) ac_try_echo=$ac_try;;
-+esac
-+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-+ (eval "$ac_try") 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ mysql_cv_atomic_builtins=yes
-+else
-+ echo "$as_me: program exited with status $ac_status" >&5
-+echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+( exit $ac_status )
-+mysql_cv_atomic_builtins=no
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-+fi
-+
-+
-+fi
-+{ echo "$as_me:$LINENO: result: $mysql_cv_atomic_builtins" >&5
-+echo "${ECHO_T}$mysql_cv_atomic_builtins" >&6; }
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+
-+cat >>confdefs.h <<\_ACEOF
-+#define HAVE_ATOMIC_BUILTINS 1
-+_ACEOF
-+
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/configure.in b/innobase/configure.in
---- a/innobase/configure.in 2009-01-30 06:42:15.000000000 +0900
-+++ b/innobase/configure.in 2009-05-06 15:40:47.000000000 +0900
-@@ -42,6 +42,31 @@
- AC_CHECK_FUNCS(sched_yield)
- AC_CHECK_FUNCS(fdatasync)
- AC_CHECK_FUNCS(localtime_r)
-+
-+# as http://lists.mysql.com/commits/40686 does
-+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
-+ [mysql_cv_atomic_builtins], [AC_TRY_RUN([
-+ int main()
-+ {
-+ int foo= -10; int bar= 10;
-+ __sync_fetch_and_add(&foo, bar);
-+ if (foo)
-+ return -1;
-+ bar= __sync_lock_test_and_set(&foo, bar);
-+ if (bar || foo != 10)
-+ return -1;
-+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
-+ if (bar)
-+ return -1;
-+ return 0;
-+ }
-+], [mysql_cv_atomic_builtins=yes], [mysql_cv_atomic_builtins=no])])
-+
-+if test "x$mysql_cv_atomic_builtins" = xyes; then
-+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1,
-+ [Define to 1 if compiler provides atomic builtins.])
-+fi
-+
- #AC_CHECK_FUNCS(readdir_r) MySQL checks that it has also the right args.
- # Some versions of Unix only take 2 arguments.
- #AC_C_INLINE Already checked in MySQL
-diff -ruN a/innobase/ib_config.h b/innobase/ib_config.h
---- a/innobase/ib_config.h 2009-01-30 07:05:03.000000000 +0900
-+++ b/innobase/ib_config.h 2009-05-06 15:40:47.000000000 +0900
-@@ -7,6 +7,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #define HAVE_AIO_H 1
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#define HAVE_ATOMIC_BUILTINS 1
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
-
-diff -ruN a/innobase/ib_config.h.in b/innobase/ib_config.h.in
---- a/innobase/ib_config.h.in 2009-01-30 06:56:11.000000000 +0900
-+++ b/innobase/ib_config.h.in 2009-05-06 15:40:47.000000000 +0900
-@@ -6,6 +6,9 @@
- /* Define to 1 if you have the <aio.h> header file. */
- #undef HAVE_AIO_H
-
-+/* Define to 1 if compiler provides atomic builtins. */
-+#undef HAVE_ATOMIC_BUILTINS
-+
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #undef HAVE_DLFCN_H
-
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-05-06 16:04:36.000000000 +0900
-@@ -90,6 +90,8 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_thread_concurrency_timer_based;
-+
- extern ulint srv_n_file_io_threads;
- extern ulint srv_n_read_io_threads;
- extern ulint srv_n_write_io_threads;
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-05-06 17:12:54.000000000 +0900
-@@ -267,6 +267,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-
-@@ -1020,6 +1021,74 @@
- Puts an OS thread to wait if there are too many concurrent threads
- (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+static void
-+enter_innodb_with_tickets(trx_t* trx)
-+{
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
-+ return;
-+}
-+
-+static void
-+srv_conc_enter_innodb_timer_based(trx_t* trx)
-+{
-+ lint conc_n_threads;
-+ ibool has_yielded = FALSE;
-+ ulint has_slept = 0;
-+
-+ if (trx->declared_to_be_inside_innodb) {
-+ ut_print_timestamp(stderr);
-+ fputs(
-+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
-+"InnoDB: it already is declared.\n", stderr);
-+ trx_print(stderr, trx, 0);
-+ putc('\n', stderr);
-+ }
-+retry:
-+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ }
-+ if (!has_yielded)
-+ {
-+ has_yielded = TRUE;
-+ os_thread_yield();
-+ goto retry;
-+ }
-+ if (trx->has_search_latch
-+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
-+
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+ }
-+ if (has_slept < 2)
-+ {
-+ trx->op_info = "sleeping before entering InnoDB";
-+ os_thread_sleep(10000);
-+ trx->op_info = "";
-+ has_slept++;
-+ }
-+ conc_n_threads = __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ enter_innodb_with_tickets(trx);
-+ return;
-+}
-+
-+static void
-+srv_conc_exit_innodb_timer_based(trx_t* trx)
-+{
-+ __sync_add_and_fetch(&srv_conc_n_threads, -1);
-+ trx->declared_to_be_inside_innodb = FALSE;
-+ trx->n_tickets_to_enter_innodb = 0;
-+ return;
-+}
-+#endif
-+
- void
- srv_conc_enter_innodb(
- /*==================*/
-@@ -1043,6 +1112,13 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_enter_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
- retry:
- if (trx->declared_to_be_inside_innodb) {
-@@ -1196,6 +1272,15 @@
- return;
- }
-
-+ ut_ad(srv_conc_n_threads >= 0);
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ __sync_add_and_fetch(&srv_conc_n_threads, 1);
-+ trx->declared_to_be_inside_innodb = TRUE;
-+ trx->n_tickets_to_enter_innodb = 1;
-+ return;
-+ }
-+#endif
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_threads++;
-@@ -1227,8 +1312,16 @@
- return;
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ if (srv_thread_concurrency_timer_based) {
-+ srv_conc_exit_innodb_timer_based(trx);
-+ return;
-+ }
-+#endif
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
-+ ut_ad(srv_conc_n_threads > 0);
- srv_conc_n_threads--;
- trx->declared_to_be_inside_innodb = FALSE;
- trx->n_tickets_to_enter_innodb = 0;
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-05-06 15:38:01.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-05-06 17:22:26.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+#ifdef HAVE_ATOMIC_BUILTINS
-+ fprintf(stderr,
-+ "InnoDB: use atomic builtins.\n");
-+#endif
-+
- /* Since InnoDB does not currently clean up all its internal data
- structures in MySQL Embedded Server Library server_end(), we
- print an error message if someone tries to start up InnoDB a
-diff -ruN a/patch_info/innodb_thread_concurrency_timer_based.info b/patch_info/innodb_thread_concurrency_timer_based.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_thread_concurrency_timer_based.info 2009-05-06 17:17:12.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=thread_concurrency_timer_based.patch
-+Name=Use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-05-06 15:54:08.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-
-@@ -1477,6 +1478,9 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_thread_concurrency_timer_based =
-+ (ibool) innobase_thread_concurrency_timer_based;
-+
- #ifdef UNIV_LOG_ARCHIVE
- srv_log_archive_on = (ulint) innobase_log_archive;
- #endif /* UNIV_LOG_ARCHIVE */
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-05-06 15:55:50.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
- extern long innobase_open_files;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/mysqld.cc 2009-05-06 16:22:06.000000000 +0900
-@@ -5096,6 +5096,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-@@ -5455,6 +5456,11 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
-+ "Use InnoDB timer based concurrency throttling. ",
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ (gptr*) &innobase_thread_concurrency_timer_based,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
- "Number of extra user rollback segments when create new database.",
- (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-05-06 15:38:01.000000000 +0900
-+++ b/sql/set_var.cc 2009-05-06 16:02:27.000000000 +0900
-@@ -1063,6 +1063,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
- {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20100217/innodb_use_sys_malloc.patch b/percona/5.0.87-b20-20100217/innodb_use_sys_malloc.patch
deleted file mode 100644
index 9637315..0000000
--- a/percona/5.0.87-b20-20100217/innodb_use_sys_malloc.patch
+++ /dev/null
@@ -1,265 +0,0 @@
-diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/include/srv0srv.h 2009-07-06 16:06:51.000000000 +0900
-@@ -90,6 +90,7 @@
- extern ulint srv_mem_pool_size;
- extern ulint srv_lock_table_size;
-
-+extern ibool srv_use_sys_malloc;
- extern ibool srv_thread_concurrency_timer_based;
-
- extern ulint srv_n_file_io_threads;
-diff -ruN a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h
---- a/innobase/include/ut0mem.h 2009-07-07 21:54:07.000000000 +0900
-+++ b/innobase/include/ut0mem.h 2009-08-03 14:42:17.000000000 +0900
-@@ -30,6 +30,13 @@
-
-
- /**************************************************************************
-+Initializes the mem block list at database startup. */
-+
-+void
-+ut_mem_block_list_init(void);
-+/*========================*/
-+
-+/**************************************************************************
- Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
- defined and set_to_zero is TRUE. */
-
-diff -ruN a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
---- a/innobase/mem/mem0dbg.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0dbg.c 2009-07-06 16:48:17.000000000 +0900
-@@ -134,6 +134,14 @@
- mem_hash_initialized = TRUE;
- #endif
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ /* When innodb_use_sys_malloc is set, the
-+ mem_comm_pool won't be used for any allocations. We
-+ create a dummy mem_comm_pool, because some statistics
-+ and debugging code relies on it being initialized. */
-+ size = 1;
-+ }
-+
- mem_comm_pool = mem_pool_create(size);
- }
-
-diff -ruN a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c
---- a/innobase/mem/mem0pool.c 2009-05-08 06:12:10.000000000 +0900
-+++ b/innobase/mem/mem0pool.c 2009-07-06 17:22:09.000000000 +0900
-@@ -11,6 +11,7 @@
- #include "mem0pool.ic"
- #endif
-
-+#include "srv0srv.h"
- #include "sync0sync.h"
- #include "ut0mem.h"
- #include "ut0lst.h"
-@@ -191,8 +192,6 @@
- ulint i;
- ulint used;
-
-- ut_a(size > 10000);
--
- pool = ut_malloc(sizeof(mem_pool_t));
-
- /* We do not set the memory to zero (FALSE) in the pool,
-@@ -330,6 +329,10 @@
- ulint n;
- ibool ret;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(malloc(size));
-+ }
-+
- n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE));
-
- mutex_enter(&(pool->mutex));
-@@ -457,6 +460,11 @@
- ulint size;
- ulint n;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ free(ptr);
-+ return;
-+ }
-+
- /* It may be that the area was really allocated from the OS with
- regular malloc: check if ptr points within our memory pool */
-
-diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0srv.c 2009-07-06 16:08:06.000000000 +0900
-@@ -273,6 +273,7 @@
- computer. Bigger computers need bigger values. Value 0 will disable the
- concurrency check. */
-
-+ibool srv_use_sys_malloc = TRUE;
- ibool srv_thread_concurrency_timer_based = TRUE;
- ulong srv_thread_concurrency = 0;
- ulong srv_commit_concurrency = 0;
-@@ -1012,6 +1013,7 @@
- srv_general_init(void)
- /*==================*/
- {
-+ ut_mem_block_list_init();
- os_sync_init();
- sync_init();
- mem_init(srv_mem_pool_size);
-diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
---- a/innobase/srv/srv0start.c 2009-07-06 15:59:52.000000000 +0900
-+++ b/innobase/srv/srv0start.c 2009-07-06 16:23:38.000000000 +0900
-@@ -1040,6 +1040,11 @@
- return(DB_ERROR);
- }
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ fprintf(stderr,
-+ "InnoDB: The InnoDB memory heap is disabled\n");
-+ }
-+
- #ifdef HAVE_ATOMIC_BUILTINS
- fprintf(stderr,
- "InnoDB: use atomic builtins.\n");
-diff -ruN a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
---- a/innobase/ut/ut0mem.c 2009-05-08 06:12:13.000000000 +0900
-+++ b/innobase/ut/ut0mem.c 2009-07-06 16:42:26.000000000 +0900
-@@ -15,6 +15,7 @@
- #include "mem0mem.h"
- #include "os0sync.h"
- #include "os0thread.h"
-+#include "srv0srv.h"
-
- /* This struct is placed first in every allocated memory block */
- typedef struct ut_mem_block_struct ut_mem_block_t;
-@@ -43,7 +44,7 @@
-
- /**************************************************************************
- Initializes the mem block list at database startup. */
--static
-+
- void
- ut_mem_block_list_init(void)
- /*========================*/
-@@ -70,11 +71,21 @@
- ulint retry_count = 0;
- void* ret;
-
-- ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ ret = malloc(n);
-+ ut_a(ret || !assert_on_error);
-
-- if (!ut_mem_block_list_inited) {
-- ut_mem_block_list_init();
-+#ifdef UNIV_SET_MEM_TO_ZERO
-+ if (set_to_zero) {
-+ memset(ret, '\0', n);
-+ }
-+#endif
-+ return(ret);
- }
-+
-+ ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
-+
-+ ut_a(ut_mem_block_list_inited);
- retry:
- os_fast_mutex_lock(&ut_list_mutex);
-
-@@ -223,6 +236,11 @@
- {
- 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);
-@@ -275,6 +293,10 @@
- ulint min_size;
- void* new_ptr;
-
-+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
-+ return(realloc(ptr, size));
-+ }
-+
- if (ptr == NULL) {
-
- return(ut_malloc(size));
-diff -ruN a/patch_info/innodb_use_sys_malloc.info b/patch_info/innodb_use_sys_malloc.info
---- /dev/null 1970-01-01 09:00:00.000000000 +0900
-+++ b/patch_info/innodb_use_sys_malloc.info 2009-07-06 16:04:24.000000000 +0900
-@@ -0,0 +1,6 @@
-+File=innodb_use_sys_malloc.patch
-+Name=InnoDB uses malloc directly (backport from InnoDB-Plugin)
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment
-diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
---- a/sql/ha_innodb.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.cc 2009-07-06 16:10:15.000000000 +0900
-@@ -152,6 +152,7 @@
- innobase_open_files;
-
- long innobase_read_io_threads, innobase_write_io_threads;
-+my_bool innobase_use_sys_malloc;
- my_bool innobase_thread_concurrency_timer_based;
- long innobase_extra_rsegments;
- longlong innobase_buffer_pool_size, innobase_log_file_size;
-@@ -1492,6 +1493,8 @@
- srv_n_log_files = (ulint) innobase_log_files_in_group;
- srv_log_file_size = (ulint) innobase_log_file_size;
-
-+ srv_use_sys_malloc = (ibool) innobase_use_sys_malloc;
-+
- srv_thread_concurrency_timer_based =
- (ibool) innobase_thread_concurrency_timer_based;
-
-diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
---- a/sql/ha_innodb.h 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/ha_innodb.h 2009-07-06 16:10:42.000000000 +0900
-@@ -205,6 +205,7 @@
- extern long innobase_buffer_pool_awe_mem_mb;
- extern long innobase_file_io_threads, innobase_lock_wait_timeout;
- extern long innobase_read_io_threads, innobase_write_io_threads;
-+extern my_bool innobase_use_sys_malloc;
- extern my_bool innobase_thread_concurrency_timer_based;
- extern long innobase_extra_rsegments;
- extern long innobase_force_recovery;
-diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
---- a/sql/mysqld.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/mysqld.cc 2009-07-06 16:16:56.000000000 +0900
-@@ -5102,6 +5102,7 @@
- OPT_INNODB_ADAPTIVE_CHECKPOINT,
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
-+ OPT_INNODB_USE_SYS_MALLOC,
- OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- OPT_INNODB_EXTRA_RSEGMENTS,
- OPT_INNODB_DICT_SIZE_LIMIT,
-@@ -5470,6 +5471,10 @@
- "Number of background write I/O threads in InnoDB.",
- (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
- 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0},
-+ {"innodb_use_sys_malloc", OPT_INNODB_USE_SYS_MALLOC,
-+ "Use OS memory allocator instead of InnoDB's internal memory allocator",
-+ (gptr*) &innobase_use_sys_malloc, (gptr*) &innobase_use_sys_malloc,
-+ 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
- {"innodb_thread_concurrency_timer_based", OPT_INNODB_THREAD_CONCURRENCY_TIMER_BASED,
- "Use InnoDB timer based concurrency throttling. ",
- (gptr*) &innobase_thread_concurrency_timer_based,
-diff -ruN a/sql/set_var.cc b/sql/set_var.cc
---- a/sql/set_var.cc 2009-07-06 15:59:52.000000000 +0900
-+++ b/sql/set_var.cc 2009-07-06 16:22:05.000000000 +0900
-@@ -1093,6 +1093,7 @@
- {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
- {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
- {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
-+ {"innodb_use_sys_malloc", (char*) &innobase_use_sys_malloc, SHOW_MY_BOOL},
- {"innodb_thread_concurrency_timer_based", (char*) &innobase_thread_concurrency_timer_based, SHOW_MY_BOOL},
- {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
- {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
diff --git a/percona/5.0.87-b20-20100217/microsec_process.patch b/percona/5.0.87-b20-20100217/microsec_process.patch
deleted file mode 100644
index 2e68888..0000000
--- a/percona/5.0.87-b20-20100217/microsec_process.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-diff -r e3b747e556c8 mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
-@@ -44,6 +44,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-@@ -740,7 +741,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--106
-+107
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -749,6 +750,7 @@
- table_schema table_name column_name
- information_schema COLUMNS COLUMN_DEFAULT
- information_schema COLUMNS COLUMN_TYPE
-+information_schema PROCESSLIST INFO
- information_schema ROUTINES ROUTINE_DEFINITION
- information_schema ROUTINES SQL_MODE
- information_schema TRIGGERS ACTION_CONDITION
-@@ -813,7 +815,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 21
-+information_schema 22
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1206,6 +1208,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1242,6 +1245,7 @@
- COLUMN_PRIVILEGES TABLE_SCHEMA
- INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
-+PROCESSLIST ID
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
- SCHEMATA SCHEMA_NAME
-@@ -1329,6 +1333,7 @@
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
-+PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
- SCHEMATA information_schema.SCHEMATA 1
-diff -r e3b747e556c8 mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
-@@ -13,6 +13,7 @@
- COLUMN_PRIVILEGES
- INDEX_STATISTICS
- KEY_COLUMN_USAGE
-+PROCESSLIST
- PROFILING
- ROUTINES
- SCHEMATA
-diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
-@@ -87,6 +87,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-@@ -113,6 +114,7 @@
- | COLUMN_PRIVILEGES |
- | INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
-+| PROCESSLIST |
- | PROFILING |
- | ROUTINES |
- | SCHEMATA |
-diff -r e3b747e556c8 patch_info/microsec_process.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
-@@ -0,0 +1,6 @@
-+File=microsec_process.patch
-+Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-diff -r e3b747e556c8 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
-@@ -249,6 +249,8 @@
-
- /* Characters shown for the command in 'show processlist' */
- #define PROCESS_LIST_WIDTH 100
-+/* Characters shown for the command in 'information_schema.processlist' */
-+#define PROCESS_LIST_INFO_WIDTH 65535
-
- #define PRECISION_FOR_DOUBLE 53
- #define PRECISION_FOR_FLOAT 24
-diff -r e3b747e556c8 sql/sql_show.cc
---- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
-+++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
-@@ -1480,6 +1480,122 @@
- DBUG_VOID_RETURN;
- }
-
-+int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ CHARSET_INFO *cs= system_charset_info;
-+ char *user;
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ DBUG_ENTER("fill_process_list");
-+
-+ user= thd->security_ctx->master_access & PROCESS_ACL ?
-+ NullS : thd->security_ctx->priv_user;
-+
-+ VOID(pthread_mutex_lock(&LOCK_thread_count));
-+
-+ if (!thd->killed)
-+ {
-+ I_List_iterator<THD> it(threads);
-+ THD* tmp;
-+
-+ while ((tmp= it++))
-+ {
-+ Security_context *tmp_sctx= tmp->security_ctx;
-+ struct st_my_thread_var *mysys_var;
-+ const char *val;
-+
-+ if ((!tmp->vio_ok() && !tmp->system_thread) ||
-+ (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
-+ continue;
-+
-+ restore_record(table, s->default_values);
-+ /* ID */
-+ table->field[0]->store((longlong) tmp->thread_id, TRUE);
-+ /* USER */
-+ val= tmp_sctx->user ? tmp_sctx->user :
-+ (tmp->system_thread ? "system user" : "unauthenticated user");
-+ table->field[1]->store(val, strlen(val), cs);
-+ /* HOST */
-+ if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
-+ thd->security_ctx->host_or_ip[0])
-+ {
-+ char host[LIST_PROCESS_HOST_LEN + 1];
-+ my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
-+ tmp_sctx->host_or_ip, tmp->peer_port);
-+ table->field[2]->store(host, strlen(host), cs);
-+ }
-+ else
-+ table->field[2]->store(tmp_sctx->host_or_ip,
-+ strlen(tmp_sctx->host_or_ip), cs);
-+ /* DB */
-+ if (tmp->db)
-+ {
-+ table->field[3]->store(tmp->db, strlen(tmp->db), cs);
-+ table->field[3]->set_notnull();
-+ }
-+
-+ if ((mysys_var= tmp->mysys_var))
-+ pthread_mutex_lock(&mysys_var->mutex);
-+ /* COMMAND */
-+ if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
-+ table->field[4]->store(val, strlen(val), cs);
-+ else
-+ table->field[4]->store(command_name[tmp->command],
-+ strlen(command_name[tmp->command]), cs);
-+ /* MYSQL_TIME */
-+ ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
-+ /* correction for negative time */
-+ if (utime > 2629743) utime= 0;
-+ table->field[5]->store(utime / 1000000, TRUE);
-+ /* STATE */
-+#ifndef EMBEDDED_LIBRARY
-+ val= (char*) (tmp->locked ? "Locked" :
-+ tmp->net.reading_or_writing ?
-+ (tmp->net.reading_or_writing == 2 ?
-+ "Writing to net" :
-+ tmp->command == COM_SLEEP ? "" :
-+ "Reading from net") :
-+ tmp->proc_info ? tmp->proc_info :
-+ tmp->mysys_var &&
-+ tmp->mysys_var->current_cond ?
-+ "Waiting on cond" : NullS);
-+#else
-+ val= (char *) "Writing to net";
-+#endif
-+ if (val)
-+ {
-+ table->field[6]->store(val, strlen(val), cs);
-+ table->field[6]->set_notnull();
-+ }
-+
-+ if (mysys_var)
-+ pthread_mutex_unlock(&mysys_var->mutex);
-+
-+ /* INFO */
-+ if (tmp->query)
-+ {
-+ table->field[7]->store(tmp->query,
-+ min(PROCESS_LIST_INFO_WIDTH,
-+ tmp->query_length), cs);
-+ table->field[7]->set_notnull();
-+ }
-+
-+ /* TIME_MS */
-+ table->field[8]->store((double)(utime / 1000.0));
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(1);
-+ }
-+
-+ }
-+ }
-+
-+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
-+ DBUG_RETURN(0);
-+}
-+
- /*****************************************************************************
- Status functions
- *****************************************************************************/
-@@ -4849,6 +4965,22 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO processlist_fields_info[]=
-+{
-+ {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
-+ {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
-+ {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
-+ {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
-+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
-+ {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
-+ {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
-+ {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
-+ 0, 0, "Time_ms"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
- /*
- Description of ST_FIELD_INFO in table.h
- */
-@@ -4873,6 +5005,8 @@
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
- fill_open_tables, make_old_format, 0, -1, -1, 1},
-+ {"PROCESSLIST", processlist_fields_info, create_schema_table,
-+ fill_schema_processlist, make_old_format, 0, -1, -1, 0},
- {"PROFILING", query_profile_statistics_info, create_schema_table,
- fill_query_profile_statistics_info, make_profile_table_for_show,
- NULL, -1, -1, false},
-diff -r e3b747e556c8 sql/table.h
---- a/sql/table.h Mon May 18 18:44:04 2009 -0700
-+++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
-@@ -379,6 +379,7 @@
- SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
-+ SCH_PROCESSLIST,
- SCH_PROFILES,
- SCH_PROCEDURES,
- SCH_SCHEMATA,
diff --git a/percona/5.0.87-b20-20100217/microslow_innodb.patch b/percona/5.0.87-b20-20100217/microslow_innodb.patch
deleted file mode 100644
index 11a186c..0000000
--- a/percona/5.0.87-b20-20100217/microslow_innodb.patch
+++ /dev/null
@@ -1,2492 +0,0 @@
-diff -r 1242d4575291 include/my_getopt.h
---- a/include/my_getopt.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_getopt.h Tue Jul 28 23:42:44 2009 -0700
-@@ -28,7 +28,8 @@
- #define GET_ULL 8
- #define GET_STR 9
- #define GET_STR_ALLOC 10
--#define GET_DISABLED 11
-+#define GET_MICROTIME 11
-+#define GET_DISABLED 12
-
- #define GET_ASK_ADDR 128
- #define GET_TYPE_MASK 127
-diff -r 1242d4575291 include/my_time.h
---- a/include/my_time.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/include/my_time.h Tue Jul 28 23:42:44 2009 -0700
-@@ -140,7 +140,7 @@
- int my_date_to_str(const MYSQL_TIME *l_time, char *to);
- int my_datetime_to_str(const MYSQL_TIME *l_time, char *to);
- int my_TIME_to_str(const MYSQL_TIME *l_time, char *to);
--
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency);
- C_MODE_END
-
- #endif /* _my_time_h_ */
-diff -r 1242d4575291 innobase/buf/buf0buf.c
---- a/innobase/buf/buf0buf.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0buf.c Tue Jul 28 23:42:44 2009 -0700
-@@ -37,6 +37,10 @@
- #include "log0log.h"
- #include "trx0undo.h"
- #include "srv0srv.h"
-+#include "trx0trx.h"
-+
-+/* prototypes for new functions added to ha_innodb.cc */
-+trx_t* innobase_get_trx();
-
- /*
- IMPLEMENTATION OF THE BUFFER POOL
-@@ -1086,6 +1090,36 @@
- return(block);
- }
-
-+inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
-+{
-+ ulint block_hash;
-+ ulint block_hash_byte;
-+ byte block_hash_offset;
-+
-+ ut_ad(block);
-+
-+ if (!srv_slow_log || !trx || !trx->take_stats)
-+ return;
-+
-+ if (!trx->distinct_page_access_hash) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
-+ block_hash = ut_hash_ulint((block->space << 20) + block->space +
-+ block->offset, DPAH_SIZE << 3);
-+ block_hash_byte = block_hash >> 3;
-+ block_hash_offset = (byte) block_hash & 0x07;
-+ if (block_hash_byte < 0 || block_hash_byte >= DPAH_SIZE)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if (block_hash_offset < 0 || block_hash_offset > 7)
-+ fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %lu !!!\n", block_hash_byte, block_hash_offset);
-+ if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
-+ trx->distinct_page_access++;
-+ trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
-+ return;
-+}
-+
- /************************************************************************
- This is the general function used to get access to a database page. */
-
-@@ -1108,6 +1142,11 @@
- ulint fix_type;
- ibool success;
- ibool must_read;
-+ trx_t* trx = NULL;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH)
-@@ -1119,6 +1158,9 @@
- #ifndef UNIV_LOG_DEBUG
- ut_ad(!ibuf_inside() || ibuf_page(space, offset));
- #endif
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ }
- buf_pool->n_page_gets++;
- loop:
- block = NULL;
-@@ -1148,7 +1190,7 @@
- return(NULL);
- }
-
-- buf_read_page(space, offset);
-+ buf_read_page(space, offset, trx);
-
- #ifdef UNIV_DEBUG
- buf_dbg_counter++;
-@@ -1261,6 +1303,11 @@
- /* Let us wait until the read operation
- completes */
-
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- for (;;) {
- mutex_enter(&block->mutex);
-
-@@ -1276,6 +1323,12 @@
- break;
- }
- }
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
- }
-
- fix_type = MTR_MEMO_BUF_FIX;
-@@ -1296,12 +1349,17 @@
- /* In the case of a first access, try to apply linear
- read-ahead */
-
-- buf_read_ahead_linear(space, offset);
-+ buf_read_ahead_linear(space, offset, trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
- ut_a(ibuf_count_get(block->space, block->offset) == 0);
- #endif
-+
-+ if (srv_slow_log) {
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(block->frame);
- }
-
-@@ -1326,6 +1384,7 @@
- ibool accessed;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr && block);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1440,7 +1499,7 @@
- read-ahead */
-
- buf_read_ahead_linear(buf_frame_get_space_id(guess),
-- buf_frame_get_page_no(guess));
-+ buf_frame_get_page_no(guess), trx);
- }
-
- #ifdef UNIV_IBUF_DEBUG
-@@ -1448,6 +1507,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-@@ -1470,6 +1534,7 @@
- buf_block_t* block;
- ibool success;
- ulint fix_type;
-+ trx_t* trx = NULL;
-
- ut_ad(mtr);
- ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
-@@ -1559,6 +1624,11 @@
- #endif
- buf_pool->n_page_gets++;
-
-+ if (srv_slow_log) {
-+ trx = innobase_get_trx();
-+ _increment_page_get_statistics(block, trx);
-+ }
-+
- return(TRUE);
- }
-
-diff -r 1242d4575291 innobase/buf/buf0rea.c
---- a/innobase/buf/buf0rea.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/buf/buf0rea.c Tue Jul 28 23:42:44 2009 -0700
-@@ -70,7 +70,8 @@
- treat the tablespace as dropped; this is a timestamp we
- use to stop dangling page reads from a tablespace
- which we have DISCARDed + IMPORTed back */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- buf_block_t* block;
- ulint wake_later;
-@@ -140,10 +141,10 @@
-
- ut_a(block->state == BUF_BLOCK_FILE_PAGE);
-
-- *err = fil_io(OS_FILE_READ | wake_later,
-+ *err = _fil_io(OS_FILE_READ | wake_later,
- sync, space,
- offset, 0, UNIV_PAGE_SIZE,
-- (void*)block->frame, (void*)block);
-+ (void*)block->frame, (void*)block, trx);
- ut_a(*err == DB_SUCCESS);
-
- if (sync) {
-@@ -174,8 +175,9 @@
- the page at the given page number does not get
- read even if we return a value > 0! */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page which the current thread
-+ ulint offset, /* in: page number of a page which the current thread
- wants to access */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -270,7 +272,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -314,7 +316,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- ulint count;
-@@ -323,13 +326,13 @@
-
- tablespace_version = fil_space_get_version(space);
-
-- count = buf_read_ahead_random(space, offset);
-+ count = buf_read_ahead_random(space, offset, trx);
-
- /* We do the i/o in the synchronous aio mode to save thread
- switches: hence TRUE */
-
- count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, offset);
-+ tablespace_version, offset, trx);
- srv_buf_pool_reads+= count2;
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
-@@ -374,8 +377,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset) /* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx)
- {
- ib_longlong tablespace_version;
- buf_block_t* block;
-@@ -556,7 +560,7 @@
- if (!ibuf_bitmap_page(i)) {
- count += buf_read_page_low(&err, FALSE, ibuf_mode
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, i);
-+ space, tablespace_version, i, trx);
- if (err == DB_TABLESPACE_DELETED) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
-@@ -625,10 +629,10 @@
- for (i = 0; i < n_stored; i++) {
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE,
-- space_ids[i], space_versions[i], page_nos[i]);
-+ space_ids[i], space_versions[i], page_nos[i], NULL);
- }
-
- if (err == DB_TABLESPACE_DELETED) {
-@@ -704,11 +708,11 @@
-
- if ((i + 1 == n_stored) && sync) {
- buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
-- tablespace_version, page_nos[i]);
-+ tablespace_version, page_nos[i], NULL);
- } else {
- buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
- | OS_AIO_SIMULATED_WAKE_LATER,
-- space, tablespace_version, page_nos[i]);
-+ space, tablespace_version, page_nos[i], NULL);
- }
- }
-
-diff -r 1242d4575291 innobase/fil/fil0fil.c
---- a/innobase/fil/fil0fil.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/fil/fil0fil.c Tue Jul 28 23:42:44 2009 -0700
-@@ -3527,7 +3527,7 @@
- node->name, node->handle, buf,
- offset_low, offset_high,
- UNIV_PAGE_SIZE * n_pages,
-- NULL, NULL);
-+ NULL, NULL, NULL);
- #endif
- if (success) {
- node->size += n_pages;
-@@ -3851,7 +3851,7 @@
- Reads or writes data. This operation is asynchronous (aio). */
-
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -3877,8 +3877,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message) /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx)
- {
- fil_system_t* system = fil_system;
- ulint mode;
-@@ -4018,7 +4019,7 @@
- #else
- /* Queue the aio request */
- ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
-- offset_low, offset_high, len, node, message);
-+ offset_low, offset_high, len, node, message, trx);
- #endif
- ut_a(ret);
-
-diff -r 1242d4575291 innobase/include/buf0rea.h
---- a/innobase/include/buf0rea.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/buf0rea.h Tue Jul 28 23:42:44 2009 -0700
-@@ -10,6 +10,7 @@
- #define buf0rea_h
-
- #include "univ.i"
-+#include "trx0types.h"
- #include "buf0types.h"
-
- /************************************************************************
-@@ -25,7 +26,8 @@
- /* out: number of page read requests issued: this can
- be > 1 if read-ahead occurred */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number */
-+ ulint offset, /* in: page number */
-+ trx_t* trx);
- /************************************************************************
- Applies linear read-ahead if in the buf_pool the page is a border page of
- a linear read-ahead area and all the pages in the area have been accessed.
-@@ -55,8 +57,9 @@
- /*==================*/
- /* out: number of page read requests issued */
- ulint space, /* in: space id */
-- ulint offset);/* in: page number of a page; NOTE: the current thread
-+ ulint offset, /* in: page number of a page; NOTE: the current thread
- must want access to this page (see NOTE 3 above) */
-+ trx_t* trx);
- /************************************************************************
- Issues read requests for pages which the ibuf module wants to read in, in
- order to contract the insert buffer tree. Technically, this function is like
-diff -r 1242d4575291 innobase/include/fil0fil.h
---- a/innobase/include/fil0fil.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/fil0fil.h Tue Jul 28 23:42:44 2009 -0700
-@@ -534,8 +534,11 @@
- /************************************************************************
- Reads or writes data. This operation is asynchronous (aio). */
-
-+#define fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message) \
-+ _fil_io(type, sync, space_id, block_offset, byte_offset, len, buf, message, NULL)
-+
- ulint
--fil_io(
-+_fil_io(
- /*===*/
- /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
- if we are trying to do i/o on a tablespace
-@@ -561,8 +564,9 @@
- void* buf, /* in/out: buffer where to store read data
- or from where to write; in aio this must be
- appropriately aligned */
-- void* message); /* in: message for aio handler if non-sync
-+ void* message, /* in: message for aio handler if non-sync
- aio used, else ignored */
-+ trx_t* trx);
- /************************************************************************
- Reads data from a space to a buffer. Remember that the possible incomplete
- blocks at the end of file are ignored: they are not taken into account when
-diff -r 1242d4575291 innobase/include/os0file.h
---- a/innobase/include/os0file.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/os0file.h Tue Jul 28 23:42:44 2009 -0700
-@@ -11,6 +11,8 @@
-
- #include "univ.i"
-
-+#include "trx0types.h"
-+
- #ifndef __WIN__
- #include <dirent.h>
- #include <sys/stat.h>
-@@ -421,8 +423,11 @@
- /***********************************************************************
- Requests a synchronous read operation. */
-
-+#define os_file_read(file, buf, offset, offset_high, n) \
-+ _os_file_read(file, buf, offset, offset_high, n, NULL)
-+
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -432,7 +437,8 @@
- offset where to read */
- ulint offset_high,/* in: most significant 32 bits of
- offset */
-- ulint n); /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx);
- /***********************************************************************
- Rewind file to its start, read at most size - 1 bytes from it to str, and
- NUL-terminate str. All errors are silently ignored. This function is
-@@ -584,7 +590,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2);
-+ void* message2,
-+ trx_t* trx);
- /****************************************************************************
- Wakes up all async i/o threads so that they know to exit themselves in
- shutdown. */
-diff -r 1242d4575291 innobase/include/srv0srv.h
---- a/innobase/include/srv0srv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/srv0srv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -27,6 +27,8 @@
- #define SRV_AUTO_EXTEND_INCREMENT \
- (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
-
-+extern ibool srv_slow_log;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL */
- extern ibool srv_lower_case_table_names;
-
-diff -r 1242d4575291 innobase/include/trx0trx.h
---- a/innobase/include/trx0trx.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/include/trx0trx.h Tue Jul 28 23:42:44 2009 -0700
-@@ -668,6 +668,17 @@
- /*------------------------------*/
- char detailed_error[256]; /* detailed error message for last
- error, or empty. */
-+ /*------------------------------*/
-+ ulint io_reads;
-+ ib_longlong io_read;
-+ ulint io_reads_wait_timer;
-+ ib_longlong lock_que_wait_ustarted;
-+ ulint lock_que_wait_timer;
-+ ulint innodb_que_wait_timer;
-+ ulint distinct_page_access;
-+#define DPAH_SIZE 8192
-+ byte* distinct_page_access_hash;
-+ ibool take_stats;
- };
-
- #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent
-diff -r 1242d4575291 innobase/lock/lock0lock.c
---- a/innobase/lock/lock0lock.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/lock/lock0lock.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1806,6 +1806,8 @@
- {
- lock_t* lock;
- trx_t* trx;
-+ ulint sec;
-+ ulint ms;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1861,6 +1863,10 @@
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
-
- ut_a(que_thr_stop(thr));
-
-@@ -3514,7 +3520,9 @@
- {
- lock_t* lock;
- trx_t* trx;
--
-+ ulint sec;
-+ ulint ms;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -3564,6 +3572,10 @@
- return(DB_SUCCESS);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ trx->lock_que_wait_ustarted = (ib_longlong)sec * 1000000 + ms;
-+ }
- trx->que_state = TRX_QUE_LOCK_WAIT;
- trx->was_chosen_as_deadlock_victim = FALSE;
- trx->wait_started = time(NULL);
-diff -r 1242d4575291 innobase/os/os0file.c
---- a/innobase/os/os0file.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/os/os0file.c Tue Jul 28 23:42:44 2009 -0700
-@@ -14,6 +14,8 @@
- #include "srv0start.h"
- #include "fil0fil.h"
- #include "buf0buf.h"
-+#include "trx0sys.h"
-+#include "trx0trx.h"
-
- #if defined(UNIV_HOTBACKUP) && defined(__WIN__)
- /* Add includes for the _stat() call to compile on Windows */
-@@ -1903,9 +1905,13 @@
- #ifndef __WIN__
- /***********************************************************************
- Does a synchronous read operation in Posix. */
-+
-+#define os_file_pread(file, buf, n, offset, offset_high) \
-+ _os_file_pread(file, buf, n, offset, offset_high, NULL);
-+
- static
- ssize_t
--os_file_pread(
-+_os_file_pread(
- /*==========*/
- /* out: number of bytes read, -1 if error */
- os_file_t file, /* in: handle to a file */
-@@ -1913,12 +1919,17 @@
- ulint n, /* in: number of bytes to read */
- ulint offset, /* in: least significant 32 bits of file
- offset from where to read */
-- ulint offset_high) /* in: most significant 32 bits of
-- offset */
-+ ulint offset_high, /* in: most significant 32 bits of
-+ offset */
-+ trx_t* trx)
- {
- off_t offs;
- ssize_t n_bytes;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong start_time;
-+ ib_longlong finish_time;
-+
- ut_a((offset & 0xFFFFFFFFUL) == offset);
-
- /* If off_t is > 4 bytes in size, then we assume we can pass a
-@@ -1937,7 +1948,13 @@
- }
-
- os_n_file_reads++;
--
-+ if (srv_slow_log && trx && trx->take_stats)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
- #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
- os_mutex_enter(os_file_count_mutex);
- os_file_n_pending_preads++;
-@@ -1951,6 +1968,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(n_bytes);
- #else
- {
-@@ -1981,6 +2005,13 @@
- os_n_pending_reads--;
- os_mutex_exit(os_file_count_mutex);
-
-+ if (srv_slow_log && trx && trx->take_stats && start_time)
-+ {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- return(ret);
- }
- #endif
-@@ -2103,7 +2134,7 @@
- Requests a synchronous positioned read operation. */
-
- ibool
--os_file_read(
-+_os_file_read(
- /*=========*/
- /* out: TRUE if request was
- successful, FALSE if fail */
-@@ -2113,7 +2144,8 @@
- offset where to read */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint n) /* in: number of bytes to read */
-+ ulint n, /* in: number of bytes to read */
-+ trx_t* trx)
- {
- #ifdef __WIN__
- BOOL ret;
-@@ -2177,7 +2209,7 @@
- os_bytes_read_since_printout += n;
-
- try_again:
-- ret = os_file_pread(file, buf, n, offset, offset_high);
-+ ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
-
- if ((ulint)ret == n) {
-
-@@ -3137,7 +3169,8 @@
- offset */
- ulint offset_high, /* in: most significant 32 bits of
- offset */
-- ulint len) /* in: length of the block to read or write */
-+ ulint len, /* in: length of the block to read or write */
-+ trx_t* trx)
- {
- os_aio_slot_t* slot;
- #ifdef WIN_ASYNC_IO
-@@ -3390,7 +3423,8 @@
- can be used to identify a completed aio
- operation); if mode is OS_AIO_SYNC, these
- are ignored */
-- void* message2)
-+ void* message2,
-+ trx_t* trx)
- {
- os_aio_array_t* array;
- os_aio_slot_t* slot;
-@@ -3429,8 +3463,8 @@
- wait in the Windows case. */
-
- if (type == OS_FILE_READ) {
-- return(os_file_read(file, buf, offset,
-- offset_high, n));
-+ return(_os_file_read(file, buf, offset,
-+ offset_high, n, trx));
- }
-
- ut_a(type == OS_FILE_WRITE);
-@@ -3463,8 +3497,13 @@
- ut_error;
- }
-
-+ if (trx && type == OS_FILE_READ)
-+ {
-+ trx->io_reads++;
-+ trx->io_read += n;
-+ }
- slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
-- name, buf, offset, offset_high, n);
-+ name, buf, offset, offset_high, n, trx);
- if (type == OS_FILE_READ) {
- if (os_aio_use_native_aio) {
- #ifdef WIN_ASYNC_IO
-diff -r 1242d4575291 innobase/srv/srv0srv.c
---- a/innobase/srv/srv0srv.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/srv/srv0srv.c Tue Jul 28 23:42:44 2009 -0700
-@@ -48,6 +48,8 @@
- #include "srv0start.h"
- #include "row0mysql.h"
-
-+ibool srv_slow_log = 0;
-+
- /* This is set to TRUE if the MySQL user has set it in MySQL; currently
- affects only FOREIGN KEY definition parsing */
- ibool srv_lower_case_table_names = FALSE;
-@@ -1002,6 +1004,10 @@
- ibool has_slept = FALSE;
- srv_conc_slot_t* slot = NULL;
- ulint i;
-+ ib_longlong start_time = 0L;
-+ ib_longlong finish_time = 0L;
-+ ulint sec;
-+ ulint ms;
-
- /* If trx has 'free tickets' to enter the engine left, then use one
- such ticket */
-@@ -1060,6 +1066,7 @@
- if (SRV_THREAD_SLEEP_DELAY > 0)
- {
- os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
-+ trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
- }
-
- trx->op_info = "";
-@@ -1115,12 +1122,23 @@
- /* Go to wait for the event; when a thread leaves InnoDB it will
- release this thread */
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ start_time = (ib_longlong)sec * 1000000 + ms;
-+ }
-+
- trx->op_info = "waiting in InnoDB queue";
-
- os_event_wait(slot->event);
-
- trx->op_info = "";
-
-+ if (srv_slow_log && trx->take_stats && start_time) {
-+ ut_usectime(&sec, &ms);
-+ finish_time = (ib_longlong)sec * 1000000 + ms;
-+ trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
-+ }
-+
- os_fast_mutex_lock(&srv_conc_mutex);
-
- srv_conc_n_waiting_threads--;
-diff -r 1242d4575291 innobase/trx/trx0trx.c
---- a/innobase/trx/trx0trx.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/innobase/trx/trx0trx.c Tue Jul 28 23:42:44 2009 -0700
-@@ -190,6 +190,15 @@
- trx->global_read_view_heap = mem_heap_create(256);
- trx->global_read_view = NULL;
- trx->read_view = NULL;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ trx->distinct_page_access_hash = NULL;
-+ trx->take_stats = FALSE;
-
- /* Set X/Open XA transaction identification to NULL */
- memset(&trx->xid, 0, sizeof(trx->xid));
-@@ -230,6 +239,11 @@
-
- trx->mysql_process_no = os_proc_get_number();
-
-+ if (srv_slow_log && trx->take_stats) {
-+ trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+ }
-+
- return(trx);
- }
-
-@@ -366,6 +380,12 @@
- /*===============*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- thr_local_free(trx->mysql_thread_id);
-
- mutex_enter(&kernel_mutex);
-@@ -389,6 +409,12 @@
- /*====================*/
- trx_t* trx) /* in, own: trx object */
- {
-+ if (trx->distinct_page_access_hash)
-+ {
-+ mem_free(trx->distinct_page_access_hash);
-+ trx->distinct_page_access_hash= NULL;
-+ }
-+
- mutex_enter(&kernel_mutex);
-
- trx_free(trx);
-@@ -1064,7 +1090,10 @@
- trx_t* trx) /* in: transaction */
- {
- que_thr_t* thr;
--
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-+
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
- #endif /* UNIV_SYNC_DEBUG */
-@@ -1080,6 +1109,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-@@ -1093,6 +1127,9 @@
- trx_t* trx) /* in: transaction in the TRX_QUE_LOCK_WAIT state */
- {
- que_thr_t* thr;
-+ ulint sec;
-+ ulint ms;
-+ ib_longlong now;
-
- #ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-@@ -1109,6 +1146,11 @@
- thr = UT_LIST_GET_FIRST(trx->wait_thrs);
- }
-
-+ if (srv_slow_log && trx->take_stats) {
-+ ut_usectime(&sec, &ms);
-+ now = (ib_longlong)sec * 1000000 + ms;
-+ trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
-+ }
- trx->que_state = TRX_QUE_RUNNING;
- }
-
-diff -r 1242d4575291 mysys/my_getopt.c
---- a/mysys/my_getopt.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/mysys/my_getopt.c Tue Jul 28 23:42:44 2009 -0700
-@@ -827,7 +827,8 @@
- #endif
- break;
- default:
-- DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
-+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL
-+ || (optp->var_type & GET_TYPE_MASK) == GET_MICROTIME);
- break;
- }
-
-@@ -1061,6 +1062,9 @@
- case GET_ULONG:
- printf("%lu\n", *((ulong*) value));
- break;
-+ case GET_MICROTIME:
-+ printf("%6f\n", ((double)(*((longlong*) value))) / 1000000.0);
-+ break;
- case GET_LL:
- printf("%s\n", llstr(*((longlong*) value), buff));
- break;
-diff -r 1242d4575291 patch_info/microslow_innodb.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/microslow_innodb.info Tue Jul 28 23:42:44 2009 -0700
-@@ -0,0 +1,15 @@
-+File=microslow_innodb.patch
-+Name=Extended statistics in slow.log
-+Version=1.2
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2008-11-26
-+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
-+
-+2008-11-07
-+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
-+
-+2008-11
-+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
-diff -r 1242d4575291 scripts/mysqldumpslow.sh
---- a/scripts/mysqldumpslow.sh Tue Jul 28 23:39:12 2009 -0700
-+++ b/scripts/mysqldumpslow.sh Tue Jul 28 23:42:44 2009 -0700
-@@ -83,8 +83,8 @@
- s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
- my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
-
-- s/^# Query_time: (\d+) Lock_time: (\d+) Rows_sent: (\d+).*\n//;
-- my ($t, $l, $r) = ($1, $2, $3);
-+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
-+ my ($t, $l, $r) = ($1, $3, $5);
- $t -= $l unless $opt{l};
-
- # remove fluff that mysqld writes to log when it (re)starts:
-diff -r 1242d4575291 sql-common/my_time.c
---- a/sql-common/my_time.c Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql-common/my_time.c Tue Jul 28 23:42:44 2009 -0700
-@@ -1253,3 +1253,37 @@
- return 0;
- }
-
-+/*
-+ int my_timer(ulonglong *ltime, ulonglong frequency)
-+
-+ For performance measurement this function returns the number
-+ of microseconds since the epoch (SVr4, BSD 4.3, POSIX 1003.1-2001)
-+ or system start (Windows platforms).
-+
-+ For windows platforms frequency value (obtained via
-+ QueryPerformanceFrequency) has to be specified. The global frequency
-+ value is set in mysqld.cc.
-+
-+ If Windows platform doesn't support QueryPerformanceFrequency we will
-+ obtain the time via GetClockCount, which supports microseconds only.
-+*/
-+
-+ulonglong my_timer(ulonglong *ltime, ulonglong frequency)
-+{
-+ ulonglong newtime= 0;
-+#ifdef __WIN__
-+ if (frequency)
-+ {
-+ QueryPerformanceCounter((LARGE_INTEGER *)&newtime);
-+ newtime/= (frequency * 1000000);
-+ } else
-+ newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */
-+#else
-+ struct timeval t;
-+ if (gettimeofday(&t, NULL) != -1)
-+ newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec;
-+#endif
-+ if (ltime)
-+ *ltime= newtime;
-+ return newtime;
-+}
-diff -r 1242d4575291 sql/filesort.cc
---- a/sql/filesort.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/filesort.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -180,6 +180,7 @@
- {
- statistic_increment(thd->status_var.filesort_scan_count, &LOCK_status);
- }
-+ thd->query_plan_flags|= QPLAN_FILESORT;
- #ifdef CAN_TRUST_RANGE
- if (select && select->quick && select->quick->records > 0L)
- {
-@@ -245,6 +246,7 @@
- }
- else
- {
-+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
- if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
- {
- x_free(table_sort.buffpek);
-@@ -1116,6 +1118,7 @@
-
- statistic_increment(current_thd->status_var.filesort_merge_passes,
- &LOCK_status);
-+ current_thd->query_plan_fsort_passes++;
- if (param->not_killable)
- {
- killed= &not_killable;
-diff -r 1242d4575291 sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1,3 +1,4 @@
-+
- /* Copyright (C) 2000-2005 MySQL AB & Innobase Oy
-
- This program is free software; you can redistribute it and/or modify
-@@ -819,9 +820,34 @@
- trx->check_unique_secondary = TRUE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- return(trx);
- }
-
-+/*************************************************************************
-+Gets current trx. */
-+extern "C"
-+trx_t*
-+innobase_get_trx()
-+{
-+ THD *thd=current_thd;
-+ if (likely(thd != 0)) {
-+ return((trx_t*) thd->ha_data[innobase_hton.slot]);
-+ } else {
-+ return(NULL);
-+ }
-+}
-+
-+void
-+innobase_update_var_slow_log()
-+{
-+ srv_slow_log = (ibool) opt_slow_log;
-+}
-
- /*************************************************************************
- Construct ha_innobase handler. */
-@@ -1324,6 +1350,8 @@
-
- /* -------------- Log files ---------------------------*/
-
-+ srv_slow_log = (ibool) opt_slow_log;
-+
- /* The default dir for log files is the datadir of MySQL */
-
- if (!innobase_log_group_home_dir) {
-@@ -4697,6 +4725,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- if (lower_case_table_names) {
- srv_lower_case_table_names = TRUE;
- } else {
-@@ -4962,6 +4996,12 @@
- trx->check_unique_secondary = FALSE;
- }
-
-+ if (thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len = strlen(name);
-
- assert(name_len < 1000);
-@@ -5049,6 +5089,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- error = row_drop_database_for_mysql(namebuf, trx);
- my_free(namebuf, MYF(0));
-
-@@ -5115,6 +5161,12 @@
- trx->check_foreigns = FALSE;
- }
-
-+ if (current_thd->variables.log_slow_verbosity & SLOG_V_INNODB) {
-+ trx->take_stats = TRUE;
-+ } else {
-+ trx->take_stats = FALSE;
-+ }
-+
- name_len1 = strlen(from);
- name_len2 = strlen(to);
-
-@@ -6122,6 +6174,7 @@
- {
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- trx_t* trx;
-+ int i;
-
- DBUG_ENTER("ha_innobase::external_lock");
- DBUG_PRINT("enter",("lock_type: %d", lock_type));
-@@ -6245,7 +6298,24 @@
-
- if (trx->n_mysql_tables_in_use == 0) {
-
-- trx->mysql_n_tables_locked = 0;
-+ current_thd->innodb_was_used = TRUE;
-+ current_thd->innodb_io_reads += trx->io_reads;
-+ current_thd->innodb_io_read += trx->io_read;
-+ current_thd->innodb_io_reads_wait_timer += trx->io_reads_wait_timer;
-+ current_thd->innodb_lock_que_wait_timer += trx->lock_que_wait_timer;
-+ current_thd->innodb_innodb_que_wait_timer += trx->innodb_que_wait_timer;
-+ current_thd->innodb_page_access += trx->distinct_page_access;
-+
-+ trx->io_reads = 0;
-+ trx->io_read = 0;
-+ trx->io_reads_wait_timer = 0;
-+ trx->lock_que_wait_timer = 0;
-+ trx->innodb_que_wait_timer = 0;
-+ trx->distinct_page_access = 0;
-+ if (trx->distinct_page_access_hash)
-+ memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
-+
-+ trx->mysql_n_tables_locked = 0;
- prebuilt->used_in_HANDLER = FALSE;
-
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-diff -r 1242d4575291 sql/ha_innodb.h
---- a/sql/ha_innodb.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/ha_innodb.h Tue Jul 28 23:42:44 2009 -0700
-@@ -271,6 +271,8 @@
-
- int innobase_start_trx_and_assign_read_view(THD* thd);
-
-+void innobase_update_var_slow_log();
-+
- /***********************************************************************
- This function is used to prepare X/Open XA distributed transaction */
-
-diff -r 1242d4575291 sql/log.cc
---- a/sql/log.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2289,11 +2289,12 @@
- */
-
- bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-- time_t query_start_arg)
-+ time_t query_start_arg, ulonglong query_start_timer)
- {
- bool error=0;
- time_t current_time;
-- if (!is_open())
-+ ulonglong current_timer;
-+ if (!opt_slow_log || !is_open())
- return 0;
- DBUG_ENTER("MYSQL_LOG::write");
-
-@@ -2303,7 +2304,8 @@
- int tmp_errno=0;
- char buff[80],*end;
- end=buff;
-- if (!(thd->options & OPTION_UPDATE_LOG))
-+ if (!(thd->options & OPTION_UPDATE_LOG) &&
-+ !(thd->slave_thread && opt_log_slow_slave_statements))
- {
- VOID(pthread_mutex_unlock(&LOCK_log));
- DBUG_RETURN(0);
-@@ -2333,22 +2335,72 @@
- if (my_b_printf(&log_file, "# User@Host: %s[%s] @ %s [%s]\n",
- sctx->priv_user ?
- sctx->priv_user : "",
-- sctx->user ? sctx->user : "",
-+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""),
- sctx->host ? sctx->host : "",
- sctx->ip ? sctx->ip : "") ==
- (uint) -1)
- tmp_errno=errno;
- }
-- if (query_start_arg)
-+ if (query_start_timer)
- {
-+ char buf[5][20];
-+ ulonglong current_timer= my_timer(&current_timer, frequency);
-+ snprintf(buf[0], 20, "%.6f", (current_timer ? (current_timer - query_start_timer):0) / 1000000.0);
-+ snprintf(buf[1], 20, "%.6f", (thd->timer_after_lock - query_start_timer) / 1000000.0);
-+ if (!query_length)
-+ {
-+ thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
-+ }
-+
- /* For slow query log */
- if (my_b_printf(&log_file,
-- "# Query_time: %lu Lock_time: %lu Rows_sent: %lu Rows_examined: %lu\n",
-- (ulong) (current_time - query_start_arg),
-- (ulong) (thd->time_after_lock - query_start_arg),
-+ "# Thread_id: %lu Schema: %s\n" \
-+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n",
-+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
-+ buf[0], buf[1],
- (ulong) thd->sent_row_count,
-- (ulong) thd->examined_row_count) == (uint) -1)
-+ (ulong) thd->examined_row_count,
-+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
-+ (ulong) thd->row_count) == (uint) -1)
- tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
-+ my_b_printf(&log_file,
-+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
-+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
-+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
-+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
-+ thd->query_plan_fsort_passes) == (uint) -1)
-+ tmp_errno=errno;
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
-+ {
-+ snprintf(buf[2], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
-+ snprintf(buf[3], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
-+ snprintf(buf[4], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
-+ if (my_b_printf(&log_file,
-+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
-+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
-+ "# InnoDB_pages_distinct: %lu\n",
-+ (ulong) thd->innodb_io_reads,
-+ (ulong) thd->innodb_io_read,
-+ buf[2], buf[3], buf[4],
-+ (ulong) thd->innodb_page_access) == (uint) -1)
-+ tmp_errno=errno;
-+ }
-+ else
-+ {
-+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
-+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
-+ tmp_errno=errno;
-+ }
- }
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
-diff -r 1242d4575291 sql/log_event.cc
---- a/sql/log_event.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/log_event.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2061,6 +2061,7 @@
- /* Execute the query (note that we bypass dispatch_command()) */
- const char* found_semicolon= NULL;
- mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
-+ log_slow_statement(thd);
-
- }
- else
-diff -r 1242d4575291 sql/mysql_priv.h
---- a/sql/mysql_priv.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysql_priv.h Tue Jul 28 23:42:44 2009 -0700
-@@ -507,6 +507,78 @@
-
- #define STRING_BUFFER_USUAL_SIZE 80
-
-+/* Slow log */
-+
-+struct msl_opts
-+{
-+ ulong val;
-+ const char *name;
-+};
-+
-+#define SLOG_V_MICROTIME 1 << 0
-+#define SLOG_V_QUERY_PLAN 1 << 1
-+#define SLOG_V_INNODB 1 << 2
-+/* ... */
-+#define SLOG_V_INVALID 1 << 31
-+#define SLOG_V_NONE SLOG_V_MICROTIME
-+
-+static const struct msl_opts slog_verb[]=
-+{
-+ /* Basic flags */
-+
-+ { SLOG_V_MICROTIME, "microtime" },
-+ { SLOG_V_QUERY_PLAN, "query_plan" },
-+ { SLOG_V_INNODB, "innodb" },
-+
-+ /* End of baisc flags */
-+
-+ { 0, "" },
-+
-+ /* Complex flags */
-+
-+ { SLOG_V_MICROTIME, "minimal" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
-+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
-+
-+ /* End of complex flags */
-+
-+ { SLOG_V_INVALID, (char *)0 }
-+};
-+
-+#define QPLAN_NONE 0
-+#define QPLAN_QC 1 << 0
-+#define QPLAN_QC_NO 1 << 1
-+#define QPLAN_FULL_SCAN 1 << 2
-+#define QPLAN_FULL_JOIN 1 << 3
-+#define QPLAN_TMP_TABLE 1 << 4
-+#define QPLAN_TMP_DISK 1 << 5
-+#define QPLAN_FILESORT 1 << 6
-+#define QPLAN_FILESORT_DISK 1 << 7
-+/* ... */
-+#define QPLAN_MAX 1 << 31
-+
-+#define SLOG_F_QC_NO QPLAN_QC_NO
-+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
-+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
-+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
-+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
-+#define SLOG_F_FILESORT QPLAN_FILESORT
-+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
-+#define SLOG_F_INVALID 1 << 31
-+#define SLOG_F_NONE 0
-+
-+static const struct msl_opts slog_filter[]=
-+{
-+ { SLOG_F_QC_NO, "qc_miss" },
-+ { SLOG_F_FULL_SCAN, "full_scan" },
-+ { SLOG_F_FULL_JOIN, "full_join" },
-+ { SLOG_F_TMP_TABLE, "tmp_table" },
-+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
-+ { SLOG_F_FILESORT, "filesort" },
-+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
-+ { SLOG_F_INVALID, (char *)0 }
-+};
-+
- enum enum_parsing_place
- {
- NO_MATTER,
-@@ -1365,6 +1437,7 @@
- extern bool using_update_log, opt_large_files, server_id_supplied;
- extern bool opt_update_log, opt_bin_log, opt_error_log;
- extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
-+extern char *opt_slow_logname;
- extern bool opt_disable_networking, opt_skip_show_db;
- extern my_bool opt_character_set_client_handshake;
- extern bool volatile abort_loop, shutdown_in_progress, grant_option;
-@@ -1376,7 +1449,8 @@
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
--extern my_bool opt_log_slow_admin_statements;
-+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-+extern my_bool opt_use_global_long_query_time;
- extern my_bool sp_automatic_privileges, opt_noacl;
- extern my_bool opt_old_style_user_limits, trust_function_creators;
- extern uint opt_crash_binlog_innodb;
-diff -r 1242d4575291 sql/mysqld.cc
---- a/sql/mysqld.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/mysqld.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -176,7 +176,6 @@
- static void getvolumeID(BYTE *volumeName);
- #endif /* __NETWARE__ */
-
--
- #ifdef _AIX41
- int initgroups(const char *,unsigned int);
- #endif
-@@ -411,10 +410,13 @@
- my_bool opt_secure_auth= 0;
- char* opt_secure_file_priv= 0;
- my_bool opt_log_slow_admin_statements= 0;
-+my_bool opt_log_slow_slave_statements= 0;
-+my_bool opt_use_global_long_query_time= 0;
- my_bool lower_case_file_system= 0;
- my_bool opt_large_pages= 0;
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
-+char* opt_slow_logname= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -509,6 +511,7 @@
- Ge_creator ge_creator;
- Le_creator le_creator;
-
-+ulonglong frequency= 0;
-
- FILE *bootstrap_file;
- int bootstrap_error;
-@@ -588,7 +591,7 @@
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
- static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
--static char *opt_slow_logname, *opt_tc_heuristic_recover;
-+static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
- static char *opt_bin_logname;
-@@ -3697,6 +3700,8 @@
- unireg_abort(1);
- }
- }
-+ if (!QueryPerformanceFrequency((LARGE_INTEGER *)&frequency))
-+ frequency= 0;
- #endif /* __WIN__ */
-
- if (init_common_variables(MYSQL_CONFIG_NAME,
-@@ -4947,7 +4952,7 @@
- OPT_INTERACTIVE_TIMEOUT, OPT_JOIN_BUFF_SIZE,
- OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
- OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
-- OPT_LONG_QUERY_TIME,
-+ OPT_LONG_QUERY_TIME, OPT_MIN_EXAMINED_ROW_LIMIT,
- OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
- OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
- OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
-@@ -5038,11 +5043,18 @@
- OPT_TIMED_MUTEXES,
- OPT_OLD_STYLE_USER_LIMITS,
- OPT_LOG_SLOW_ADMIN_STATEMENTS,
-+ OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ OPT_LOG_SLOW_RATE_LIMIT,
-+ OPT_LOG_SLOW_VERBOSITY,
-+ OPT_LOG_SLOW_FILTER,
- OPT_TABLE_LOCK_WAIT_TIMEOUT,
- OPT_PLUGIN_DIR,
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_SLOW_LOG,
-+ OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
- OPT_KEEP_FILES_ON_CREATE,
-@@ -5441,10 +5453,19 @@
- (gptr*) &opt_log_slow_admin_statements,
- (gptr*) &opt_log_slow_admin_statements,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-+ {"log-slow-slave-statements", OPT_LOG_SLOW_SLAVE_STATEMENTS,
-+ "Log slow replicated statements to the slow log if it is open.",
-+ (gptr*) &opt_log_slow_slave_statements,
-+ (gptr*) &opt_log_slow_slave_statements,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"log-slow-queries", OPT_SLOW_QUERY_LOG,
- "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.",
- (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
- 0, 0, 0, 0, 0, 0},
-+ {"slow_query_log_file", OPT_SLOW_QUERY_LOG_FILE,
-+ "Log slow queries to given log file. Defaults logging to hostname-slow.log. Must be enabled to activate other slow log options.",
-+ (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
-+ 0, 0, 0, 0, 0, 0},
- {"log-tc", OPT_LOG_TC,
- "Path to transaction coordinator log (used for transactions that affect "
- "more than one storage engine, when binary log is disabled)",
-@@ -5808,6 +5829,9 @@
- "Tells the slave thread to continue replication when a query returns an error from the provided list.",
- 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- #endif
-+ {"slow-query-log", OPT_SLOW_LOG,
-+ "Enable|disable slow query log", (gptr*) &opt_slow_log,
-+ (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"socket", OPT_SOCKET, "Socket file to use for connection.",
- (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-@@ -6110,11 +6134,31 @@
- (gptr*) 0,
- 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
- 1, 100, 0, 1, 0},
-- {"long_query_time", OPT_LONG_QUERY_TIME,
-- "Log all queries that have taken more than long_query_time seconds to execute to file.",
-- (gptr*) &global_system_variables.long_query_time,
-- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
-- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
-+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
-+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
-+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
-+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
-+ (gptr*) &global_system_variables.log_slow_rate_limit,
-+ (gptr*) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
-+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
-+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
-+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
-+ {"long_query_time", OPT_LONG_QUERY_TIME,
-+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
-+ (gptr*) &global_system_variables.long_query_time,
-+ (gptr*) &max_system_variables.long_query_time, 0, GET_MICROTIME,
-+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
-+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
-+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
-+ (gptr*) &global_system_variables.min_examined_row_limit,
-+ (gptr*) &max_system_variables.min_examined_row_limit, 0, GET_ULONG,
-+ REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1L, 0},
-+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
-+ "Control always use global long_query_time or local long_query_time.",
-+ (gptr*) &opt_use_global_long_query_time, (gptr*) &opt_use_global_long_query_time,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
- "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
- (gptr*) &lower_case_table_names,
-@@ -6893,7 +6937,11 @@
- global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
- global_system_variables.old_passwords= 0;
--
-+ global_system_variables.long_query_time = 10000000;
-+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
-+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
-+ global_system_variables.log_slow_filter= SLOG_F_NONE;
-+
- /*
- Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
- when collecting index statistics for MyISAM tables.
-@@ -7364,6 +7412,35 @@
- case OPT_BOOTSTRAP:
- opt_noacl=opt_bootstrap=1;
- break;
-+ case OPT_LOG_SLOW_FILTER:
-+ if ((global_system_variables.log_slow_filter=
-+ msl_flag_resolve_by_name(slog_filter, argument,
-+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LOG_SLOW_VERBOSITY:
-+ if ((global_system_variables.log_slow_verbosity=
-+ msl_flag_resolve_by_name(slog_verb, argument,
-+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
-+ {
-+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
-+ exit(1);
-+ }
-+ break;
-+ case OPT_LONG_QUERY_TIME:
-+ {
-+ double doubleslow = strtod(argument,NULL);
-+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
-+ {
-+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
-+ exit(1);
-+ }
-+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
-+ break;
-+ }
- case OPT_STORAGE_ENGINE:
- {
- if ((enum db_type)((global_system_variables.table_type=
-@@ -7696,10 +7773,14 @@
- if (opt_bdb)
- sql_print_warning("this binary does not contain BDB storage engine");
- #endif
-- if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
-+ if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes ||
-+ opt_log_slow_slave_statements) &&
- !opt_slow_log)
-- sql_print_warning("options --log-slow-admin-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
--
-+ {
-+ sql_print_warning("options --log-slow-admin-statements, --log-slow-slave-statements and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
-+ opt_log_slow_slave_statements= FALSE;
-+ }
-+
- if (argc > 0)
- {
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);
-diff -r 1242d4575291 sql/set_var.cc
---- a/sql/set_var.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -217,9 +217,13 @@
- sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
- &opt_log_queries_not_using_indexes);
- sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
--sys_var_thd_ulong sys_long_query_time("long_query_time",
-+sys_var_thd_microtime sys_long_query_time("long_query_time",
- &SV::long_query_time);
-+sys_var_bool_ptr sys_use_global_long_query_time("use_global_long_query_time",
-+ &opt_use_global_long_query_time);
- sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
-+sys_var_log_slow sys_slow_query_log("slow_query_log", &opt_slow_log);
-+sys_var_const_str_ptr sys_slow_query_log_file("slow_query_log_file", &opt_slow_logname);
- sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
- &SV::low_priority_updates,
- fix_low_priority_updates);
-@@ -283,6 +287,8 @@
- &SV::max_tmp_tables);
- sys_var_long_ptr sys_max_write_lock_count("max_write_lock_count",
- &max_write_lock_count);
-+sys_var_thd_ulong sys_min_examined_row_limit("min_examined_row_limit",
-+ &SV::min_examined_row_limit);
- sys_var_thd_ulong sys_multi_range_count("multi_range_count",
- &SV::multi_range_count);
- sys_var_long_ptr sys_myisam_data_pointer_size("myisam_data_pointer_size",
-@@ -327,6 +333,20 @@
- sys_var_bool_ptr sys_relay_log_purge("relay_log_purge",
- &relay_log_purge);
- #endif
-+sys_var_thd_ulong sys_log_slow_rate_limit("log_slow_rate_limit",
-+ &SV::log_slow_rate_limit);
-+sys_var_thd_msl_flag sys_log_slow_filter("log_slow_filter",
-+ &SV::log_slow_filter,
-+ SLOG_F_NONE,
-+ SLOG_F_NONE,
-+ SLOG_F_INVALID,
-+ slog_filter);
-+sys_var_thd_msl_flag sys_log_slow_verbosity("log_slow_verbosity",
-+ &SV::log_slow_verbosity,
-+ SLOG_V_NONE,
-+ SLOG_V_MICROTIME,
-+ SLOG_V_INVALID,
-+ slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
-@@ -697,6 +717,10 @@
- &sys_log_off,
- &sys_log_queries_not_using_indexes,
- &sys_log_slow,
-+ &sys_log_slow_filter,
-+ &sys_log_slow_rate_limit,
-+ &sys_log_slow_verbosity,
-+ &sys_use_global_long_query_time,
- &sys_log_update,
- &sys_log_warnings,
- &sys_long_query_time,
-@@ -720,6 +744,7 @@
- &sys_max_tmp_tables,
- &sys_max_user_connections,
- &sys_max_write_lock_count,
-+ &sys_min_examined_row_limit,
- &sys_multi_range_count,
- &sys_myisam_data_pointer_size,
- &sys_myisam_max_sort_file_size,
-@@ -773,6 +798,8 @@
- &sys_slave_skip_counter,
- #endif
- &sys_slow_launch_time,
-+ &sys_slow_query_log,
-+ &sys_slow_query_log_file,
- &sys_sort_buffer,
- &sys_sql_big_tables,
- &sys_sql_low_priority_updates,
-@@ -994,8 +1021,11 @@
- {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
- #endif
- {sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
-+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
-+ {sys_log_slow_rate_limit.name, (char*) &sys_log_slow_rate_limit, SHOW_SYS},
-+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
- {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
-- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
-+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
- {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
- {"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
- {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
-@@ -1022,6 +1052,7 @@
- {sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
- {sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
- {sys_max_write_lock_count.name, (char*) &sys_max_write_lock_count,SHOW_SYS},
-+ {sys_min_examined_row_limit.name, (char*) &sys_min_examined_row_limit, SHOW_SYS},
- {sys_multi_range_count.name, (char*) &sys_multi_range_count, SHOW_SYS},
- {sys_myisam_data_pointer_size.name, (char*) &sys_myisam_data_pointer_size, SHOW_SYS},
- {sys_myisam_max_sort_file_size.name, (char*) &sys_myisam_max_sort_file_size,
-@@ -1109,6 +1140,8 @@
- {sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
- #endif
- {sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
-+ {sys_slow_query_log.name, (char*) &sys_slow_query_log, SHOW_SYS},
-+ {sys_slow_query_log_file.name,(char*) &sys_slow_query_log_file, SHOW_SYS},
- #ifdef HAVE_SYS_UN_H
- {"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
- #endif
-@@ -1149,6 +1182,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
- {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
-@@ -1777,6 +1811,17 @@
- }
-
-
-+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
-+{
-+ if (var->value->result_type() == DECIMAL_RESULT)
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
-+ else
-+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
-+
-+ return 0;
-+}
-+
-+
- bool sys_var_thd_bool::update(THD *thd, set_var *var)
- {
- if (var->type == OPT_GLOBAL)
-@@ -1933,6 +1978,19 @@
- pthread_mutex_unlock(&LOCK_global_system_variables);
- return new Item_int(value);
- }
-+ case SHOW_MICROTIME:
-+ {
-+ longlong value;
-+ char buff[80];
-+ int len;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ value= *(longlong*) value_ptr(thd, var_type, base);
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
-+ return new Item_float(buff,len);
-+ }
- case SHOW_HA_ROWS:
- {
- ha_rows value;
-@@ -2765,6 +2823,30 @@
- }
-
-
-+bool sys_var_log_slow::update(THD *thd, set_var *var)
-+{
-+ bool ret;
-+
-+ pthread_mutex_lock(&LOCK_global_system_variables);
-+ if (var->save_result.ulong_value)
-+ {
-+ if(!mysql_slow_log.is_open())
-+ {
-+ mysql_slow_log.open_slow_log(opt_slow_logname);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_system_variables);
-+
-+ ret = sys_var_bool_ptr::update(thd, var);
-+
-+#ifdef HAVE_INNOBASE_DB
-+ innobase_update_var_slow_log();
-+#endif
-+
-+ return(ret);
-+}
-+
-+
- #ifdef HAVE_REPLICATION
- bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
- {
-@@ -3549,6 +3631,191 @@
- #endif
- }
-
-+/* Slow log stuff */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
-+{
-+ ulong i;
-+
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)name, len,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ return opts[i].val;
-+ }
-+ return opts[i].val;
-+}
-+
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val)
-+{
-+ const char *p, *e;
-+ ulong val= none_val;
-+
-+ if (!*names_list)
-+ return val;
-+
-+ for (p= e= names_list; ; e++)
-+ {
-+ ulong i;
-+
-+ if (*e != ',' && *e)
-+ continue;
-+ for (i=0; opts[i].name; i++)
-+ {
-+ if (!my_strnncoll(&my_charset_latin1,
-+ (const uchar *)p, e - p,
-+ (const uchar *)opts[i].name, strlen(opts[i].name)))
-+ {
-+ val= val | opts[i].val;
-+ break;
-+ }
-+ }
-+ if (opts[i].val == invalid_val)
-+ return invalid_val;
-+ if (!*e)
-+ break;
-+ p= e + 1;
-+ }
-+ return val;
-+}
-+
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
-+{
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val == val)
-+ return opts[i].name;
-+ }
-+ return "*INVALID*";
-+}
-+
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
-+{
-+ uint offset= 0;
-+
-+ *buf= '\0';
-+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
-+ {
-+ if (opts[i].val & val)
-+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
-+ "%s%s", (offset ? "," : ""), opts[i].name);
-+ }
-+ return buf;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_verbosity
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
-+{
-+ char buff[STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong verb= this->invalid_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ const char *verbosity= msl_option_get_name(this->opts, val);
-+ return (byte *) verbosity;
-+}
-+
-+
-+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
-+/****************************************************************************
-+ Functions to handle log_slow_filter
-+****************************************************************************/
-+
-+/* Based upon sys_var::check_enum() */
-+
-+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
-+{
-+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
-+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
-+
-+ if (var->value->result_type() == STRING_RESULT)
-+ {
-+ ulong filter= this->none_val;
-+ if (!(res=var->value->val_str(&str)) ||
-+ (var->save_result.ulong_value=
-+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
-+ this->invalid_val))) == this->invalid_val)
-+ goto err;
-+ return 0;
-+ }
-+
-+err:
-+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
-+ return 1;
-+}
-+
-+byte *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
-+ LEX_STRING *base)
-+{
-+ ulong val;
-+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
-+ thd->variables.*offset);
-+ msl_flag_get_name(this->flags, this->flags_string, val);
-+ return (byte *) this->flags_string;
-+}
-+
-+
-+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
-+{
-+ if (type == OPT_GLOBAL)
-+ global_system_variables.*offset= (ulong) this->default_val;
-+ else
-+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
-+}
-+
-+
-+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
-+{
-+ if (var->type == OPT_GLOBAL)
-+ global_system_variables.*offset= var->save_result.ulong_value;
-+ else
-+ thd->variables.*offset= var->save_result.ulong_value;
-+ return 0;
-+}
-+
- /****************************************************************************
- Functions to handle table_type
- ****************************************************************************/
-diff -r 1242d4575291 sql/set_var.h
---- a/sql/set_var.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/set_var.h Tue Jul 28 23:42:44 2009 -0700
-@@ -132,6 +132,7 @@
- };
-
-
-+
- class sys_var_ulonglong_ptr :public sys_var
- {
- public:
-@@ -168,6 +169,13 @@
- bool check_update_type(Item_result type) { return 0; }
- };
-
-+class sys_var_log_slow :public sys_var_bool_ptr
-+{
-+public:
-+ sys_var_log_slow(const char *name_arg, my_bool *value_arg)
-+ :sys_var_bool_ptr(name_arg, value_arg) {}
-+ bool update(THD *thd, set_var *var);
-+};
-
- class sys_var_bool_const_ptr : public sys_var
- {
-@@ -340,7 +348,6 @@
- }
- };
-
--
- class sys_var_thd_ulong :public sys_var_thd
- {
- sys_check_func check_func;
-@@ -360,7 +367,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ha_rows :public sys_var_thd
- {
- public:
-@@ -378,7 +384,6 @@
- byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
- };
-
--
- class sys_var_thd_ulonglong :public sys_var_thd
- {
- public:
-@@ -407,6 +412,19 @@
- }
- };
-
-+class sys_var_thd_microtime :public sys_var_thd_ulonglong
-+{
-+public:
-+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
-+ :sys_var_thd_ulonglong(name_arg, offset_arg)
-+ {}
-+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
-+ bool check(THD *thd, set_var *var);
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != INT_RESULT && type != DECIMAL_RESULT;
-+ }
-+};
-
- class sys_var_thd_bool :public sys_var_thd
- {
-@@ -478,6 +496,66 @@
- };
-
-
-+class sys_var_thd_msl_option :public sys_var_thd
-+{
-+protected:
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *opts;
-+public:
-+ sys_var_thd_msl_option(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *opts_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ opts(opts_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
-+
-+class sys_var_thd_msl_flag :public sys_var_thd
-+{
-+protected:
-+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
-+ ulong SV::*offset;
-+ const ulong none_val;
-+ const ulong default_val;
-+ const ulong invalid_val;
-+ const struct msl_opts *flags;
-+public:
-+ sys_var_thd_msl_flag(const char *name_arg, ulong SV::*offset_arg,
-+ const ulong none_val_arg,
-+ const ulong default_val_arg,
-+ const ulong invalid_val_arg,
-+ const struct msl_opts *flags_arg)
-+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
-+ default_val(default_val_arg), invalid_val(invalid_val_arg),
-+ flags(flags_arg)
-+ {}
-+ bool check(THD *thd, set_var *var);
-+ SHOW_TYPE show_type() { return SHOW_CHAR; }
-+ bool check_update_type(Item_result type)
-+ {
-+ return type != STRING_RESULT; /* Only accept strings */
-+ }
-+ void set_default(THD *thd, enum_var_type type);
-+ bool update(THD *thd, set_var *var);
-+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
-+};
-+
- class sys_var_thd_storage_engine :public sys_var_thd
- {
- protected:
-@@ -1109,3 +1187,11 @@
- bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
- void delete_elements(I_List<NAMED_LIST> *list,
- void (*free_element)(const char*, gptr));
-+
-+/* Slow log functions */
-+
-+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
-+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
-+ const ulong none_val, const ulong invalid_val);
-+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
-+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
-diff -r 1242d4575291 sql/slave.cc
---- a/sql/slave.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/slave.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -2983,6 +2983,12 @@
- + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */
- thd->slave_thread = 1;
- set_slave_thread_options(thd);
-+ if (opt_log_slow_slave_statements)
-+ {
-+ thd->enable_slow_log= TRUE;
-+ /* Slave thread is excluded from rate limiting the slow log writes. */
-+ thd->write_to_slow_log= TRUE;
-+ }
- thd->client_capabilities = CLIENT_LOCAL_FILES;
- thd->real_id=pthread_self();
- pthread_mutex_lock(&LOCK_thread_count);
-diff -r 1242d4575291 sql/sql_cache.cc
---- a/sql/sql_cache.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_cache.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1402,6 +1402,7 @@
-
- thd->limit_found_rows = query->found_rows();
- thd->status_var.last_query_cost= 0.0;
-+ thd->query_plan_flags|= QPLAN_QC;
-
- BLOCK_UNLOCK_RD(query_block);
- DBUG_RETURN(1); // Result sent to client
-@@ -1409,6 +1410,7 @@
- err_unlock:
- STRUCT_UNLOCK(&structure_guard_mutex);
- err:
-+ thd->query_plan_flags|= QPLAN_QC_NO;
- DBUG_RETURN(0); // Query was not cached
- }
-
-diff -r 1242d4575291 sql/sql_class.cc
---- a/sql/sql_class.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -190,7 +190,7 @@
- table_map_for_update(0),
- global_read_lock(0), is_fatal_error(0),
- transaction_rollback_request(0), is_fatal_sub_stmt_error(0),
-- rand_used(0), time_zone_used(0),
-+ rand_used(0), time_zone_used(0), user_timer(0),
- last_insert_id_used(0), last_insert_id_used_bin_log(0), insert_id_used(0),
- clear_next_insert_id(0), in_lock_tables(0), bootstrap(0),
- derived_tables_processing(FALSE), spcont(NULL),
-@@ -2251,6 +2251,12 @@
- backup->cuted_fields= cuted_fields;
- backup->client_capabilities= client_capabilities;
- backup->savepoints= transaction.savepoints;
-+ backup->innodb_io_reads= innodb_io_reads;
-+ backup->innodb_io_read= innodb_io_read;
-+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+ backup->innodb_page_access= innodb_page_access;
-
- if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
- options&= ~OPTION_BIN_LOG;
-@@ -2267,7 +2273,13 @@
- sent_row_count= 0;
- cuted_fields= 0;
- transaction.savepoints= 0;
--
-+ innodb_io_reads= 0;
-+ innodb_io_read= 0;
-+ innodb_io_reads_wait_timer= 0;
-+ innodb_lock_que_wait_timer= 0;
-+ innodb_innodb_que_wait_timer= 0;
-+ innodb_page_access= 0;
-+
- /* Surpress OK packets in case if we will execute statements */
- net.no_send_ok= TRUE;
- }
-@@ -2320,6 +2332,12 @@
- */
- examined_row_count+= backup->examined_row_count;
- cuted_fields+= backup->cuted_fields;
-+ innodb_io_reads+= backup->innodb_io_reads;
-+ innodb_io_read+= backup->innodb_io_read;
-+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+ innodb_page_access+= backup->innodb_page_access;
- }
-
-
-diff -r 1242d4575291 sql/sql_class.h
---- a/sql/sql_class.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_class.h Tue Jul 28 23:42:44 2009 -0700
-@@ -43,6 +43,7 @@
- extern char internal_table_name[2];
- extern char empty_c_string[1];
- extern const char **errmesg;
-+extern ulonglong frequency;
-
- #define TC_LOG_PAGE_SIZE 8192
- #define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
-@@ -321,7 +322,7 @@
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-- time_t query_start=0);
-+ time_t query_start=0, ulonglong query_start_timer=0);
- bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
-
-@@ -527,13 +528,14 @@
- ulong auto_increment_increment, auto_increment_offset;
- ulong bulk_insert_buff_size;
- ulong join_buff_size;
-- ulong long_query_time;
-+ ulonglong long_query_time;
- ulong max_allowed_packet;
- ulong max_error_count;
- ulong max_length_for_sort_data;
- ulong max_sort_length;
- ulong max_tmp_tables;
- ulong max_insert_delayed_threads;
-+ ulong min_examined_row_limit;
- ulong multi_range_count;
- ulong myisam_repair_threads;
- ulong myisam_sort_buff_size;
-@@ -549,10 +551,13 @@
- ulong preload_buff_size;
- ulong profiling_history_size;
- ulong query_cache_type;
-+ ulong log_slow_rate_limit;
- ulong read_buff_size;
- ulong read_rnd_buff_size;
- ulong div_precincrement;
- ulong sortbuff_size;
-+ ulong log_slow_filter;
-+ ulong log_slow_verbosity;
- ulong table_type;
- ulong tx_isolation;
- ulong completion_type;
-@@ -1129,6 +1134,12 @@
- uint in_sub_stmt;
- bool enable_slow_log, insert_id_used, clear_next_insert_id;
- bool last_insert_id_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
- my_bool no_send_ok;
- SAVEPOINT *savepoints;
- };
-@@ -1185,6 +1196,11 @@
- class THD :public Statement,
- public Open_tables_state
- {
-+private:
-+ inline ulonglong query_start_timer() { return start_timer; }
-+ inline void set_timer() { if (user_timer) start_timer=timer_after_lock=user_timer; else timer_after_lock=my_timer(&start_timer, frequency); }
-+ inline void end_timer() { my_timer(&start_timer, frequency); }
-+ inline void lock_timer() { my_timer(&timer_after_lock, frequency); }
- public:
- /*
- Constant for THD::where initialization in the beginning of every query.
-@@ -1293,10 +1309,24 @@
- */
- const char *where;
- time_t start_time,time_after_lock,user_time;
-+ ulonglong start_timer,timer_after_lock, user_timer;
- time_t connect_time,thr_create_time; // track down slow pthread_create
- thr_lock_type update_lock_default;
- Delayed_insert *di;
-
-+ bool write_to_slow_log;
-+
-+ bool innodb_was_used;
-+ ulong innodb_io_reads;
-+ ulonglong innodb_io_read;
-+ ulong innodb_io_reads_wait_timer;
-+ ulong innodb_lock_que_wait_timer;
-+ ulong innodb_innodb_que_wait_timer;
-+ ulong innodb_page_access;
-+
-+ ulong query_plan_flags;
-+ ulong query_plan_fsort_passes;
-+
- /* <> 0 if we are inside of trigger or stored function. */
- uint in_sub_stmt;
-
-@@ -1696,11 +1726,11 @@
- sql_print_information("time() failed with %d", errno);
- }
-
-- inline time_t query_start() { query_start_used=1; return start_time; }
-- inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-- inline void end_time() { safe_time(&start_time); }
-- inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; }
-- inline void lock_time() { safe_time(&time_after_lock); }
-+ inline time_t query_start() { query_start_timer(); query_start_used=1; return start_time; }
-+ inline void set_time() { set_timer(); if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
-+ inline void end_time() { end_timer(); safe_time(&start_time); }
-+ inline void set_time(time_t t) { set_timer(); time_after_lock=start_time=user_time=t; }
-+ inline void lock_time() { lock_timer(); safe_time(&time_after_lock); }
- inline void insert_id(ulonglong id_arg)
- {
- last_insert_id= id_arg;
-diff -r 1242d4575291 sql/sql_parse.cc
---- a/sql/sql_parse.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_parse.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -20,6 +20,7 @@
- #include <m_ctype.h>
- #include <myisam.h>
- #include <my_dir.h>
-+#include <my_time.h>
-
- #ifdef HAVE_INNOBASE_DB
- #include "ha_innodb.h"
-@@ -1227,6 +1228,15 @@
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- my_net_set_write_timeout(net, thd->variables.net_write_timeout);
-
-+ /*
-+ If rate limiting of slow log writes is enabled, decide whether to log this
-+ new thread's queries or not. Uses extremely simple algorithm. :)
-+ */
-+ thd->write_to_slow_log= FALSE;
-+ if (thd->variables.log_slow_rate_limit <= 1 ||
-+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
-+ thd->write_to_slow_log= TRUE;
-+
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
- {
-@@ -2353,28 +2363,57 @@
- return; // Don't set time for sub stmt
-
- start_of_query= thd->start_time;
-- thd->end_time(); // Set start time
-+ ulonglong start_of_query_timer= thd->start_timer;
-+ thd->end_time(); // Set start timea
-+
-+
-+ /* Follow the slow log filter configuration. */
-+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
-+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
-+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
-+ (thd->query_plan_flags & QPLAN_QC))))
-+ return;
-+
-+ /*
-+ Low long_query_time value most likely means user is debugging stuff and even
-+ though some thread's queries are not supposed to be logged b/c of the rate
-+ limit, if one of them takes long enough (>= 1 second) it will be sensible
-+ to make an exception and write to slow log anyway.
-+ */
-+
-+ if (opt_use_global_long_query_time)
-+ thd->variables.long_query_time = global_system_variables.long_query_time;
-+
-+ /* Do not log this thread's queries due to rate limiting. */
-+ if (thd->write_to_slow_log != TRUE
-+ && (thd->variables.long_query_time >= 1000000
-+ || (ulong) (thd->start_timer - thd->timer_after_lock) < 1000000))
-+ return;
-+
-
- /*
- Do not log administrative statements unless the appropriate option is
- set; do not log into slow log if reading from backup.
- */
-- if (thd->enable_slow_log && !thd->user_time)
-+ if (thd->enable_slow_log &&
-+ (!thd->user_time || (thd->slave_thread && opt_log_slow_slave_statements))
-+ )
-+
- {
- thd_proc_info(thd, "logging slow query");
-
-- if ((thd->start_time > thd->time_after_lock &&
-- (ulong) (thd->start_time - thd->time_after_lock) >
-- thd->variables.long_query_time) ||
-- ((thd->server_status &
-- (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-- opt_log_queries_not_using_indexes &&
-- /* == SQLCOM_END unless this is a SHOW command */
-- thd->lex->orig_sql_command == SQLCOM_END))
-+ if (((ulong) (thd->start_timer - thd->timer_after_lock) >=
-+ thd->variables.long_query_time ||
-+ (thd->server_status &
-+ (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
-+ opt_log_queries_not_using_indexes &&
-+ /* == SQLCOM_END unless this is a SHOW command */
-+ thd->lex->orig_sql_command == SQLCOM_END) &&
-+ thd->examined_row_count >= thd->variables.min_examined_row_limit)
- {
- thd_proc_info(thd, "logging slow query");
- thd->status_var.long_query_count++;
-- mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
-+ mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query, start_of_query_timer);
- }
- }
- }
-@@ -2669,6 +2708,8 @@
- context.resolve_in_table_list_only((TABLE_LIST*)select_lex->
- table_list.first);
-
-+ /* Reset the counter at all cases for the extended slow query log */
-+ thd->row_count= 1;
- /*
- Reset warning count for each query that uses tables
- A better approach would be to reset this for any commands
-@@ -6203,6 +6244,15 @@
- thd->total_warn_count=0; // Warnings for this query
- thd->rand_used= 0;
- thd->sent_row_count= thd->examined_row_count= 0;
-+ thd->innodb_was_used= FALSE;
-+ thd->innodb_io_reads= 0;
-+ thd->innodb_io_read= 0;
-+ thd->innodb_io_reads_wait_timer= 0;
-+ thd->innodb_lock_que_wait_timer= 0;
-+ thd->innodb_innodb_que_wait_timer= 0;
-+ thd->innodb_page_access= 0;
-+ thd->query_plan_flags= QPLAN_NONE;
-+ thd->query_plan_fsort_passes= 0;
- }
- DBUG_VOID_RETURN;
- }
-diff -r 1242d4575291 sql/sql_select.cc
---- a/sql/sql_select.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_select.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -6272,8 +6272,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_scan_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
-+ }
- }
- }
- else
-@@ -6288,8 +6291,11 @@
- {
- join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED;
- if (statistics)
-+ {
- statistic_increment(join->thd->status_var.select_full_join_count,
- &LOCK_status);
-+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
-+ }
- }
- }
- if (!table->no_keyread)
-@@ -9350,6 +9356,7 @@
- (ulong) rows_limit,test(group)));
-
- statistic_increment(thd->status_var.created_tmp_tables, &LOCK_status);
-+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
-
- if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES))
- temp_pool_slot = bitmap_set_next(&temp_pool);
-@@ -10210,6 +10217,7 @@
- }
- statistic_increment(table->in_use->status_var.created_tmp_disk_tables,
- &LOCK_status);
-+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
- table->s->db_record_offset= 1;
- DBUG_RETURN(0);
- err:
-diff -r 1242d4575291 sql/sql_show.cc
---- a/sql/sql_show.cc Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/sql_show.cc Tue Jul 28 23:42:44 2009 -0700
-@@ -1560,6 +1560,12 @@
- case SHOW_LONGLONG:
- end= longlong10_to_str(*(longlong*) value, buff, 10);
- break;
-+ case SHOW_MICROTIME:
-+ show_type= ((sys_var*) value)->show_type();
-+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
-+ &null_lex_str);
-+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
-+ break;
- case SHOW_HA_ROWS:
- end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
- break;
-diff -r 1242d4575291 sql/structs.h
---- a/sql/structs.h Tue Jul 28 23:39:12 2009 -0700
-+++ b/sql/structs.h Tue Jul 28 23:42:44 2009 -0700
-@@ -168,8 +168,8 @@
- enum SHOW_TYPE
- {
- SHOW_UNDEF,
-- SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-- SHOW_DOUBLE_STATUS,
-+ SHOW_LONG, SHOW_LONGLONG, SHOW_MICROTIME, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
-+ SHOW_DOUBLE_STATUS,
- SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUERIES,
- SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
- SHOW_VARS,
diff --git a/percona/5.0.87-b20-20100217/mirror_binlog.patch b/percona/5.0.87-b20-20100217/mirror_binlog.patch
deleted file mode 100644
index d52e806..0000000
--- a/percona/5.0.87-b20-20100217/mirror_binlog.patch
+++ /dev/null
@@ -1,2694 +0,0 @@
-diff -r 66cc9e0a6768 mysql-test/lib/mtr_cases.pl
---- a/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/lib/mtr_cases.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -334,6 +334,10 @@
-
- $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
-
-+ if ( $tname eq 'rpl_mirror_binlog' )
-+ {
-+ $tinfo->{'slave_num'}= 3;
-+ }
- }
-
- if ( defined mtr_match_prefix($tname,"federated") )
-@@ -344,15 +348,20 @@
-
- my $master_opt_file= "$testdir/$tname-master.opt";
- my $slave_opt_file= "$testdir/$tname-slave.opt";
-- my $slave_mi_file= "$testdir/$tname.slave-mi";
-+ my $slave_mi_files= ["$testdir/$tname.slave-mi",
-+ "$testdir/$tname.1.slave-mi",
-+ "$testdir/$tname.2.slave-mi"];
- my $master_sh= "$testdir/$tname-master.sh";
- my $slave_sh= "$testdir/$tname-slave.sh";
- my $disabled_file= "$testdir/$tname.disabled";
- my $im_opt_file= "$testdir/$tname-im.opt";
-
-- $tinfo->{'master_opt'}= [];
-- $tinfo->{'slave_opt'}= [];
-- $tinfo->{'slave_mi'}= [];
-+ $tinfo->{'master_opt'}= [];
-+ $tinfo->{'slave_opt'}= [];
-+ $tinfo->{'slave_mi'}= {};
-+ $tinfo->{'slave_mi'}{0}= [];
-+ $tinfo->{'slave_mi'}{1}= [];
-+ $tinfo->{'slave_mi'}{2}= [];
-
- if ( -f $master_opt_file )
- {
-@@ -427,9 +436,14 @@
- push(@{$tinfo->{'slave_opt'}}, @$slave_opt);
- }
-
-- if ( -f $slave_mi_file )
-+ my $mi_idx= 0;
-+ foreach my $slave_mi_file ( @$slave_mi_files )
- {
-- $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file);
-+ if ( -f $slave_mi_file )
-+ {
-+ $tinfo->{'slave_mi'}{$mi_idx}= mtr_get_opts_from_file($slave_mi_file);
-+ }
-+ $mi_idx+= 1;
- }
-
- if ( -f $master_sh )
-diff -r 66cc9e0a6768 mysql-test/mysql-test-run.pl
---- a/mysql-test/mysql-test-run.pl Thu Dec 04 21:37:12 2008 -0800
-+++ b/mysql-test/mysql-test-run.pl Thu Dec 04 21:46:15 2008 -0800
-@@ -275,6 +275,7 @@
- our $opt_stress_test_file= "";
-
- our $opt_warnings;
-+our $opt_slave_innodb= 0;
-
- our $opt_skip_ndbcluster= 0;
- our $opt_skip_ndbcluster_slave= 0;
-@@ -299,6 +300,8 @@
- our $used_binlog_format;
- our $used_default_engine;
- our $debug_compiled_binaries;
-+
-+our $current_testname= "";
-
- our %mysqld_variables;
-
-@@ -645,6 +648,7 @@
- 'testcase-timeout=i' => \$opt_testcase_timeout,
- 'suite-timeout=i' => \$opt_suite_timeout,
- 'warnings|log-warnings' => \$opt_warnings,
-+ 'slave-innodb' => \$opt_slave_innodb,
-
- # Options which are no longer used
- (map { $_ => \&warn_about_removed_option } @removed_options),
-@@ -1001,6 +1005,14 @@
- {
- $ENV{'BIG_TEST'}= 1;
- }
-+
-+ # --------------------------------------------------------------------------
-+ # Big test flags
-+ # --------------------------------------------------------------------------
-+ if ( $opt_big_test )
-+ {
-+ $ENV{'BIG_TEST'}= 1;
-+ }
-
- # --------------------------------------------------------------------------
- # Gcov flag
-@@ -1885,7 +1897,9 @@
- $ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
- $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
- $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
-+ $ENV{'SLAVE_MYSOCK1'}= $slave->[1]->{'path_sock'};
- $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
-+ $ENV{'SLAVE_MYSOCK2'}= $slave->[2]->{'path_sock'};
- $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'};
- $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'};
-
-@@ -2375,6 +2389,8 @@
- if ( ! $glob_win32 )
- {
- symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
-+ my @a = ("chmod", "-R", "o+r", "$glob_mysql_test_dir/std_data");
-+ system(@a) == 0 or die "system @ failed: $?"
- }
- else
- {
-@@ -3466,6 +3482,8 @@
- $ENV{'TZ'}= $tinfo->{'timezone'};
- mtr_verbose("Setting timezone: $tinfo->{'timezone'}");
-
-+ $current_testname= $tinfo->{'name'};
-+
- my $master_restart= run_testcase_need_master_restart($tinfo);
- my $slave_restart= run_testcase_need_slave_restart($tinfo);
-
-@@ -3881,7 +3899,8 @@
- unless $mysqld->{'type'} eq 'slave';
-
- mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
-- if (! ( $opt_skip_slave_binlog || $skip_binlog ))
-+
-+ if (! ($opt_skip_slave_binlog or ($current_testname eq 'rpl_mirror_binlog')) )
- {
- mtr_add_arg($args, "%s--log-bin=%s/log/slave%s-bin", $prefix,
- $opt_vardir, $sidx); # FIXME use own dir for binlogs
-@@ -4568,7 +4587,7 @@
- if ( ! $slave->[$idx]->{'pid'} )
- {
- mysqld_start($slave->[$idx],$tinfo->{'slave_opt'},
-- $tinfo->{'slave_mi'});
-+ $tinfo->{'slave_mi'}{$idx});
-
- }
- }
-@@ -4580,7 +4599,6 @@
- # Wait for clusters to start
- foreach my $cluster (@{$clusters})
- {
--
- next if !$cluster->{'pid'};
-
- if (ndbcluster_wait_started($cluster, ""))
-@@ -5179,6 +5197,7 @@
- skip-im Don't start IM, and skip the IM test cases
- big-test Set the environment variable BIG_TEST, which can be
- checked from test cases.
-+
-
- Options that specify ports
-
-diff -r 66cc9e0a6768 mysql-test/r/rpl_mirror_binlog.result
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/r/rpl_mirror_binlog.result Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,441 @@
-+stop slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+reset master;
-+reset slave;
-+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-+start slave;
-+drop table if exists t1;
-+create table t1(n int) engine = InnoDB;
-+insert into t1 values (300);
-+insert into t1 values (299);
-+insert into t1 values (298);
-+insert into t1 values (297);
-+insert into t1 values (296);
-+insert into t1 values (295);
-+insert into t1 values (294);
-+insert into t1 values (293);
-+insert into t1 values (292);
-+insert into t1 values (291);
-+insert into t1 values (290);
-+insert into t1 values (289);
-+insert into t1 values (288);
-+insert into t1 values (287);
-+insert into t1 values (286);
-+insert into t1 values (285);
-+insert into t1 values (284);
-+insert into t1 values (283);
-+insert into t1 values (282);
-+insert into t1 values (281);
-+insert into t1 values (280);
-+insert into t1 values (279);
-+insert into t1 values (278);
-+insert into t1 values (277);
-+insert into t1 values (276);
-+insert into t1 values (275);
-+insert into t1 values (274);
-+insert into t1 values (273);
-+insert into t1 values (272);
-+insert into t1 values (271);
-+insert into t1 values (270);
-+insert into t1 values (269);
-+insert into t1 values (268);
-+insert into t1 values (267);
-+insert into t1 values (266);
-+insert into t1 values (265);
-+insert into t1 values (264);
-+insert into t1 values (263);
-+insert into t1 values (262);
-+insert into t1 values (261);
-+insert into t1 values (260);
-+insert into t1 values (259);
-+insert into t1 values (258);
-+insert into t1 values (257);
-+insert into t1 values (256);
-+insert into t1 values (255);
-+insert into t1 values (254);
-+insert into t1 values (253);
-+insert into t1 values (252);
-+insert into t1 values (251);
-+insert into t1 values (250);
-+insert into t1 values (249);
-+insert into t1 values (248);
-+insert into t1 values (247);
-+insert into t1 values (246);
-+insert into t1 values (245);
-+insert into t1 values (244);
-+insert into t1 values (243);
-+insert into t1 values (242);
-+insert into t1 values (241);
-+insert into t1 values (240);
-+insert into t1 values (239);
-+insert into t1 values (238);
-+insert into t1 values (237);
-+insert into t1 values (236);
-+insert into t1 values (235);
-+insert into t1 values (234);
-+insert into t1 values (233);
-+insert into t1 values (232);
-+insert into t1 values (231);
-+insert into t1 values (230);
-+insert into t1 values (229);
-+insert into t1 values (228);
-+insert into t1 values (227);
-+insert into t1 values (226);
-+insert into t1 values (225);
-+insert into t1 values (224);
-+insert into t1 values (223);
-+insert into t1 values (222);
-+insert into t1 values (221);
-+insert into t1 values (220);
-+insert into t1 values (219);
-+insert into t1 values (218);
-+insert into t1 values (217);
-+insert into t1 values (216);
-+insert into t1 values (215);
-+insert into t1 values (214);
-+insert into t1 values (213);
-+insert into t1 values (212);
-+insert into t1 values (211);
-+insert into t1 values (210);
-+insert into t1 values (209);
-+insert into t1 values (208);
-+insert into t1 values (207);
-+insert into t1 values (206);
-+insert into t1 values (205);
-+insert into t1 values (204);
-+insert into t1 values (203);
-+insert into t1 values (202);
-+insert into t1 values (201);
-+insert into t1 values (200);
-+insert into t1 values (199);
-+insert into t1 values (198);
-+insert into t1 values (197);
-+insert into t1 values (196);
-+insert into t1 values (195);
-+insert into t1 values (194);
-+insert into t1 values (193);
-+insert into t1 values (192);
-+insert into t1 values (191);
-+insert into t1 values (190);
-+insert into t1 values (189);
-+insert into t1 values (188);
-+insert into t1 values (187);
-+insert into t1 values (186);
-+insert into t1 values (185);
-+insert into t1 values (184);
-+insert into t1 values (183);
-+insert into t1 values (182);
-+insert into t1 values (181);
-+insert into t1 values (180);
-+insert into t1 values (179);
-+insert into t1 values (178);
-+insert into t1 values (177);
-+insert into t1 values (176);
-+insert into t1 values (175);
-+insert into t1 values (174);
-+insert into t1 values (173);
-+insert into t1 values (172);
-+insert into t1 values (171);
-+insert into t1 values (170);
-+insert into t1 values (169);
-+insert into t1 values (168);
-+insert into t1 values (167);
-+insert into t1 values (166);
-+insert into t1 values (165);
-+insert into t1 values (164);
-+insert into t1 values (163);
-+insert into t1 values (162);
-+insert into t1 values (161);
-+insert into t1 values (160);
-+insert into t1 values (159);
-+insert into t1 values (158);
-+insert into t1 values (157);
-+insert into t1 values (156);
-+insert into t1 values (155);
-+insert into t1 values (154);
-+insert into t1 values (153);
-+insert into t1 values (152);
-+insert into t1 values (151);
-+insert into t1 values (150);
-+insert into t1 values (149);
-+insert into t1 values (148);
-+insert into t1 values (147);
-+insert into t1 values (146);
-+insert into t1 values (145);
-+insert into t1 values (144);
-+insert into t1 values (143);
-+insert into t1 values (142);
-+insert into t1 values (141);
-+insert into t1 values (140);
-+insert into t1 values (139);
-+insert into t1 values (138);
-+insert into t1 values (137);
-+insert into t1 values (136);
-+insert into t1 values (135);
-+insert into t1 values (134);
-+insert into t1 values (133);
-+insert into t1 values (132);
-+insert into t1 values (131);
-+insert into t1 values (130);
-+insert into t1 values (129);
-+insert into t1 values (128);
-+insert into t1 values (127);
-+insert into t1 values (126);
-+insert into t1 values (125);
-+insert into t1 values (124);
-+insert into t1 values (123);
-+insert into t1 values (122);
-+insert into t1 values (121);
-+insert into t1 values (120);
-+insert into t1 values (119);
-+insert into t1 values (118);
-+insert into t1 values (117);
-+insert into t1 values (116);
-+insert into t1 values (115);
-+insert into t1 values (114);
-+insert into t1 values (113);
-+insert into t1 values (112);
-+insert into t1 values (111);
-+insert into t1 values (110);
-+insert into t1 values (109);
-+insert into t1 values (108);
-+insert into t1 values (107);
-+insert into t1 values (106);
-+insert into t1 values (105);
-+insert into t1 values (104);
-+insert into t1 values (103);
-+insert into t1 values (102);
-+insert into t1 values (101);
-+insert into t1 values (100);
-+insert into t1 values (99);
-+insert into t1 values (98);
-+insert into t1 values (97);
-+insert into t1 values (96);
-+insert into t1 values (95);
-+insert into t1 values (94);
-+insert into t1 values (93);
-+insert into t1 values (92);
-+insert into t1 values (91);
-+insert into t1 values (90);
-+insert into t1 values (89);
-+insert into t1 values (88);
-+insert into t1 values (87);
-+insert into t1 values (86);
-+insert into t1 values (85);
-+insert into t1 values (84);
-+insert into t1 values (83);
-+insert into t1 values (82);
-+insert into t1 values (81);
-+insert into t1 values (80);
-+insert into t1 values (79);
-+insert into t1 values (78);
-+insert into t1 values (77);
-+insert into t1 values (76);
-+insert into t1 values (75);
-+insert into t1 values (74);
-+insert into t1 values (73);
-+insert into t1 values (72);
-+insert into t1 values (71);
-+insert into t1 values (70);
-+insert into t1 values (69);
-+insert into t1 values (68);
-+insert into t1 values (67);
-+insert into t1 values (66);
-+insert into t1 values (65);
-+insert into t1 values (64);
-+insert into t1 values (63);
-+insert into t1 values (62);
-+insert into t1 values (61);
-+insert into t1 values (60);
-+insert into t1 values (59);
-+insert into t1 values (58);
-+insert into t1 values (57);
-+insert into t1 values (56);
-+insert into t1 values (55);
-+insert into t1 values (54);
-+insert into t1 values (53);
-+insert into t1 values (52);
-+insert into t1 values (51);
-+insert into t1 values (50);
-+insert into t1 values (49);
-+insert into t1 values (48);
-+insert into t1 values (47);
-+insert into t1 values (46);
-+insert into t1 values (45);
-+insert into t1 values (44);
-+insert into t1 values (43);
-+insert into t1 values (42);
-+insert into t1 values (41);
-+insert into t1 values (40);
-+insert into t1 values (39);
-+insert into t1 values (38);
-+insert into t1 values (37);
-+insert into t1 values (36);
-+insert into t1 values (35);
-+insert into t1 values (34);
-+insert into t1 values (33);
-+insert into t1 values (32);
-+insert into t1 values (31);
-+insert into t1 values (30);
-+insert into t1 values (29);
-+insert into t1 values (28);
-+insert into t1 values (27);
-+insert into t1 values (26);
-+insert into t1 values (25);
-+insert into t1 values (24);
-+insert into t1 values (23);
-+insert into t1 values (22);
-+insert into t1 values (21);
-+insert into t1 values (20);
-+insert into t1 values (19);
-+insert into t1 values (18);
-+insert into t1 values (17);
-+insert into t1 values (16);
-+insert into t1 values (15);
-+insert into t1 values (14);
-+insert into t1 values (13);
-+insert into t1 values (12);
-+insert into t1 values (11);
-+insert into t1 values (10);
-+insert into t1 values (9);
-+insert into t1 values (8);
-+insert into t1 values (7);
-+insert into t1 values (6);
-+insert into t1 values (5);
-+insert into t1 values (4);
-+insert into t1 values (3);
-+insert into t1 values (2);
-+insert into t1 values (1);
-+"The following are SLAVE."
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9306 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000014 2849
-+"The following are SLAVE1."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+300
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+300
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000014 2849 # # master-bin.000014 Yes Yes # 0 0 2849 # None 0 No #
-+"The following are SLAVE."
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication-log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+stop slave;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log';
-+ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+MASTER_SERVER_ID=2,
-+INDEX='replication_log'
-+ WITH BINLOG;
-+MAKE MASTER GRANT SESSION;
-+delete from t1 where n > 250;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+"The following are SLAVE1."
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+"The following are SLAVE2."
-+start slave;
-+select count(distinct n) from t1;
-+count(distinct n)
-+250
-+select min(n) from t1;
-+min(n)
-+1
-+select max(n) from t1;
-+max(n)
-+250
-+show slave status;
-+Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-+Waiting for master to send event 127.0.0.1 root 9308 1 master-bin.000015 189 # # master-bin.000015 Yes Yes # 0 0 189 # None 0 No #
-+drop table t1;
-+drop table t1;
-+"The following are SLAVE."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+"The following are SLAVE2."
-+show master logs;
-+Log_name File_size
-+master-bin.000001 4214
-+master-bin.000002 4212
-+master-bin.000003 4212
-+master-bin.000004 4212
-+master-bin.000005 4212
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+show master status;
-+File Position Binlog_Do_DB Binlog_Ignore_DB
-+master-bin.000015 265
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+Log_name File_size
-+master-bin.000006 4212
-+master-bin.000007 4212
-+master-bin.000008 4212
-+master-bin.000009 4212
-+master-bin.000010 4194
-+master-bin.000011 4190
-+master-bin.000012 4190
-+master-bin.000013 4190
-+master-bin.000014 2849
-+master-bin.000015 265
-+reset master;
-+ERROR HY000: Binlog closed, cannot RESET MASTER
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-master.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-master.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+-O max_binlog_size=4096
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog-slave.opt
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog-slave.opt Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--rpl_mirror_binlog_enabled=1 --log-bin-index=replication_log
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.1.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.1.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=3
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.2.slave-mi
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.2.slave-mi Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,1 @@
-+--master-user=root --master-connect-retry=1 --master-host=127.0.0.1 --master-password="" --master-port=9308 --server-id=4
-diff -r 66cc9e0a6768 mysql-test/t/rpl_mirror_binlog.test
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/mysql-test/t/rpl_mirror_binlog.test Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,119 @@
-+-- source include/master-slave.inc
-+-- source include/have_innodb.inc
-+connect (slave_sec,localhost,root,,test,$SLAVE_MYPORT1,$SLAVE_MYSOCK1);
-+connect (slave_ter,localhost,root,,test,$SLAVE_MYPORT2,$SLAVE_MYSOCK2);
-+
-+connection master;
-+--disable_warnings
-+drop table if exists t1;
-+--enable_warnings
-+create table t1(n int) engine = InnoDB;
-+
-+let $i=300;
-+while ($i)
-+{
-+ eval insert into t1 values ($i);
-+ dec $i;
-+}
-+
-+save_master_pos;
-+
-+connection slave;
-+sync_with_master;
-+
-+echo "The following are SLAVE.";
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+show master status;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+# make the slave the new master
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+# The first 1201 error is caused by running slave.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication-log';
-+stop slave;
-+
-+# The second 1201 error is caused by failover mode.
-+--error 1201
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log';
-+
-+MAKE MASTER REVOKE SESSION WITH KILL;
-+MAKE MASTER MASTER_LOG_FILE='master-bin',
-+ MASTER_SERVER_ID=2,
-+ INDEX='replication_log'
-+ WITH BINLOG;
-+
-+MAKE MASTER GRANT SESSION;
-+
-+delete from t1 where n > 250;
-+save_master_pos;
-+
-+select count(distinct n) from t1;
-+
-+connection slave_sec;
-+echo "The following are SLAVE1.";
-+
-+sync_with_master;
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+start slave;
-+sync_with_master;
-+
-+select count(distinct n) from t1;
-+select min(n) from t1;
-+select max(n) from t1;
-+
-+--replace_column 8 # 9 # 18 # 23 # 33 #
-+show slave status;
-+
-+connection master;
-+drop table t1;
-+
-+connection slave;
-+drop table t1;
-+save_master_pos;
-+
-+connection slave_sec;
-+sync_with_master;
-+
-+connection slave;
-+echo "The following are SLAVE.";
-+
-+show master logs;
-+show master status;
-+
-+
-+connection slave_ter;
-+echo "The following are SLAVE2.";
-+sync_with_master;
-+
-+show master logs;
-+show master status;
-+purge master logs to 'master-bin.000006';
-+show master logs;
-+--error 1186
-+reset master;
-diff -r 66cc9e0a6768 patch_info/mirror_binlog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mirror_binlog.info Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,6 @@
-+File=mirror_binlog.patch
-+Name=Mirroring binary logs on slave
-+Version=V1
-+Author=Google
-+License=GPL
-+Comment=contains FastMaster promotion patch
-diff -r 66cc9e0a6768 sql/Makefile.am
---- a/sql/Makefile.am Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.am Thu Dec 04 21:46:15 2008 -0800
-@@ -68,7 +68,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
- item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \
-@@ -105,7 +105,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-diff -r 66cc9e0a6768 sql/Makefile.in
---- a/sql/Makefile.in Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/Makefile.in Thu Dec 04 21:46:15 2008 -0800
-@@ -152,7 +152,7 @@
- sp_rcontext.$(OBJEXT) sp.$(OBJEXT) sp_cache.$(OBJEXT) \
- parse_file.$(OBJEXT) sql_trigger.$(OBJEXT) \
- ha_example.$(OBJEXT) ha_archive.$(OBJEXT) ha_tina.$(OBJEXT) \
-- ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT)
-+ ha_blackhole.$(OBJEXT) ha_federated.$(OBJEXT) repl_mule.$(OBJEXT)
- mysqld_OBJECTS = $(am_mysqld_OBJECTS)
- mysqld_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
-@@ -516,7 +516,7 @@
- sql_array.h sql_cursor.h \
- examples/ha_example.h ha_archive.h \
- examples/ha_tina.h ha_blackhole.h \
-- ha_federated.h
-+ ha_federated.h repl_mule.h
-
- mysqld_SOURCES = sql_lex.cc sql_handler.cc \
- item.cc item_sum.cc item_buff.cc item_func.cc \
-@@ -554,7 +554,7 @@
- sp_cache.cc parse_file.cc sql_trigger.cc \
- examples/ha_example.cc ha_archive.cc \
- examples/ha_tina.cc ha_blackhole.cc \
-- ha_federated.cc
-+ ha_federated.cc repl_mule.cc
-
- gen_lex_hash_SOURCES = gen_lex_hash.cc
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
-@@ -748,6 +748,7 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/records.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_failsafe.Po@am__quote@
-+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repl_mule.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_var.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slave.Po@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sp.Po@am__quote@
-diff -r 66cc9e0a6768 sql/lex.h
---- a/sql/lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -292,6 +292,7 @@
- { "LONGTEXT", SYM(LONGTEXT)},
- { "LOOP", SYM(LOOP_SYM)},
- { "LOW_PRIORITY", SYM(LOW_PRIORITY)},
-+ { "MAKE", SYM(MAKE_SYM)},
- { "MASTER", SYM(MASTER_SYM)},
- { "MASTER_CONNECT_RETRY", SYM(MASTER_CONNECT_RETRY_SYM)},
- { "MASTER_HOST", SYM(MASTER_HOST_SYM)},
-diff -r 66cc9e0a6768 sql/log.cc
---- a/sql/log.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -79,7 +79,9 @@
-
- bool binlog_init()
- {
-- return !opt_bin_log;
-+ if (!opt_bin_log)
-+ binlog_hton.prepare = NULL;
-+ return 0; /* return !opt_bin_log; */
- }
-
- static int binlog_close_connection(THD *thd)
-@@ -406,6 +408,7 @@
- :bytes_written(0), last_time(0), query_start(0), name(0),
- prepared_xids(0), log_type(LOG_CLOSED), file_id(1), open_count(1),
- write_error(FALSE), inited(FALSE), need_start_event(TRUE),
-+ mule_binlog_(0),
- description_event_for_exec(0), description_event_for_queue(0)
- {
- /*
-@@ -506,7 +509,10 @@
- const char *log_name)
- {
- File index_file_nr= -1;
-- DBUG_ASSERT(!my_b_inited(&index_file));
-+
-+ /* If the index is already opened, do not open it again. */
-+ if (my_b_inited(&index_file))
-+ return FALSE;
-
- /*
- First open of this class instance
-@@ -750,7 +756,7 @@
- if (file >= 0)
- my_close(file,MYF(0));
- end_io_cache(&log_file);
-- end_io_cache(&index_file);
-+ close_index_file();
- safeFree(name);
- log_type= LOG_CLOSED;
- DBUG_RETURN(1);
-@@ -768,7 +774,10 @@
- int MYSQL_LOG::raw_get_current_log(LOG_INFO* linfo)
- {
- strmake(linfo->log_file_name, log_file_name, sizeof(linfo->log_file_name)-1);
-- linfo->pos = my_b_tell(&log_file);
-+ if (!mule_binlog_)
-+ linfo->pos = my_b_tell(&log_file);
-+ else
-+ linfo->pos = my_b_filelength(&log_file);
- return 0;
- }
-
-@@ -935,6 +944,11 @@
- if (need_lock)
- pthread_mutex_lock(&LOCK_index);
- safe_mutex_assert_owner(&LOCK_index);
-+
-+ if (open_index_file(index_file_name, NULL) != 0) {
-+ error = -1;
-+ goto err;
-+ }
-
- /* As the file is flushed, we can't get an error here */
- (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-@@ -1446,18 +1460,19 @@
- SYNOPSIS
- new_file()
- need_lock Set to 1 if caller has not locked LOCK_log
-+ logfile_name the specified log filename.
-
- NOTE
- The new file name is stored last in the index file
- */
-
--void MYSQL_LOG::new_file(bool need_lock)
-+void MYSQL_LOG::new_file(bool need_lock, const char* log_filename)
- {
- char new_name[FN_REFLEN], *new_name_ptr, *old_name;
- enum_log_type save_log_type;
-
- DBUG_ENTER("MYSQL_LOG::new_file");
-- if (!is_open())
-+ if (!is_log_open())
- {
- DBUG_PRINT("info",("log is closed"));
- DBUG_VOID_RETURN;
-@@ -1496,7 +1511,9 @@
- We have to do this here and not in open as we want to store the
- new file name in the current binary log file.
- */
-- if (generate_new_name(new_name, name))
-+ if (log_filename) {
-+ fn_format(new_name,log_filename,mysql_data_home,"",4);
-+ } else if (generate_new_name(new_name, name))
- goto end;
- new_name_ptr=new_name;
-
-@@ -1571,7 +1588,7 @@
- bytes_written+= ev->data_written;
- DBUG_PRINT("info",("max_size: %lu",max_size));
- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+ new_file(0);
-
- err:
- pthread_mutex_unlock(&LOCK_log);
-@@ -1600,8 +1617,14 @@
- bytes_written += len;
- } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
- DBUG_PRINT("info",("max_size: %lu",max_size));
-- if ((uint) my_b_append_tell(&log_file) > max_size)
-- new_file(0);
-+
-+ /* If max_size is BINLOG_NOSWITCH_SIZE, binlog would not switch because
-+ * of file size limit.
-+ */
-+ if (max_size != BINLOG_NOSWITCH_SIZE &&
-+ (uint) my_b_append_tell(&log_file) > max_size) {
-+ new_file(0);
-+ }
-
- err:
- if (!error)
-@@ -2492,6 +2515,17 @@
- DBUG_VOID_RETURN;
- }
-
-+int MYSQL_LOG::flush_log_file() {
-+ return flush_io_cache(&log_file);
-+}
-+
-+int MYSQL_LOG::close_index_file() {
-+ if (my_b_inited(&index_file)) {
-+ end_io_cache(&index_file);
-+ my_close(index_file.file, MYF(0));
-+ }
-+ return 0;
-+}
-
- /*
- Check if a string is a valid number
-diff -r 66cc9e0a6768 sql/log_event.h
---- a/sql/log_event.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/log_event.h Thu Dec 04 21:46:15 2008 -0800
-@@ -94,6 +94,14 @@
- #define LINE_TERM_EMPTY 0x4
- #define LINE_START_EMPTY 0x8
- #define ESCAPED_EMPTY 0x10
-+
-+/* This server-id value is used to indicate a special master-info event
-+ * in relay-log.
-+ * We will enforce in database that replication can not set this value
-+ * as the server-id.
-+ */
-+#define MASTER_INFO_SERVER_ID 0xffffffff
-+
-
- /*****************************************************************************
-
-diff -r 66cc9e0a6768 sql/mysql_priv.h
---- a/sql/mysql_priv.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysql_priv.h Thu Dec 04 21:46:15 2008 -0800
-@@ -462,6 +462,7 @@
- /* BINLOG_DUMP options */
-
- #define BINLOG_DUMP_NON_BLOCK 1
-+#define BINLOG_MIRROR_CLIENT 0x0004
-
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
-@@ -1374,6 +1375,7 @@
- extern const char **errmesg; /* Error messages */
- extern const char *myisam_recover_options_str;
- extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-+extern char *opt_binlog_index_name;
- extern const char * const triggers_file_ext;
- extern const char * const trigname_file_ext;
- extern Eq_creator eq_creator;
-@@ -1875,6 +1877,10 @@
- extern "C" void unireg_abort(int exit_code);
- void kill_delayed_threads(void);
- bool check_stack_overrun(THD *thd, long margin, char *dummy);
-+extern my_bool rpl_mirror_binlog_enabled;
-+extern ulong sync_mirror_binlog_period;
-+extern my_bool rpl_mirror_binlog_no_replicate;
-+extern ulong rpl_mirror_binlog_clients, rpl_mirror_binlog_status;
- #else
- #define unireg_abort(exit_code) DBUG_RETURN(exit_code)
- inline void kill_delayed_threads(void) {}
-diff -r 66cc9e0a6768 sql/mysqld.cc
---- a/sql/mysqld.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/mysqld.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -555,6 +555,7 @@
- pthread_mutex_t LOCK_global_user_client_stats;
- pthread_mutex_t LOCK_global_table_stats;
- pthread_mutex_t LOCK_global_index_stats;
-+pthread_mutex_t LOCK_failover_master;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -584,13 +585,15 @@
- char *master_ssl_key, *master_ssl_cert;
- char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher;
-
-+char *opt_binlog_index_name;
-+
- /* Static variables */
-
- static bool kill_in_progress, segfaulted;
- static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log;
- static int cleanup_done;
- static ulong opt_specialflag, opt_myisam_block_size;
--static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
-+static char *opt_logname, *opt_update_logname;
- static char *opt_tc_heuristic_recover;
- static char *mysql_home_ptr, *pidfile_name_ptr;
- static char **defaults_argv;
-@@ -598,6 +601,32 @@
-
- static my_socket unix_sock,ip_sock;
- struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
-+
-+/* When set, we are inside a failover slave and deny all non-super access */
-+bool failover_deny_access= 0;
-+
-+/* When set, binlog will be mirrored on the replica. */
-+my_bool rpl_mirror_binlog_enabled;
-+
-+/* Sync the mirrored binlog to disk after every #th event. */
-+ulong sync_mirror_binlog_period;
-+
-+/* The fixed size for replication event buffer. Replication event can exceed
-+ * the size.
-+ */
-+//ulong rpl_event_buffer_size;
-+
-+/* This is a mirror binlog status variable on the primary to indicate how many
-+ * mirror binlog servers are connecting.
-+ */
-+ulong rpl_mirror_binlog_clients = 0;
-+
-+/* This indicates whether mirror binlog is working on a replica database. It
-+ * requires:
-+ * . rpl_mirror_binlog_enabled = 1
-+ * . the slave I/O thread is running and mirror binlog is also dumped
-+ */
-+ulong rpl_mirror_binlog_status = 0;
-
- /* OS specific variables */
-
-@@ -1315,6 +1344,7 @@
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
- (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_failover_master);
- (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
- (void) pthread_mutex_destroy(&LOCK_global_table_stats);
- (void) pthread_mutex_destroy(&LOCK_global_index_stats);
-@@ -3164,6 +3194,7 @@
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_failover_master, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
-@@ -3398,39 +3429,8 @@
-
- if (opt_bin_log)
- {
-- char buf[FN_REFLEN];
-- const char *ln;
-- ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
-- if (!opt_bin_logname && !opt_binlog_index_name)
-- {
-- /*
-- User didn't give us info to name the binlog index file.
-- Picking `hostname`-bin.index like did in 4.x, causes replication to
-- fail if the hostname is changed later. So, we would like to instead
-- require a name. But as we don't want to break many existing setups, we
-- only give warning, not error.
-- */
-- sql_print_warning("No argument was provided to --log-bin, and "
-- "--log-bin-index was not used; so replication "
-- "may break when this MySQL server acts as a "
-- "master and has his hostname changed!! Please "
-- "use '--log-bin=%s' to avoid this problem.", ln);
-- }
-- if (ln == buf)
-- {
-- my_free(opt_bin_logname, MYF(MY_ALLOW_ZERO_PTR));
-- opt_bin_logname=my_strdup(buf, MYF(0));
-- }
-- if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln))
-- {
-- unireg_abort(1);
-- }
--
-- /*
-- Used to specify which type of lock we need to use for queries of type
-- INSERT ... SELECT. This will change when we have row level logging.
-- */
-- using_update_log=1;
-+ if (make_master_open_index(&opt_bin_logname, opt_binlog_index_name) != 0)
-+ unireg_abort(1);
- }
-
- if (xid_cache_init())
-@@ -3480,9 +3480,10 @@
- unireg_abort(1);
- }
-
-- if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
-- WRITE_CACHE, 0, max_binlog_size, 0))
-- unireg_abort(1);
-+ if (opt_bin_log &&
-+ make_master(NULL, opt_bin_logname, opt_binlog_index_name, NULL) != 0) {
-+ unireg_abort(1);
-+ }
-
- #ifdef HAVE_REPLICATION
- if (opt_bin_log && expire_logs_days)
-@@ -5098,6 +5098,8 @@
- OPT_INNODB_READ_IO_THREADS,
- OPT_INNODB_WRITE_IO_THREADS,
- OPT_INNODB_ADAPTIVE_HASH_INDEX,
-+ OPT_RPL_MIRROR_BINLOG,
-+ OPT_SYNC_MIRROR_BINLOG,
- OPT_FEDERATED,
- OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
- };
-@@ -5725,6 +5728,11 @@
- {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.",
- (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-+ {"rpl_mirror_binlog_enabled", OPT_RPL_MIRROR_BINLOG,
-+ "1 = support mirroring binlogs. 0 = disable mirroring binlogs",
-+ (gptr*) &rpl_mirror_binlog_enabled,
-+ (gptr*) &rpl_mirror_binlog_enabled, 0, GET_BOOL, NO_ARG,
-+ 0, 0, 1, 0, 1, 0},
- {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).",
- 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- #ifndef TO_BE_DELETED
-@@ -5849,6 +5857,11 @@
- {"symbolic-links", 's', "Enable symbolic link support.",
- (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
- IF_PURIFY(0,1), 0, 0, 0, 0, 0},
-+ {"sync-mirror-binlog", OPT_SYNC_MIRROR_BINLOG,
-+ "Sync the mirrored binlog to disk after every #th event. "
-+ "#=0 (the default) does no sync. Syncing slows MySQL down",
-+ (gptr*) &sync_mirror_binlog_period,
-+ (gptr*) &sync_mirror_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
- {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
- "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.",
- (gptr*) &global_system_variables.sysdate_is_now,
-@@ -6625,6 +6638,7 @@
- {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
- {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_CONST},
- {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
-+ {"Failover_deny_access", (char*) &failover_deny_access, SHOW_LONG},
- {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
- {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
- {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
-diff -r 66cc9e0a6768 sql/repl_mule.cc
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,466 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#include "mysql_priv.h"
-+#include <my_dir.h>
-+#include "slave.h"
-+#include "repl_mule.h"
-+
-+/* max log size: 2GB */
-+#define MAX_LOG_SIZE BINLOG_NOSWITCH_SIZE
-+
-+ReplMule::ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period)
-+ : desc_event_(new Format_description_log_event(BINLOG_VERSION)),
-+ io_thd_(thd), mi_(mi), status_(status), dump_position_(0L),
-+ file_size_(file_size), mule_log_(binlog),
-+ mule_log_sync_period_(sync_period), mule_log_event_counter_(0) {
-+ char llbuf1[22], llbuf2[22];
-+
-+ DBUG_ENTER("ReplMule::ReplMule");
-+
-+ /* Indicate that we are in replication mule mode. */
-+ mule_log_->set_mule_mode();
-+
-+ strmake(curr_log_filename_, mi->master_log_name,
-+ sizeof(curr_log_filename_)-1);
-+ strmake(mule_indexname_, binlog_indexname, sizeof(mule_indexname_)-1);
-+
-+ /* Open the mule log file */
-+ if (!mule_log_->is_log_open()) {
-+ /* Do not open binlog file when master_log_name is not specified. We
-+ * are at the I/O thread initialization time and we do not know what
-+ * filename we are going to dump.
-+ * We wait for the next rotation event to indicate the filename.
-+ */
-+ if (strlen(curr_log_filename_) > 0 &&
-+ mule_log_->open(curr_log_filename_, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("ReplMule: open binlog failed: %s",
-+ curr_log_filename_);
-+ status_ = MULE_ERROR;
-+ DBUG_VOID_RETURN;
-+ }
-+ }
-+
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = file_size_;
-+ sql_print_information("ReplicationMule: MULE_BEHIND - new(%s), old(%s)",
-+ llstr(mi->master_log_pos, llbuf1),
-+ llstr(dump_position_, llbuf2));
-+ break;
-+ case RELAY_MATCH_MULE:
-+ case RELAY_MATCH_MULE_RUN:
-+ dump_position_ = mi->master_log_pos;
-+ sql_print_information("ReplicationMule: RELAY_MATCH_MULE.");
-+ break;
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ dump_position_ = mi->master_log_pos;
-+ mi->master_log_pos = BIN_LOG_HEADER_SIZE;
-+ sql_print_information(
-+ "ReplicationMule: MULE_VERIFY - old(%s), file_size(%s)",
-+ llstr(dump_position_, llbuf1), llstr(file_size_, llbuf2));
-+
-+ /* seek to the beginning of the file for verification */
-+ seekToPosition(BIN_LOG_HEADER_SIZE);
-+ break;
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::~ReplMule() {
-+ DBUG_ENTER("ReplMule::~ReplMule");
-+
-+ if (mule_log_->is_log_open())
-+ mule_log_->close(LOG_CLOSE_INDEX);
-+ mule_log_->clear_mule_mode();
-+
-+ /* If we are still in MULE_BEHIND or MULE_VERIFY state and we exit from
-+ * I/O thread, it means we encountered some errors.
-+ * mi->master_log_pos might be used by later slave start. It is being
-+ * changed here to do event dumping or event verification. So, we should
-+ * restore it to its original value.
-+ */
-+ switch (status_) {
-+ case MULE_BEHIND:
-+ case MULE_VERIFY:
-+ if (mi_->master_log_pos < dump_position_)
-+ mi_->master_log_pos = dump_position_;
-+ break;
-+ }
-+
-+ delete desc_event_;
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+ReplMule::WriteStatus ReplMule::writeEvent(const char* buf, ulong event_len) {
-+ WriteStatus dump_status = WRITE_RELAY;
-+ char llbuf1[22], llbuf2[22], llbuf3[22];
-+ char *verify_event;
-+ bool verified = false;
-+ bool skip_event = false;
-+
-+ DBUG_ENTER("ReplMule::dumpEvent");
-+ switch (status_) {
-+ case MULE_VERIFY:
-+ case MULE_VERIFY_RELAY_BEHIND:
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT &&
-+ IsFakeRotation(buf, event_len)) {
-+ /* Do not verify the faked rotate event */
-+ if (status_ == MULE_VERIFY)
-+ dump_status = SKIP_RELAY;
-+ break;
-+ }
-+ verify_event = new char[event_len];
-+ if (verify_event == NULL) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - insufficient memory in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ if (my_b_read(mule_log_->get_log_file(), (byte*) verify_event,
-+ event_len) != 0) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - read log error in verification, "
-+ "position(%s), event_len(%d).",
-+ llstr(mi_->master_log_pos, llbuf1), event_len);
-+ dump_status = WRITE_ERROR;
-+ delete verify_event;
-+ break;
-+ }
-+ verified = (memcmp(buf, verify_event, event_len) == 0);
-+ delete verify_event;
-+ if (!verified) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - event does not match at position(%s)",
-+ llstr(mi_->master_log_pos, llbuf1));
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+ /* fall through */
-+ case MULE_BEHIND:
-+ dump_status = SKIP_RELAY;
-+ if (status_ == MULE_BEHIND &&
-+ queueEvent(buf, event_len, &skip_event) != 0) {
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ /* Skip faked rotation event */
-+ if (!skip_event)
-+ mi_->master_log_pos += event_len;
-+
-+ if (mi_->master_log_pos == dump_position_) {
-+ if (dump_position_ < file_size_) {
-+ status_ = MULE_VERIFY_RELAY_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (mi_->master_log_pos == file_size_) {
-+ if (dump_position_ > file_size_) {
-+ status_ = MULE_BEHIND;
-+ } else {
-+ status_ = RELAY_MATCH_MULE;
-+ }
-+ sql_print_information(
-+ "ReplMule::dumpEvent - new status(%d) "
-+ "master_log_pos(%s), dump_pos(%s), file_size(%s)", status_,
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2),
-+ llstr(file_size_, llbuf3));
-+ } else if (status_ != MULE_VERIFY_RELAY_BEHIND &&
-+ mi_->master_log_pos > dump_position_) {
-+ sql_print_error(
-+ "ReplMule::dumpEvent - mule position(%s) does not match "
-+ "relay-log position(%s).",
-+ llstr(mi_->master_log_pos, llbuf1), llstr(dump_position_, llbuf2));
-+ dump_status = WRITE_ERROR;
-+ }
-+ break;
-+ case RELAY_MATCH_MULE_RUN:
-+ if (buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) {
-+ sql_print_information(" RELAY_MATCH_MULE event %d", buf[EVENT_TYPE_OFFSET] );
-+ /* Do not write format description record if size is the same */
-+ break;
-+ }
-+ case RELAY_MATCH_MULE:
-+ if (queueEvent(buf, event_len, &skip_event) != 0)
-+ dump_status = WRITE_ERROR;
-+ break;
-+ }
-+
-+ DBUG_RETURN(dump_status);
-+}
-+
-+int ReplMule::appendEvent(const char* buf, ulong event_len) {
-+ char llbuf1[22];
-+ int error;
-+
-+ DBUG_ENTER("ReplMule::appendEvent");
-+
-+ error = mule_log_->appendv(buf,event_len,0);
-+ if (error != 0) {
-+ sql_print_error("ReplMule::appendEvent - append error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ } else if (mule_log_->flush_log_file() != 0) {
-+ sql_print_error("ReplMule::appendEvent - flush error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ error = -1;
-+ } else if (mule_log_sync_period_ > 0) {
-+ mule_log_event_counter_++;
-+ if (mule_log_event_counter_ >= mule_log_sync_period_) {
-+ mule_log_event_counter_ = 0;
-+ error = my_sync(mule_log_->get_log_file()->file, MYF(MY_WME));
-+ if (error != 0)
-+ sql_print_error("ReplMule::appendEvent - sync error at %s(%s)",
-+ mi_->master_log_name,
-+ llstr(mi_->master_log_pos, llbuf1));
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+int ReplMule::queueEvent(const char* buf, ulong event_len, bool *skip_event) {
-+ int error = 0;
-+
-+ DBUG_ENTER("ReplMule::queueEvent");
-+
-+ *skip_event = false;
-+
-+ mule_log_->lock_log();
-+ if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT) {
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+
-+ /* If this is a faked rotate event and the specified filename is
-+ * the same as the current binlog filename, ignore the event.
-+ */
-+ if (IsFakeRotation(rev)) {
-+ *skip_event = true;
-+ DBUG_PRINT("info",("skipped faked rotation event"));
-+ } else {
-+ /* Only append real events. */
-+ if (rev.when != 0)
-+ error = appendEvent(buf, event_len);
-+
-+ /* Only rotate file when append succeeds. */
-+ if (error == 0) {
-+ /* Create a new file: lock both index and log. */
-+ if (strlen(curr_log_filename_) == 0) {
-+ /* If curr_log_filename_ is not specified, then this is the first
-+ * valid rotation event to indicate the filename.
-+ */
-+ error = mule_log_->open(rev.new_log_ident, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0);
-+ } else {
-+ mule_log_->new_file(0, rev.new_log_ident);
-+ }
-+
-+ strmake(curr_log_filename_, rev.new_log_ident,
-+ strlen(rev.new_log_ident));
-+
-+ DBUG_PRINT("info",("rotate file: %s", rev.new_log_ident));
-+ }
-+ }
-+ } else {
-+ error = appendEvent(buf, event_len);
-+ }
-+ mule_log_->unlock_log();
-+
-+ DBUG_RETURN(error);
-+}
-+
-+void ReplMule::seekToPosition(my_off_t pos) {
-+ DBUG_ENTER("ReplMule::seekToPosition");
-+ DBUG_PRINT("enter",("seek_pos: %ld", (ulong) pos));
-+
-+ my_b_seek(mule_log_->get_log_file(), pos);
-+ DBUG_VOID_RETURN;
-+}
-+
-+bool ReplMule::IsFakeRotation(const char* buf, ulong event_len) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+
-+ Rotate_log_event rev(buf, event_len, desc_event_);
-+ DBUG_RETURN(IsFakeRotation(rev));
-+}
-+
-+bool ReplMule::IsFakeRotation(const Rotate_log_event& rev) {
-+ DBUG_ENTER("ReplMule::IsFakeRotation");
-+ DBUG_RETURN(rev.when == 0 &&
-+ rev.ident_len == strlen(curr_log_filename_) &&
-+ strcmp(rev.new_log_ident, curr_log_filename_) == 0);
-+}
-+
-+/* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Code flow:
-+ * last_mulelog = scan the existing mule log index to find it
-+ * if (mulelog index is not created or there is no mule log inside it)
-+ * old_mule_log <- requested dumping position
-+ * requested dumping position <- 0 in the file
-+ * else
-+ * check whether the mule log matches the requested dump
-+ * (whether the last mule log name/size matches)
-+ * if the mule log name does not match
-+ * exit with an error
-+ * if (the mule log size does not match the requested dump position)
-+ * request the dump from position 0 and read all events
-+ * verify all events with the corresponding events in mule log
-+ * if (the verification succeeds)
-+ * continue the dump
-+ * else
-+ * exit with an error
-+ */
-+ReplMule* ReplMule::createReplicationMule(
-+ THD* thd, MASTER_INFO *mi, const char *binlog_indexname,
-+ MYSQL_LOG *binlog) {
-+ ReplMule *mule = NULL;
-+ LOG_INFO linfo;
-+ bool index_opened = false;
-+
-+ DBUG_ENTER("ReplMule::createReplicationMule");
-+
-+ /* binlog_indexname must be set to some real value. */
-+ DBUG_ASSERT(binlog_indexname);
-+
-+ /* Lock binlog index for all binlog operations */
-+ binlog->lock_index();
-+ index_opened = binlog->open_index_file(binlog_indexname, NULL);
-+ DBUG_PRINT("info",("open index file succeed: %d", index_opened));
-+ sql_print_information("createReplicationMule");
-+
-+ /* Scan the existing binlog index to find the last relayed binlog */
-+ if (index_opened ||
-+ binlog->find_log_pos(&linfo, NullS, false) != 0) {
-+ /* binlog index is not created or has no log file inside:
-+ * . old_relay_binlog <- requested dumping position
-+ * . requested dumping position <- 0 in the file
-+ */
-+ if (mi->master_log_pos == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ } else {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog, sync_mirror_binlog_period);
-+ }
-+
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ }
-+ } else {
-+ IO_CACHE* log_file;
-+ MY_STAT stat;
-+ char last_binlog_name[FN_REFLEN];
-+
-+ /* Find the last log file from the binlog index.
-+ * Check whether the last binlog matches the requested dump for both
-+ * binlog name and binlog size.
-+ */
-+ for (;;) {
-+ strmake(last_binlog_name, linfo.log_file_name, FN_REFLEN);
-+ last_binlog_name[FN_REFLEN - 1] = '\0';
-+ if (binlog->find_next_log(&linfo, false))
-+ break;
-+ }
-+ DBUG_PRINT("info",("the last binlog: %s", last_binlog_name));
-+
-+ /* if the binlog name does not match, exit with an error. */
-+ if (strcmp(last_binlog_name+dirname_length(last_binlog_name),
-+ mi->master_log_name) != 0) {
-+ sql_print_error("Mule binlog(%s) does not match new relay-binlog(%s)",
-+ last_binlog_name, mi->master_log_name);
-+ } /* Open the last binlog. */
-+ else if (binlog->open(last_binlog_name, LOG_BIN, NULL,
-+ SEQ_READ_APPEND, true, MAX_LOG_SIZE, 0) != 0) {
-+ sql_print_error("Mule open last binlog failed: %s", last_binlog_name);
-+ } else {
-+ bool valid_file_size = true;
-+
-+ /* Get the binlog size. */
-+ log_file = binlog->get_log_file();
-+ if (my_fstat(log_file->file, &stat, MYF(0)) == 0) {
-+ /* If the binlog size does not match the requested dump position, then
-+ * request the dump from position 0 and verify all events, we need to
-+ * verify events because the mule log might be used for serving during
-+ * anytime. We must be sure that they are correct.
-+ */
-+ sql_print_information("Binglog size %d", stat.st_size);
-+ if (stat.st_size == mi->master_log_pos) {
-+ mule = new ReplMule(thd, mi, RELAY_MATCH_MULE_RUN, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size > BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_VERIFY, stat.st_size,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else if (stat.st_size == BIN_LOG_HEADER_SIZE) {
-+ mule = new ReplMule(thd, mi, MULE_BEHIND, BIN_LOG_HEADER_SIZE,
-+ binlog_indexname, binlog,
-+ sync_mirror_binlog_period);
-+ } else {
-+ char llbuf[22];
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s) invalid size: %s",
-+ last_binlog_name, llstr(stat.st_size, llbuf));
-+ }
-+ } else {
-+ valid_file_size = false;
-+ sql_print_error("Mule binlog file(%s): fstat failed.",
-+ last_binlog_name);
-+ }
-+
-+ if (valid_file_size) {
-+ if (mule == NULL) {
-+ sql_print_error("Mule malloc operation failed.");
-+ } else if (mule->status_ == MULE_ERROR) {
-+ /* If mule creation fails, indicate the error. */
-+ delete mule;
-+ mule = NULL;
-+ }
-+ }
-+ }
-+ }
-+
-+ /* Clear the mule binlog mode if there are errors. */
-+ if (mule == NULL) {
-+ binlog->clear_mule_mode();
-+ binlog->close_index_file();
-+ }
-+
-+ /* Unlock binlog index */
-+ binlog->unlock_index();
-+
-+ DBUG_RETURN(mule);
-+}
-diff -r 66cc9e0a6768 sql/repl_mule.h
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/repl_mule.h Thu Dec 04 21:46:15 2008 -0800
-@@ -0,0 +1,166 @@
-+/*
-+ Copyright (C) 2007 Google Inc.
-+
-+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; either version 2
-+of the License, or (at your option) any later version.
-+
-+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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-+*/
-+
-+#ifndef SQL_REPL_MULE_H__
-+#define SQL_REPL_MULE_H__
-+
-+/* Replication Mule is the class that is responsible for generating
-+ * an exact copy of the binlog from a master database. We call this feature
-+ * mirror binlog and it can be enabled by setting rpl_mirror_binlog. We
-+ * need to keep the same copy for the following purposes:
-+ * . The replica can serve the binlog transparently as if they are the
-+ * master database. This can relieve master connection overhead.
-+ * . During failover, the replica can become the new master and serve
-+ * old binlogs transparently.
-+ * (The Mule name comes from the popular P2P software eMule.)
-+ *
-+ * Internally, we call the mirrored binlog mule log.
-+ */
-+
-+class THD;
-+class Rotate_log_event;
-+class Format_description_log_event;
-+typedef struct st_master_info MASTER_INFO;
-+
-+class ReplMule {
-+ public:
-+ /* Because I/O thread also creates relay-binlog, instead of an exact
-+ * copy of the original master's binlog, we have two resources that
-+ * might get out of sync.
-+ * This enum indicates the status:
-+ * MULE_BEHIND - the mule's header is behind:
-+ * (mule is activated for the first time)
-+ * RELAY_MATCH_MULE - mule matches relay-log
-+ * RELAY_MATCH_MULE_RUN - mule matches relay-log and it was not empty binlog
-+ * MULE_VERIFY - mule has more events than the relay-log and needs
-+ * verification; we can not verify based on relay-log
-+ * events because events might get changed a little;
-+ * verification starts with downloading all events in
-+ * the last binlog from the master and compare with
-+ * all events in the mule log;
-+ * MULE_VERIFY_RELAY_BEHIND - mule has more events than the relay-log
-+ * and relay-log needs to write events
-+ * MULE_ERROR - mule detects errors in event duplicate
-+ *
-+ * When the mule mirrors binlogs, it writes an event into the mule log
-+ * first. Then, I/O thread writes the event into the relay log.
-+ */
-+ enum RelayStatus {
-+ MULE_BEHIND = 1,
-+ RELAY_MATCH_MULE = 2,
-+ RELAY_MATCH_MULE_RUN = 7,
-+ MULE_VERIFY = 3,
-+ MULE_VERIFY_RELAY_BEHIND = 4,
-+ MULE_ERROR = 5,
-+ };
-+
-+ enum WriteStatus {
-+ WRITE_RELAY = 1,
-+ WRITE_ERROR = 2,
-+ SKIP_RELAY = 3,
-+ };
-+
-+ private:
-+ const Format_description_log_event *desc_event_;
-+ THD *io_thd_;
-+ MASTER_INFO *mi_;
-+
-+ /*
-+ * I/O thread will write both mule log for mirror binlog and relay log
-+ * for SQL thread.
-+ * The variable indicates whether the two are in sync.
-+ */
-+ RelayStatus status_;
-+
-+ /* The starting event writing position. */
-+ my_off_t dump_position_;
-+
-+ /* During the initial setup, the last mule log's file size. */
-+ my_off_t file_size_;
-+
-+ /* Internally, we call the mirrored binlog mule log. */
-+ MYSQL_LOG *mule_log_;
-+
-+ /* Sync the mule log to disk for every #N events. */
-+ ulong mule_log_sync_period_;
-+ ulong mule_log_event_counter_;
-+
-+ /* mule log's index filename */
-+ char mule_indexname_[FN_REFLEN];
-+
-+ /* the current mule log's filename */
-+ char curr_log_filename_[FN_REFLEN];
-+
-+ ReplMule(THD* thd, MASTER_INFO *mi, RelayStatus status,
-+ my_off_t file_size, const char *binlog_indexname,
-+ MYSQL_LOG *binlog, ulong sync_period);
-+
-+ /*
-+ * Queue the event into the current mule log. If it is a rotation
-+ * event, generate a new mule log file.
-+ * Indicate whether the event is skipped because it is an fake event.
-+ * A fake event is generated by the master to indicate the current
-+ * reading position.
-+ */
-+ int queueEvent(const char* buf, ulong event_len, bool *skip_event);
-+
-+ /* Append the event to the current mule log. */
-+ int appendEvent(const char* buf, ulong event_len);
-+
-+ bool IsFakeRotation(const char* buf, ulong event_len);
-+ bool IsFakeRotation(const Rotate_log_event& rev);
-+
-+ /* Seek to the specified position in the current open mule log. */
-+ void seekToPosition(my_off_t pos);
-+
-+ public:
-+
-+ ~ReplMule();
-+
-+ /* Dump the event into mule binlog.
-+ * Input:
-+ * buf (IN) - replication event buffer
-+ * event_len (IN) - the event length
-+ *
-+ * Return:
-+ * . WRITE_RELAY: the relay log needs to writing the event
-+ * . WRITE_ERROR: the writing encountered errors
-+ * . SKIP_RELAY: the relay log should skip the event
-+ */
-+ WriteStatus writeEvent(const char* buf, ulong event_len);
-+
-+ /* createReplicationMule:
-+ * Create a mule that relays master's replication binlog and
-+ * generate an exact same copy on the local filesystem.
-+ *
-+ * Input:
-+ * thd (IN) - replication I/O thread
-+ * mi (IN) - master info struct for I/O thread's progress
-+ * binlog_indexname (IN) - filename for binlog's index
-+ * binlog (IN) - replication binlog
-+ *
-+ * Return:
-+ * . a replication mule if success
-+ * . NULL if there are any errors
-+ */
-+ static ReplMule *createReplicationMule(THD* thd, MASTER_INFO *mi,
-+ const char *binlog_indexname,
-+ MYSQL_LOG *binlog);
-+};
-+
-+#endif /* SQL_REPL_MULE_H__ */
-diff -r 66cc9e0a6768 sql/set_var.cc
---- a/sql/set_var.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/set_var.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -345,6 +345,8 @@
- slog_verb);
- sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
- &rpl_recovery_rank);
-+sys_var_bool_ptr sys_rpl_mirror_binlog_enabled("rpl_mirror_binlog_enabled",
-+ &rpl_mirror_binlog_enabled);
- sys_var_long_ptr sys_query_cache_size("query_cache_size",
- &query_cache_size,
- fix_query_cache_size);
-@@ -364,6 +366,9 @@
- sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size",
- &SV::trans_prealloc_size,
- 0, fix_trans_mem_root);
-+sys_var_long_ptr sys_sync_mirror_binlog_period(
-+ "sync_mirror_binlog_period",
-+ &sync_mirror_binlog_period);
-
- #ifdef HAVE_QUERY_CACHE
- sys_var_long_ptr sys_query_cache_limit("query_cache_limit",
-@@ -774,6 +779,7 @@
- &sys_relay_log_purge,
- #endif
- &sys_rpl_recovery_rank,
-+ &sys_rpl_mirror_binlog_enabled,
- &sys_safe_updates,
- &sys_secure_auth,
- &sys_secure_file_priv,
-@@ -1113,6 +1119,8 @@
- {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
- #endif
- {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
-+ {sys_rpl_mirror_binlog_enabled.name,
-+ (char *) &sys_rpl_mirror_binlog_enabled, SHOW_SYS},
- {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS},
- {"secure_file_priv", (char*) &sys_secure_file_priv, SHOW_SYS},
- #ifdef HAVE_SMEM
-diff -r 66cc9e0a6768 sql/slave.cc
---- a/sql/slave.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/slave.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -25,6 +25,7 @@
- #include <thr_alarm.h>
- #include <my_dir.h>
- #include <sql_common.h>
-+#include "repl_mule.h"
- #include <errmsg.h>
- #include <mysys_err.h>
-
-@@ -3527,6 +3528,7 @@
- RELAY_LOG_INFO *rli= &mi->rli;
- char llbuff[22];
- uint retry_count;
-+ ReplMule *mule = NULL;
-
- // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
- my_thread_init();
-@@ -3609,6 +3611,23 @@
- if (get_master_version_and_clock(mysql, mi))
- goto err;
-
-+ if (rpl_mirror_binlog_enabled && !mule) {
-+ if (opt_binlog_index_name == NULL) {
-+ sql_print_error("\"log-bin-index\" must be set in mirror binlog.");
-+ goto err;
-+ }
-+
-+ /* Create the mule to generate the exact copy of the binlog */
-+ mule = ReplMule::createReplicationMule(
-+ thd, mi, opt_binlog_index_name, &mysql_bin_log);
-+
-+ /* If we could not create the mule, we stop the I/O thread and report
-+ * an error.
-+ */
-+ if (mule == NULL)
-+ goto err;
-+ }
-+
- if (mi->rli.relay_log.description_event_for_queue->binlog_version > 1)
- {
- /*
-@@ -3624,6 +3643,7 @@
- DBUG_PRINT("info",("Starting reading binary log from master"));
- while (!io_slave_killed(thd,mi))
- {
-+ const char* event_buf;
- bool suppress_warnings= 0;
- thd_proc_info(thd, "Requesting binlog dump");
- if (request_dump(mysql, mi, &suppress_warnings))
-@@ -3754,10 +3774,25 @@
- goto connected;
- } // if (event_len == packet_error)
-
-+ event_buf = (const char*)mysql->net.read_pos + 1;
-+
-+ if (mule) {
-+ ReplMule::WriteStatus d_status =
-+ mule->writeEvent(event_buf, event_len);
-+ switch (d_status) {
-+ case ReplMule::WRITE_RELAY:
-+ break;
-+ case ReplMule::SKIP_RELAY:
-+ /* Skip writing relay event; go back to read the next event */
-+ continue;
-+ case ReplMule::WRITE_ERROR:
-+ goto err;
-+ }
-+ }
-+
- retry_count=0; // ok event, reset retry counter
- thd_proc_info(thd, "Queueing master event to the relay log");
-- if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
-- event_len))
-+ if (queue_event(mi, event_buf, event_len))
- {
- sql_print_error("Slave I/O thread could not queue event from master");
- goto err;
-@@ -3847,6 +3882,7 @@
- change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
-+ delete mule;
- close_thread_tables(thd, 0);
- pthread_mutex_lock(&LOCK_thread_count);
- THD_CHECK_SENTRY(thd);
-diff -r 66cc9e0a6768 sql/sql_class.h
---- a/sql/sql_class.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_class.h Thu Dec 04 21:46:15 2008 -0800
-@@ -152,6 +152,12 @@
- #define LOG_INFO_FATAL -7
- #define LOG_INFO_IN_USE -8
-
-+/* If the maximum size is equal to this value, binlog would not rotate on
-+ * size limit.
-+ */
-+#define BINLOG_NOSWITCH_SIZE ((ulong) -1)
-+
-+
- /* bitmap to SQL_LOG::close() */
- #define LOG_CLOSE_INDEX 1
- #define LOG_CLOSE_TO_BE_OPENED 2
-@@ -245,6 +251,9 @@
- bool no_auto_events;
- friend class Log_event;
-
-+ /* mule replication mode */
-+ bool mule_binlog_;
-+
- public:
- /*
- These describe the log's format. This is used only for relay logs.
-@@ -317,7 +326,8 @@
- }
- bool open_index_file(const char *index_file_name_arg,
- const char *log_name);
-- void new_file(bool need_lock);
-+ int close_index_file();
-+ void new_file(bool need_lock= 1, const char* log_filename= NULL);
- bool write(THD *thd, enum enum_server_command command,
- const char *format, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
- bool write(THD *thd, const char *query, uint query_length,
-@@ -357,7 +367,27 @@
- int get_current_log(LOG_INFO* linfo);
- int raw_get_current_log(LOG_INFO* linfo);
- uint next_file_id();
-- inline bool is_open() { return log_type != LOG_CLOSED; }
-+
-+ /* Because mysql use is_open() to check whether replication is on,
-+ * we will let the check fail during binlog mule mode. Mule replication
-+ * and normal master replication can not be on at the same time.
-+ *
-+ * is_log_open(): the binlog file is open for either purpose
-+ *
-+ * is_open(): the binlog is open for master replication.
-+ * is_mule_open(): the binlog is open for mirror binlog or for
-+ * replication mule; refer repl_mule.h for details
-+ */
-+ bool is_log_open() {
-+ return log_type != LOG_CLOSED;
-+ }
-+ bool is_open() {
-+ return (!mule_binlog_) && is_log_open();
-+ }
-+ bool is_mule_open() {
-+ return (mule_binlog_) && is_log_open();
-+ }
-+
- inline char* get_index_fname() { return index_file_name;}
- inline char* get_log_fname() { return log_file_name; }
- inline char* get_name() { return name; }
-@@ -366,8 +396,18 @@
-
- inline void lock_index() { pthread_mutex_lock(&LOCK_index);}
- inline void unlock_index() { pthread_mutex_unlock(&LOCK_index);}
-+ inline void lock_log() { pthread_mutex_lock(&LOCK_log);}
-+ inline void unlock_log() { pthread_mutex_unlock(&LOCK_log);}
- inline IO_CACHE *get_index_file() { return &index_file;}
- inline uint32 get_open_count() { return open_count; }
-+ /* Look in file repl_mule.h for the definition of mule. */
-+ void set_mule_mode() {
-+ mule_binlog_ = 1;
-+ }
-+ void clear_mule_mode() {
-+ mule_binlog_ = 0;
-+ }
-+ int flush_log_file();
- };
-
- /*
-diff -r 66cc9e0a6768 sql/sql_lex.h
---- a/sql/sql_lex.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_lex.h Thu Dec 04 21:46:15 2008 -0800
-@@ -104,6 +104,7 @@
- // TODO(mcallaghan): update status_vars in mysqld to export these
- SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
- SQLCOM_SHOW_CLIENT_STATS,
-+ SQLCOM_MAKE_MASTER,
- /* This should be the last !!! */
- SQLCOM_END
- };
-@@ -171,6 +172,12 @@
- char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
- char *relay_log_name;
- ulong relay_log_pos;
-+
-+ /* the following fields are used for make master command */
-+ char *log_index_name;
-+ bool in_failover;
-+ bool kill_session;
-+ bool with_old_binlog;
- } LEX_MASTER_INFO;
-
-
-diff -r 66cc9e0a6768 sql/sql_parse.cc
---- a/sql/sql_parse.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_parse.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -402,6 +402,15 @@
- passwd_len ? "yes": "no",
- thd->main_security_ctx.master_access,
- (thd->db ? thd->db : "*none*")));
-+
-+ /* If we are in failover mode, reject all non-super user connections. */
-+ if (is_in_failover() &&
-+ !(thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ net_send_error(thd, ER_SPECIFIC_ACCESS_DENIED_ERROR,
-+ "super-user only during failover");
-+ DBUG_RETURN(-1);
-+ }
-+
-
- if (check_count)
- {
-@@ -3470,6 +3479,22 @@
- else
- res = load_master_data(thd);
- break;
-+
-+ case SQLCOM_MAKE_MASTER:
-+ {
-+ thd_proc_info(thd, "Making master");
-+
-+ if (check_global_access(thd, SUPER_ACL))
-+ goto error;
-+ res = make_master(thd, NULL, NULL, &lex->mi);
-+ if (res == 0) {
-+ // TODO -- wei is this OK, setting it to NULL?
-+ thd_proc_info(thd, 0);
-+ send_ok(thd);
-+ }
-+ break;
-+ }
-+
- #endif /* HAVE_REPLICATION */
- #ifdef HAVE_NDBCLUSTER_DB
- case SQLCOM_SHOW_NDBCLUSTER_STATUS:
-diff -r 66cc9e0a6768 sql/sql_repl.cc
---- a/sql/sql_repl.cc Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.cc Thu Dec 04 21:46:15 2008 -0800
-@@ -20,11 +20,19 @@
- #include "log_event.h"
- #include <my_dir.h>
-
-+extern pthread_mutex_t LOCK_failover_master;
-+extern bool failover_deny_access;
-+
- int max_binlog_dump_events = 0; // unlimited
- my_bool opt_sporadic_binlog_dump_fail = 0;
- #ifndef DBUG_OFF
- static int binlog_dump_count = 0;
- #endif
-+
-+static int make_master_open_log(MYSQL_LOG *log, const char *opt_name,
-+ bool no_auto_events, ulong max_size);
-+static int set_in_failover(bool kill_session);
-+static void clear_in_failover(void);
-
- /*
- fake_rotate_event() builds a fake (=which does not exist physically in any
-@@ -255,7 +263,7 @@
- bool purge_master_logs(THD* thd, const char* to_log)
- {
- char search_file_name[FN_REFLEN];
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- send_ok(thd);
- return FALSE;
-@@ -308,6 +316,44 @@
- return error;
- }
-
-+/* Show processlist command dump the binlog state.
-+ *
-+ * Input:
-+ * output_info - (OUT) the output proc_info
-+ * output_len - (IN) output proc_info's length
-+ * thd - (IN) the thread
-+ * input_msg - (IN) the input proc_info
-+ * log_file_name - (IN) binlog file name
-+ * log_pos - (IN) binlog position
-+ */
-+static void processlist_show_binlog_state(char *output_info,
-+ int output_len,
-+ THD *thd,
-+ const char *input_msg,
-+ const char *log_file_name,
-+ my_off_t log_pos) {
-+ DBUG_ENTER("processlist_show_binlog_state");
-+
-+ /* Point to input_msg in case "show processlist" access it before the copy
-+ * is finished.
-+ */
-+ thd_proc_info(thd, input_msg);
-+
-+ if (snprintf(output_info, output_len, "%s :%s:%lld:", input_msg,
-+ log_file_name + dirname_length(log_file_name),
-+ log_pos) > 0) {
-+ thd_proc_info(thd, output_info);
-+ }
-+
-+ DBUG_VOID_RETURN;
-+}
-+
-+static void repl_cleanup(ushort flags) {
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One less mirror binlog client. */
-+ thread_safe_sub(rpl_mirror_binlog_clients, 1, &LOCK_stats);
-+ }
-+}
-
- /*
- TODO: Clean up loop to only have one call to send_file()
-@@ -319,6 +365,11 @@
- LOG_INFO linfo;
- char *log_file_name = linfo.log_file_name;
- char search_file_name[FN_REFLEN], *name;
-+
-+ /* This buffer should be enough for "comments + :file_name:file_pos:". */
-+ char binlog_state_msg[FN_REFLEN + 100];
-+ int binlog_state_msg_len = FN_REFLEN + 100;
-+
- IO_CACHE log;
- File file = -1;
- String* packet = &thd->packet;
-@@ -335,6 +386,15 @@
-
- bzero((char*) &log,sizeof(log));
-
-+ sql_print_information("Start %s binlog_dump to slave_server(%d), pos(%s, %lu)",
-+ "asynchronous",
-+ thd->server_id, log_ident, (ulong)pos);
-+
-+ if (flags & BINLOG_MIRROR_CLIENT) {
-+ /* One more mirror binlog clients. */
-+ thread_safe_increment(rpl_mirror_binlog_clients, &LOCK_stats);
-+ }
-+
- #ifndef DBUG_OFF
- if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
- {
-@@ -344,7 +404,7 @@
- }
- #endif
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- errmsg = "Binary log is not open";
- my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
-@@ -529,6 +589,12 @@
- }
- #endif
-
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Send binlog events to slave",
-+ log_file_name, pos);
-+
- if ((*packet)[EVENT_TYPE_OFFSET+1] == FORMAT_DESCRIPTION_EVENT)
- {
- binlog_can_be_corrupted= test((*packet)[FLAGS_OFFSET+1] &
-@@ -634,6 +700,13 @@
- }
- if (!thd->killed)
- {
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Has sent all binlog to slave; "
-+ "waiting for binlog to be updated",
-+ log_file_name, pos);
-+
- /* Note that the following call unlocks lock_log */
- mysql_bin_log.wait_for_update(thd, 0);
- }
-@@ -650,7 +723,12 @@
-
- if (read_packet)
- {
-- thd_proc_info(thd, "Sending binlog event to slave");
-+ // thd_proc_info(thd, "Sending binlog event to slave");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(binlog_state_msg,
-+ binlog_state_msg_len, thd,
-+ "Sending binlog event to slave",
-+ log_file_name, pos);
- if (my_net_write(net, (char*)packet->ptr(), packet->length()) )
- {
- errmsg = "Failed on my_net_write()";
-@@ -685,10 +763,21 @@
- }
- else
- {
-+ char old_log_file_name[FN_REFLEN];
- bool loop_breaker = 0;
- /* need this to break out of the for loop from switch */
-
-- thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ // thd_proc_info(thd, "Finished reading one binlog; switching to next binlog");
-+ /* Update the binlog sending state. */
-+ processlist_show_binlog_state(
-+ binlog_state_msg, binlog_state_msg_len, thd,
-+ "Finished reading one binlog; switching to next binlog",
-+ log_file_name, pos);
-+
-+ /* Keep the old fileename. */
-+ strmake(old_log_file_name, log_file_name,
-+ sizeof(old_log_file_name) - 1);
-+
- switch (mysql_bin_log.find_next_log(&linfo, 1)) {
- case LOG_INFO_EOF:
- loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK);
-@@ -706,6 +795,16 @@
-
- end_io_cache(&log);
- (void) my_close(file, MYF(MY_WME));
-+
-+ /* A sanity check that we can not serve the same binlog twice because
-+ * the filenames are stored in a .index file.
-+ */
-+ if (strcmp(old_log_file_name, log_file_name) >= 0) {
-+ errmsg = "Re-serving an already served binlog file.";
-+ my_errno = ER_MASTER_FATAL_ERROR_READING_BINLOG;
-+ goto err;
-+ }
-+
-
- /*
- Call fake_rotate_event() in case the previous log (the one which
-@@ -733,6 +832,8 @@
- end_io_cache(&log);
- (void)my_close(file, MYF(MY_WME));
-
-+ repl_cleanup(flags);
-+
- send_eof(thd);
- thd_proc_info(thd, "Waiting to finalize termination");
- pthread_mutex_lock(&LOCK_thread_count);
-@@ -743,6 +844,7 @@
- err:
- thd_proc_info(thd, "Waiting to finalize termination");
- end_io_cache(&log);
-+ repl_cleanup(flags);
- /*
- Exclude iteration through thread list
- this is needed for purge_logs() - it will iterate through
-@@ -1316,7 +1418,7 @@
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
- SELECT_LEX_UNIT *unit= &thd->lex->unit;
-@@ -1456,7 +1558,7 @@
- DBUG_RETURN(TRUE);
- protocol->prepare_for_resend();
-
-- if (mysql_bin_log.is_open())
-+ if (mysql_bin_log.is_log_open())
- {
- LOG_INFO li;
- mysql_bin_log.get_current_log(&li);
-@@ -1497,7 +1599,7 @@
- Protocol *protocol= thd->protocol;
- DBUG_ENTER("show_binlogs");
-
-- if (!mysql_bin_log.is_open())
-+ if (!mysql_bin_log.is_log_open())
- {
- my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0));
- return 1;
-@@ -1606,6 +1708,235 @@
- DBUG_RETURN(0);
- }
-
-+
-+/* make_master: Make the current database a primary and starts the
-+ * binlog logging for all updates.
-+ *
-+ * The function handles the following sql commands:
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * [WITH BINLOG];
-+ * . MAKE MASTER MASTER_LOG_FILE='replication_log', MASTER_SERVER_ID=1,
-+ * INDEX='replication_log.index' [WITH BINLOG];
-+ * . MAKE MASTER REVOKE SESSION;
-+ * . MAKE MASTER REVOKE SESSION WITH KILL;
-+ * . MAKE MASTER GRANT SESSION;
-+ *
-+ * Args:
-+ * thd - the current thread
-+ * binlog_name - binlog's filename
-+ * binlog_indexname - binlog index's filename
-+ * mi - master info struct containing binlog name
-+ * (set when we enable master during runtime)
-+ *
-+ * Return:
-+ * 0 : success
-+ * -1 : failure
-+ */
-+int make_master(THD* thd,
-+ const char *binlog_name,
-+ const char *binlog_indexname,
-+ const LEX_MASTER_INFO* mi) {
-+ int error = 0;
-+
-+ DBUG_ENTER("make_master");
-+ /* In two mode, we enable the binlog:
-+ * . !mi - LEX is not provided; this is called from startup time
-+ * . mi->log_file_name - binlog is specified in the command
-+ */
-+ if (!mi || mi->log_file_name) {
-+ /* Get the mutex */
-+ VOID(pthread_mutex_lock(&LOCK_failover_master));
-+
-+ /* If the binlog is already opened, we issue an error. We reuse one
-+ * existing error, which might not be fully accurate.
-+ */
-+ if (mysql_bin_log.is_log_open()) {
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ sql_print_error("Replication master log is already open: cannot "
-+ "make another master!");
-+ error = -1;
-+ } else {
-+ if (!mi) {
-+ /* This opening happens at mysql startup time. */
-+ if (make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ error = -1;
-+ }
-+ } else {
-+ /* This opening happens during mysql runtime, which is mostly
-+ * requested to do failover.
-+ */
-+
-+ error = -1;
-+ if (!is_in_failover()) {
-+ sql_print_error(
-+ "\"make master\" runs only in failover mode. "
-+ "Please run \"make master revoke session (with kill)\"");
-+ } else if (strlen(mi->log_file_name) == 0) {
-+ sql_print_error("Master log filename is not specified correctly.");
-+ } else if (!mi->server_id || mi->server_id == MASTER_INFO_SERVER_ID) {
-+ sql_print_error("\"make master\": invalid server_id(%d)",
-+ mi->server_id);
-+ } else {
-+ /* Open the new log files and delete all existing ones to avoid
-+ * conflicts.
-+ */
-+ uint32 old_server_id = server_id;
-+ char *binlog_name = NULL;
-+
-+ /* Set the global master server id.
-+ * We would not change server id for all connection threads.
-+ * All non-super sessions should be blocked by revoke sessions.
-+ * Super-user sessions are responsible for their own operations.
-+ */
-+ server_id = mi->server_id;
-+ thd->server_id = mi->server_id;
-+
-+ if (!(binlog_name = my_strdup(mi->log_file_name, MYF(0))) ||
-+ make_master_open_index(&binlog_name, mi->log_index_name) != 0 ||
-+ make_master_open_log(&mysql_bin_log, binlog_name,
-+ 0, max_binlog_size) != 0) {
-+ sql_print_error("Open master logfile failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else if (!mi->with_old_binlog &&
-+ mysql_bin_log.reset_logs(thd) != 0) {
-+ sql_print_error("Cleanup existing master logfiles failed.");
-+ thd->server_id = old_server_id;
-+ server_id = old_server_id;
-+ } else {
-+ error = 0;
-+ }
-+ }
-+ if (error == -1)
-+ my_error(ER_MASTER_INFO, MYF(0));
-+ }
-+ }
-+
-+ if (error == 0) {
-+ /* indicates that binlog is enabled now */
-+ using_update_log = 1;
-+ } else if (mysql_bin_log.is_open()) {
-+ mysql_bin_log.close(LOG_CLOSE_INDEX);
-+ }
-+
-+ /* Release the mutex */
-+ VOID(pthread_mutex_unlock(&LOCK_failover_master));
-+ } else {
-+ /* The following actions are related to session management during
-+ * failover operation. We do not want some sessions come in
-+ * during failover and make updates.
-+ * This is invoked for command: MAKE MASTER GRANT/REVOKE SESSION;
-+ */
-+ if (mi->in_failover) {
-+ set_in_failover(mi->kill_session);
-+ } else {
-+ clear_in_failover();
-+ }
-+ }
-+
-+ DBUG_RETURN(error);
-+}
-+
-+static int make_master_open_log(MYSQL_LOG *log,
-+ const char *opt_name,
-+ bool no_auto_events,
-+ ulong max_size) {
-+ char tmp[FN_REFLEN];
-+
-+ // get rid of extension
-+ char *p = fn_ext(opt_name);
-+ uint length=(uint) (p-opt_name);
-+ strmake(tmp,opt_name,min(length,FN_REFLEN));
-+ opt_name=tmp;
-+
-+ return log->open(opt_name, LOG_BIN, NULL, WRITE_CACHE, 0,
-+ max_size, 0);
-+}
-+
-+int make_master_open_index(char **binlog_name,
-+ const char *binlog_indexname) {
-+ char buf[FN_REFLEN];
-+ const char *ln;
-+ DBUG_ENTER("make_master_open_index");
-+
-+ ln= mysql_bin_log.generate_name(*binlog_name, "-bin", 1, buf);
-+ if (!(*binlog_name) && !binlog_indexname) {
-+ /*
-+ User didn't give us info to name the binlog index file.
-+ Picking `hostname`-bin.index like did in 4.x, causes replication to
-+ fail if the hostname is changed later. So, we would like to instead
-+ require a name. But as we don't want to break many existing setups, we
-+ only give warning, not error.
-+ */
-+ sql_print_warning("No argument was provided to --log-bin, and "
-+ "--log-bin-index was not used; so replication "
-+ "may break when this MySQL server acts as a "
-+ "master and has his hostname changed!! Please "
-+ "use '--log-bin=%s' to avoid this problem.", ln);
-+ }
-+ if (ln == buf) {
-+ my_free(*binlog_name, MYF(MY_ALLOW_ZERO_PTR));
-+ *binlog_name = my_strdup(buf, MYF(0));
-+ }
-+ if (mysql_bin_log.open_index_file(binlog_indexname, ln) != 0) {
-+ DBUG_RETURN(-1);
-+ }
-+
-+ /*
-+ Used to specify which type of lock we need to use for queries of type
-+ INSERT ... SELECT. This will change when we have row level logging.
-+ */
-+ using_update_log=1;
-+
-+ DBUG_RETURN(0);
-+}
-+
-+/* Set the status indicating that we are in failover and deny all non-super
-+ * user access.
-+ *
-+ * Args:
-+ * kill_session - kill all non-super sessions if specified
-+ *
-+ * Return:
-+ * 0 - success
-+ * -1 - failure (caused by not killing all sessions)
-+ */
-+static int set_in_failover(bool kill_session) {
-+ failover_deny_access = 1;
-+
-+ if (kill_session) {
-+ /* If kill session option is specified, we need to kill all non-super
-+ * user sessions.
-+ */
-+ THD *kill_thd;
-+
-+ uint error=ER_NO_SUCH_THREAD;
-+ pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
-+ I_List_iterator<THD> it(threads);
-+ while ((kill_thd=it++)) {
-+ if (!(kill_thd->main_security_ctx.master_access & SUPER_ACL)) {
-+ pthread_mutex_lock(&kill_thd->LOCK_delete); // Lock from delete
-+
-+ /* ask the thread to die */
-+ kill_thd->awake(THD::KILL_CONNECTION);
-+ pthread_mutex_unlock(&kill_thd->LOCK_delete);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ }
-+ return 0;
-+}
-+
-+static void clear_in_failover(void) {
-+ failover_deny_access = 0;
-+}
-+
-+bool is_in_failover(void) {
-+ return failover_deny_access;
-+}
-+
-+
- #endif /* HAVE_REPLICATION */
-
-
-diff -r 66cc9e0a6768 sql/sql_repl.h
---- a/sql/sql_repl.h Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_repl.h Thu Dec 04 21:46:15 2008 -0800
-@@ -38,6 +38,10 @@
- int start_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report);
- bool change_master(THD* thd, MASTER_INFO* mi);
-+int make_master(THD* thd, const char *binlog_name,
-+ const char *binlog_indexname, const LEX_MASTER_INFO* mi);
-+int make_master_open_index(char **binlog_name, const char *binlog_indexname);
-+bool is_in_failover(void);
- bool mysql_show_binlog_events(THD* thd);
- int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
- const char* log_file_name2, ulonglong log_pos2);
-diff -r 66cc9e0a6768 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Thu Dec 04 21:37:12 2008 -0800
-+++ b/sql/sql_yacc.yy Thu Dec 04 21:46:15 2008 -0800
-@@ -735,6 +735,7 @@
- %token LOOP_SYM
- %token LOW_PRIORITY
- %token LT
-+%token MAKE_SYM
- %token MAKE_SET_SYM
- %token MASTER_CONNECT_RETRY_SYM
- %token MASTER_HOST_SYM
-@@ -1167,7 +1168,7 @@
- query verb_clause create change select do drop insert replace insert2
- insert_values update delete truncate rename
- show describe load alter optimize keycache preload flush
-- reset purge begin commit rollback savepoint release
-+ make reset purge begin commit rollback savepoint release
- slave master_def master_defs master_file_def slave_until_opts
- repair restore backup analyze check start checksum
- field_list field_list_item field_spec kill column_def key_def
-@@ -1301,6 +1302,7 @@
- | kill
- | load
- | lock
-+ | make
- | optimize
- | keycache
- | preload
-@@ -1428,6 +1430,56 @@
- master_defs
- {}
- ;
-+
-+/* make master */
-+make:
-+ MAKE_SYM MASTER_SYM
-+ {
-+ LEX *lex = Lex;
-+ lex->sql_command = SQLCOM_MAKE_MASTER;
-+ bzero((char*) &lex->mi, sizeof(lex->mi));
-+ }
-+ make_master_defs
-+ {
-+ }
-+ ;
-+
-+make_master_defs:
-+ MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ }
-+ make_master_with_defs {}
-+ | MASTER_LOG_FILE_SYM EQ TEXT_STRING ',' MASTER_SERVER_ID_SYM EQ ulong_num ',' INDEX_SYM EQ TEXT_STRING
-+ {
-+ Lex->mi.log_file_name = $3.str;
-+ Lex->mi.server_id = $7;
-+ Lex->mi.log_index_name = $11.str;
-+ }
-+ make_master_with_defs {}
-+ | GRANT SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 0;
-+ }
-+ | REVOKE SESSION_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ }
-+ | REVOKE SESSION_SYM WITH KILL_SYM
-+ {
-+ Lex->mi.in_failover = 1;
-+ Lex->mi.kill_session = 1;
-+ }
-+ ;
-+
-+make_master_with_defs:
-+ /* empty */ {}
-+ | WITH BINLOG_SYM
-+ {
-+ /* All old binlogs will be kept after "make master" command. */
-+ Lex->mi.with_old_binlog = 1;
-+ }
-
- master_defs:
- master_def
-@@ -8396,6 +8448,7 @@
- | HANDLER_SYM {}
- | HELP_SYM {}
- | LANGUAGE_SYM {}
-+ | MAKE_SYM {}
- | NO_SYM {}
- | OPEN_SYM {}
- | PREPARE_SYM {}
diff --git a/percona/5.0.87-b20-20100217/mysql-test.patch b/percona/5.0.87-b20-20100217/mysql-test.patch
deleted file mode 100644
index 7fce8e0..0000000
--- a/percona/5.0.87-b20-20100217/mysql-test.patch
+++ /dev/null
@@ -1,108 +0,0 @@
---- a/mysql-test/r/information_schema.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/information_schema.result 2009-05-07 19:32:59.000000000 +0000
-@@ -60,6 +60,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- columns_priv
- db
- func
-@@ -743,7 +744,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--109
-+110
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -819,7 +820,7 @@
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 24
-+information_schema 25
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1228,6 +1229,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
-@@ -1267,6 +1269,7 @@
- USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- INNODB_IO_PATTERN SPACE
-+INNODB_RSEG RSEG_ID
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
- VIEWS
-@@ -1342,6 +1345,7 @@
- INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1
- INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1
-+INNODB_RSEG information_schema.INNODB_RSEG 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROCESSLIST information_schema.PROCESSLIST 1
- PROFILING information_schema.PROFILING 1
---- a/mysql-test/r/information_schema_db.result 2009-05-07 19:31:27.000000000 +0000
-+++ b/mysql-test/r/information_schema_db.result 2009-05-07 19:35:01.000000000 +0000
-@@ -29,6 +29,7 @@
- USER_STATISTICS
- VIEWS
- INNODB_IO_PATTERN
-+INNODB_RSEG
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
---- a/mysql-test/r/mysqlshow.result 2009-05-07 19:31:26.000000000 +0000
-+++ b/mysql-test/r/mysqlshow.result 2009-05-07 19:36:32.000000000 +0000
-@@ -103,6 +103,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
- +---------------------------------------+
-@@ -132,6 +133,7 @@
- | USER_STATISTICS |
- | VIEWS |
- | INNODB_IO_PATTERN |
-+| INNODB_RSEG |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
- +--------------------+
---- a/mysql-test/r/profiling.result 2009-05-28 19:39:42.000000000 +0000
-+++ b/mysql-test/r/profiling.result 2009-05-28 19:40:14.000000000 +0000
-@@ -6,6 +6,8 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 15
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 0
-@@ -16,12 +18,16 @@
- Variable_name Value
- profiling OFF
- profiling_history_size 100
-+profiling_server OFF
-+profiling_use_getrusage OFF
- set session profiling = ON;
- set session profiling_history_size=30;
- show session variables like 'profil%';
- Variable_name Value
- profiling ON
- profiling_history_size 30
-+profiling_server OFF
-+profiling_use_getrusage OFF
- select @@profiling;
- @@profiling
- 1
diff --git a/percona/5.0.87-b20-20100217/mysqld_safe_syslog.patch b/percona/5.0.87-b20-20100217/mysqld_safe_syslog.patch
deleted file mode 100644
index a493a29..0000000
--- a/percona/5.0.87-b20-20100217/mysqld_safe_syslog.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -r d91edeb58b50 patch_info/mysqld_safe_syslog.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/mysqld_safe_syslog.info Mon Sep 01 21:58:00 2008 -0700
-@@ -0,0 +1,6 @@
-+File=mysqld_safe_syslog.patch
-+Name=Patch allows redirect output of error.log to syslog-ng
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=Ported from Debian
-diff -r d91edeb58b50 scripts/mysqld_safe.sh
---- a/scripts/mysqld_safe.sh Mon Sep 01 21:57:21 2008 -0700
-+++ b/scripts/mysqld_safe.sh Mon Sep 01 21:58:00 2008 -0700
-@@ -10,12 +10,16 @@
- # mysql.server works by first doing a cd to the base directory and from there
- # executing mysqld_safe
-
--KILL_MYSQLD=1;
- MYSQLD=
-
- trap '' 1 2 3 15 # we shouldn't let anyone kill us
-
- umask 007
-+
-+KILL_MYSQLD=1;
-+
-+# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
-+ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
-
- defaults=
- case "$1" in
-@@ -177,7 +181,6 @@
-
- # these rely on $DATADIR by default, so we'll set them later on
- pid_file=
--err_log=
-
- # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
- # and then merge with the command line arguments
-@@ -245,7 +248,6 @@
- * ) pid_file="$DATADIR/$pid_file" ;;
- esac
- fi
--test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
-
- if test -n "$mysql_unix_port"
- then
-@@ -315,8 +317,6 @@
- then
- USER_OPTION="--user=$user"
- fi
-- # If we are root, change the err log to the right user.
-- touch $err_log; chown $user $err_log
- if test -n "$open_files"
- then
- ulimit -n $open_files
-@@ -341,18 +341,16 @@
- then
- if @FIND_PROC@
- then # The pid contains a mysqld process
-- echo "A mysqld process already exists"
-- echo "A mysqld process already exists at " `date` >> $err_log
-+ echo "A mysqld process already exists" | $ERR_LOGGER -s
- exit 1
- fi
- fi
- rm -f $pid_file
- if test -f $pid_file
- then
-- echo "Fatal error: Can't remove the pid file: $pid_file"
-- echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-- echo "Please remove it manually and start $0 again"
-- echo "mysqld daemon not started"
-+ echo "Fatal error: Can't remove the pid file: $pid_file" | $ERR_LOGGER -s
-+ echo "Please remove it manually and start $0 again" | $ERR_LOGGER -s
-+ echo "mysqld daemon not started" | $ERR_LOGGER -s
- exit 1
- fi
- fi
-@@ -377,15 +375,15 @@
- # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
- #fi
-
--echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log
-+echo "started" | $ERR_LOGGER -s
- while true
- do
- rm -f $safe_mysql_unix_port $pid_file # Some extra safety
- if test -z "$args"
- then
-- $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1
-+ $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ 2>&1 | $ERR_LOGGER -t mysqld
- else
-- eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1"
-+ eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args 2>&1 | $ERR_LOGGER -t mysqld"
- fi
- if test ! -f $pid_file # This is removed if normal shutdown
- then
-@@ -402,7 +400,7 @@
- # kill -9 is used or the process won't react on the kill.
- numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-- echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-+ echo -e "\nNumber of processes running now: $numofproces" | $ERR_LOGGER -s
- I=1
- while test "$I" -le "$numofproces"
- do
-@@ -415,16 +413,14 @@
- # echo "TEST $I - $T **"
- if kill -9 $T
- then
-- echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-+ echo "$MYSQLD process hanging, pid $T - killed" | $ERR_LOGGER -s
- else
- break
- fi
- I=`expr $I + 1`
- done
- fi
-- echo "`date +'%y%m%d %H:%M:%S'` mysqld restarted" | tee -a $err_log
-+ echo "restarted" | $ERR_LOGGER -s
- done
-
--echo "`date +'%y%m%d %H:%M:%S'` mysqld ended" | tee -a $err_log
--echo "" | tee -a $err_log
--
-+echo "ended" | $ERR_LOGGER -s
diff --git a/percona/5.0.87-b20-20100217/profiling_slow.patch b/percona/5.0.87-b20-20100217/profiling_slow.patch
deleted file mode 100644
index 78d35a0..0000000
--- a/percona/5.0.87-b20-20100217/profiling_slow.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-diff -r 4636d2e0b0d0 patch_info/profiling_slow.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/profiling_slow.info Fri Jul 03 15:40:29 2009 -0700
-@@ -0,0 +1,9 @@
-+File=profiling_slow.info
-+Name=profiling from SHOW PROFILE to slow.log
-+Version=1.0
-+Author=Percona <info@percona.com>
-+License=GPL
-+Comment=
-+Changelog
-+2009-05-18
-+Initial implementation
-diff -r 4636d2e0b0d0 sql/log.cc
---- a/sql/log.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/log.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -2402,6 +2402,11 @@
- tmp_errno=errno;
- }
- }
-+
-+#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
-+ thd->profiling.print_current(&log_file);
-+#endif
-+
- if (thd->db && strcmp(thd->db,db))
- { // Database changed
- if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1)
-diff -r 4636d2e0b0d0 sql/mysqld.cc
---- a/sql/mysqld.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/mysqld.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -5052,6 +5052,8 @@
- OPT_PORT_OPEN_TIMEOUT,
- OPT_MERGE,
- OPT_PROFILING,
-+ OPT_PROFILING_SERVER,
-+ OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
-@@ -5675,6 +5677,16 @@
- (gptr*) &global_system_variables.profiling_history_size,
- (gptr*) &max_system_variables.profiling_history_size,
- 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
-+ {"profiling_server", OPT_PROFILING_SERVER,
-+ "Enable profiling of all threads",
-+ (gptr*) &global_system_variables.profiling_server,
-+ (gptr*) &max_system_variables.profiling_server, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
-+ {"profiling_use_getrusage", OPT_PROFILING_USE_GETRUSAGE,
-+ "Enable getrusage function call for profiling",
-+ (gptr*) &global_system_variables.profiling_use_getrusage,
-+ (gptr*) &max_system_variables.profiling_use_getrusage, 0, GET_BOOL,
-+ OPT_ARG, 0, 0, 0, 0, 0, 0 },
- #endif
- {"relay-log", OPT_RELAY_LOG,
- "The location and name to use for relay logs.",
-diff -r 4636d2e0b0d0 sql/set_var.cc
---- a/sql/set_var.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/set_var.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -592,6 +592,10 @@
- ulonglong(OPTION_PROFILING));
- static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
- &SV::profiling_history_size);
-+static sys_var_thd_bool sys_profiling_server("profiling_server",
-+ &SV::profiling_server);
-+static sys_var_thd_bool sys_profiling_use_getrusage("profiling_use_getrusage",
-+ &SV::profiling_use_getrusage);
- #endif
-
- /* Local state variables */
-@@ -764,6 +768,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- &sys_profiling,
- &sys_profiling_history_size,
-+ &sys_profiling_server,
-+ &sys_profiling_use_getrusage,
- #endif
- &sys_pseudo_thread_id,
- &sys_query_alloc_block_size,
-@@ -1094,6 +1100,8 @@
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- {sys_profiling.name, (char*) &sys_profiling, SHOW_SYS},
- {sys_profiling_history_size.name, (char*) &sys_profiling_history_size, SHOW_SYS},
-+ {sys_profiling_server.name, (char*) &sys_profiling_server, SHOW_SYS},
-+ {sys_profiling_use_getrusage.name, (char*) &sys_profiling_use_getrusage, SHOW_SYS},
- #endif
- {"protocol_version", (char*) &protocol_version, SHOW_INT},
- {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
-diff -r 4636d2e0b0d0 sql/sql_class.h
---- a/sql/sql_class.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_class.h Fri Jul 03 15:40:29 2009 -0700
-@@ -550,6 +550,8 @@
- ulong optimizer_search_depth;
- ulong preload_buff_size;
- ulong profiling_history_size;
-+ my_bool profiling_server;
-+ my_bool profiling_use_getrusage;
- ulong query_cache_type;
- ulong log_slow_rate_limit;
- ulong read_buff_size;
-diff -r 4636d2e0b0d0 sql/sql_profile.cc
---- a/sql/sql_profile.cc Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.cc Fri Jul 03 15:40:29 2009 -0700
-@@ -221,9 +221,22 @@
- */
- void PROF_MEASUREMENT::collect()
- {
-+ struct timespec tp;
- time_usecs= (double) my_getsystime() / 10.0; /* 1 sec was 1e7, now is 1e6 */
- #ifdef HAVE_GETRUSAGE
-- getrusage(RUSAGE_SELF, &rusage);
-+ if ((profile->get_profiling())->enabled_getrusage())
-+ getrusage(RUSAGE_SELF, &rusage);
-+#endif
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ if (!(clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ {
-+ cpu_time_usecs= tp.tv_sec*1000000000.0 + tp.tv_nsec;
-+ }
-+ else
-+ {
-+ cpu_time_usecs= 0;
-+ }
- #endif
- }
-
-@@ -341,7 +354,7 @@
- finish_current_query();
- }
-
-- enabled= (((thd)->options & OPTION_PROFILING) != 0);
-+ enabled= (((thd)->options & OPTION_PROFILING) != 0) || ( thd->variables.profiling_server );
-
- if (! enabled) DBUG_VOID_RETURN;
-
-@@ -379,7 +392,8 @@
- status_change("ending", NULL, NULL, 0);
-
- if ((enabled) && /* ON at start? */
-- ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
-+ (((thd->options & OPTION_PROFILING) != 0) ||
-+ (thd->variables.profiling_server)) && /* and ON at end? */
- (current->query_source != NULL) &&
- (! current->entries.is_empty()))
- {
-@@ -480,6 +494,88 @@
- DBUG_VOID_RETURN;
- }
-
-+bool PROFILING::enabled_getrusage()
-+{
-+ return thd->variables.profiling_use_getrusage;
-+}
-+
-+/**
-+ Print output for current query to file
-+*/
-+
-+int PROFILING::print_current(IO_CACHE *log_file)
-+{
-+ DBUG_ENTER("PROFILING::print_current");
-+ ulonglong row_number= 0;
-+ char query_time_buff[22+7];
-+ char query_cpu_time_buff[22+7];
-+
-+ QUERY_PROFILE *query;
-+ /* Get current query */
-+ if (current == NULL)
-+ {
-+ DBUG_RETURN(0);
-+ }
-+
-+ query= current;
-+
-+ my_b_printf(log_file, "# PROFILE_VALUES ");
-+
-+ void *entry_iterator;
-+ PROF_MEASUREMENT *entry, *previous= NULL, *first= NULL;
-+ /* ...and for each query, go through all its state-change steps. */
-+ for (entry_iterator= query->entries.new_iterator();
-+ entry_iterator != NULL;
-+ entry_iterator= query->entries.iterator_next(entry_iterator),
-+ previous=entry, row_number++)
-+ {
-+ entry= query->entries.iterator_value(entry_iterator);
-+
-+ /* Skip the first. We count spans of fence, not fence-posts. */
-+ if (previous == NULL) {first= entry; continue;}
-+
-+ if (thd->lex->orig_sql_command == SQLCOM_SHOW_PROFILE)
-+ {
-+ /*
-+ We got here via a SHOW command. That means that we stored
-+ information about the query we wish to show and that isn't
-+ in a WHERE clause at a higher level to filter out rows we
-+ wish to exclude.
-+
-+ Because that functionality isn't available in the server yet,
-+ we must filter here, at the wrong level. Once one can con-
-+ struct where and having conditions at the SQL layer, then this
-+ condition should be ripped out.
-+ */
-+ if (thd->lex->profile_query_id == 0) /* 0 == show final query */
-+ {
-+ if (query != last)
-+ continue;
-+ }
-+ else
-+ {
-+ if (thd->lex->profile_query_id != query->profiling_query_id)
-+ continue;
-+ }
-+ }
-+
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-previous->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-previous->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "%s: %s (cpu: %s), ", previous->status, query_time_buff, query_cpu_time_buff);
-+
-+ }
-+
-+ my_b_printf(log_file, "\n");
-+ if ((entry != NULL) && (first != NULL))
-+ {
-+ snprintf(query_time_buff, sizeof(query_time_buff), "%.6f", (entry->time_usecs-first->time_usecs)/(1000.0*1000));
-+ snprintf(query_cpu_time_buff, sizeof(query_cpu_time_buff), "%.6f", (entry->cpu_time_usecs-first->cpu_time_usecs)/(1000.0*1000*1000));
-+ my_b_printf(log_file, "# PROFILE_TOTALS Total: %s (cpu: %s)\n", query_time_buff, query_cpu_time_buff);
-+ }
-+
-+ DBUG_RETURN(0);
-+}
-+
- /**
- Fill the information schema table, "query_profile", as defined in show.cc .
- There are two ways to get to this function: Selecting from the information
-diff -r 4636d2e0b0d0 sql/sql_profile.h
---- a/sql/sql_profile.h Fri Jul 03 15:40:20 2009 -0700
-+++ b/sql/sql_profile.h Fri Jul 03 15:40:29 2009 -0700
-@@ -193,6 +193,7 @@
- unsigned int line;
-
- double time_usecs;
-+ double cpu_time_usecs;
- char *allocated_status_memory;
-
- void set_label(const char *status_arg, const char *function_arg,
-@@ -243,6 +244,11 @@
-
- /* Show this profile. This is called by PROFILING. */
- bool show(uint options);
-+
-+public:
-+
-+ inline PROFILING * get_profiling() { return profiling; };
-+
- };
-
-
-@@ -288,9 +294,11 @@
-
- /* SHOW PROFILES */
- bool show_profiles();
-+ bool enabled_getrusage();
-
- /* ... from INFORMATION_SCHEMA.PROFILING ... */
- int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
-+ int print_current(IO_CACHE *log_file);
- };
-
- # endif /* HAVE_PROFILING */
diff --git a/percona/5.0.87-b20-20100217/series b/percona/5.0.87-b20-20100217/series
deleted file mode 100644
index 0dcc631..0000000
--- a/percona/5.0.87-b20-20100217/series
+++ /dev/null
@@ -1,22 +0,0 @@
-show_patches.patch
-microslow_innodb.patch
-profiling_slow.patch
-userstatv2.patch
-microsec_process.patch
-innodb_io_patches.patch
-mysqld_safe_syslog.patch
-innodb_locks_held.patch
-innodb_show_bp.patch
-innodb_check_fragmentation.patch
-innodb_io_pattern.patch
-innodb_fsync_source.patch
-innodb_show_hashed_memory.patch
-innodb_dict_size_limit.patch
-innodb_extra_rseg.patch
-innodb_thread_concurrency_timer_based.patch
-innodb_use_sys_malloc.patch
-innodb_recovery_patches.patch
-innodb_misc_patch.patch
-innodb_split_buf_pool_mutex.patch
-innodb_rw_lock.patch
-mysql-test.patch
diff --git a/percona/5.0.87-b20-20100217/show_patches.patch b/percona/5.0.87-b20-20100217/show_patches.patch
deleted file mode 100644
index 7f1d431..0000000
--- a/percona/5.0.87-b20-20100217/show_patches.patch
+++ /dev/null
@@ -1,288 +0,0 @@
-diff -r c3e57b0c22c4 patch_info/show_patches.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/show_patches.info Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,6 @@
-+File=show_patches.patch
-+Name=SHOW PATCHES
-+Version=1.0
-+Author=Jeremy Cole
-+License=N/A
-+Comment
-diff -r c3e57b0c22c4 sql/Makefile.am
---- a/sql/Makefile.am Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.am Mon Dec 22 00:25:06 2008 -0800
-@@ -118,7 +118,7 @@
- -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
- @DEFS@
-
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -175,6 +175,8 @@
- udf_example_la_SOURCES= udf_example.c
- udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-
- # Don't update the files from bitkeeper
- %::SCCS/s.%
-diff -r c3e57b0c22c4 sql/Makefile.in
---- a/sql/Makefile.in Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/Makefile.in Mon Dec 22 00:25:06 2008 -0800
-@@ -561,7 +561,7 @@
- gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
- mysql_tzinfo_to_sql_SOURCES = mysql_tzinfo_to_sql.cc
- mysql_tzinfo_to_sql_LDADD = @MYSQLD_EXTRA_LDFLAGS@ $(LDADD) $(CXXLDFLAGS)
--BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h
-+BUILT_SOURCES = sql_yacc.cc sql_yacc.h lex_hash.h patch_info.h
- EXTRA_DIST = $(BUILT_SOURCES) nt_servc.cc nt_servc.h \
- message.mc message.h message.rc MSG00001.bin \
- examples/CMakeLists.txt CMakeLists.txt \
-@@ -1237,6 +1237,9 @@
- ./gen_lex_hash$(EXEEXT) > $@-t
- $(MV) $@-t $@
-
-+patch_info.h: patch_info.h.pl
-+ $(PERL) $< > $@
-+
- # Don't update the files from bitkeeper
- %::SCCS/s.%
- # Tell versions [3.59,3.63) of GNU make to not export all variables.
-diff -r c3e57b0c22c4 sql/lex.h
---- a/sql/lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -367,6 +367,7 @@
- { "PACK_KEYS", SYM(PACK_KEYS_SYM)},
- { "PARTIAL", SYM(PARTIAL)},
- { "PASSWORD", SYM(PASSWORD)},
-+ { "PATCHES", SYM(PATCHES)},
- { "PHASE", SYM(PHASE_SYM)},
- { "POINT", SYM(POINT_SYM)},
- { "POLYGON", SYM(POLYGON)},
-diff -r c3e57b0c22c4 sql/mysql_priv.h
---- a/sql/mysql_priv.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/mysql_priv.h Mon Dec 22 00:25:06 2008 -0800
-@@ -968,6 +968,7 @@
- int mysqld_show_status(THD *thd);
- int mysqld_show_variables(THD *thd,const char *wild);
- bool mysqld_show_storage_engines(THD *thd);
-+bool mysqld_show_patches(THD *thd);
- bool mysqld_show_privileges(THD *thd);
- bool mysqld_show_column_types(THD *thd);
- bool mysqld_help (THD *thd, const char *text);
-diff -r c3e57b0c22c4 sql/patch_info.h.pl
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/sql/patch_info.h.pl Mon Dec 22 00:25:06 2008 -0800
-@@ -0,0 +1,65 @@
-+use strict;
-+
-+my $patch_info_path = '../patch_info';
-+my $file = '';
-+my $output = '';
-+
-+
-+if (opendir(PATCH_DIR, $patch_info_path))
-+{
-+ while ((my $file = readdir(PATCH_DIR)))
-+ {
-+ open(PATCH_FILE, "<$patch_info_path/$file") || die("Unable to open $patch_info_path/$file ($!)");
-+ my %fields;
-+
-+ if ($file =~ /^\./)
-+ {
-+ next;
-+ }
-+
-+ while (<PATCH_FILE>)
-+ {
-+ chomp;
-+
-+ my ($key, $value) = split(/\s*=\s*/);
-+ $fields{lc($key)} = $value;
-+ }
-+
-+ $output .= "{\"$fields{'file'}\", \"$fields{'name'}\", \"$fields{'version'}\", \"$fields{'author'}\", \"$fields{'license'}\",\"$fields{'comment'}\"},\n"
-+ }
-+}
-+
-+print <<HEADER;
-+
-+/* Copyright (C) 2002-2006 MySQL AB
-+
-+ 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 */
-+
-+#ifdef USE_PRAGMA_INTERFACE
-+#pragma interface /* gcc class implementation */
-+#endif
-+
-+struct patch {
-+ const char *file;
-+ const char *name;
-+ const char *version;
-+ const char *author;
-+ const char *license;
-+ const char *comment;
-+}patches[] = {
-+$output
-+{NULL, NULL, NULL, NULL}
-+};
-+
-+HEADER
-diff -r c3e57b0c22c4 sql/sp_head.cc
---- a/sql/sp_head.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sp_head.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -191,6 +191,7 @@
- case SQLCOM_SHOW_MUTEX_STATUS:
- case SQLCOM_SHOW_NEW_MASTER:
- case SQLCOM_SHOW_OPEN_TABLES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_SLAVE_HOSTS:
-diff -r c3e57b0c22c4 sql/sql_lex.h
---- a/sql/sql_lex.h Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_lex.h Mon Dec 22 00:25:06 2008 -0800
-@@ -95,6 +95,7 @@
- SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
- SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
- SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
-+ SQLCOM_SHOW_PATCHES,
-
- /*
- When a command is added here, be sure it's also added in mysqld.cc
-diff -r c3e57b0c22c4 sql/sql_parse.cc
---- a/sql/sql_parse.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_parse.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -3947,6 +3947,9 @@
- break;
- case SQLCOM_SHOW_STORAGE_ENGINES:
- res= mysqld_show_storage_engines(thd);
-+ break;
-+ case SQLCOM_SHOW_PATCHES:
-+ res= mysqld_show_patches(thd);
- break;
- case SQLCOM_SHOW_PRIVILEGES:
- res= mysqld_show_privileges(thd);
-diff -r c3e57b0c22c4 sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_prepare.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -1790,6 +1790,7 @@
- case SQLCOM_SHOW_DATABASES:
- case SQLCOM_SHOW_PROCESSLIST:
- case SQLCOM_SHOW_STORAGE_ENGINES:
-+ case SQLCOM_SHOW_PATCHES:
- case SQLCOM_SHOW_PRIVILEGES:
- case SQLCOM_SHOW_COLUMN_TYPES:
- case SQLCOM_SHOW_STATUS:
-diff -r c3e57b0c22c4 sql/sql_show.cc
---- a/sql/sql_show.cc Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_show.cc Mon Dec 22 00:25:06 2008 -0800
-@@ -22,6 +22,7 @@
- #include "sp.h"
- #include "sp_head.h"
- #include "sql_trigger.h"
-+#include "patch_info.h"
- #include <my_dir.h>
-
- #ifdef HAVE_BERKELEY_DB
-@@ -45,6 +46,47 @@
- static int
- view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
- bool schema_table_store_record(THD *thd, TABLE *table);
-+
-+/***************************************************************************
-+** List patches built into this release
-+***************************************************************************/
-+
-+bool mysqld_show_patches(THD *thd)
-+{
-+ List<Item> field_list;
-+ int i = 0;
-+ Protocol *protocol= thd->protocol;
-+ DBUG_ENTER("mysqld_show_patches");
-+
-+ field_list.push_back(new Item_empty_string("File", 255));
-+ field_list.push_back(new Item_empty_string("Name", 50));
-+ field_list.push_back(new Item_empty_string("Version", 10));
-+ field_list.push_back(new Item_empty_string("Author", 50));
-+ field_list.push_back(new Item_empty_string("License", 50));
-+ field_list.push_back(new Item_empty_string("Comment", 32));
-+
-+ if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
-+ DBUG_RETURN(TRUE);
-+
-+ for (i = 0; patches[i].file; i++)
-+ {
-+ protocol->prepare_for_resend();
-+ protocol->store(patches[i].file, system_charset_info);
-+ protocol->store(patches[i].name, system_charset_info);
-+ protocol->store(patches[i].version, system_charset_info);
-+ protocol->store(patches[i].author, system_charset_info);
-+ protocol->store(patches[i].license, system_charset_info);
-+ protocol->store(patches[i].comment, system_charset_info);
-+
-+ if (protocol->write())
-+ DBUG_RETURN(TRUE);
-+ }
-+
-+
-+ send_eof(thd);
-+ DBUG_RETURN(FALSE);
-+
-+}
-
-
- /***************************************************************************
-diff -r c3e57b0c22c4 sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Mon Dec 22 00:20:06 2008 -0800
-+++ b/sql/sql_yacc.yy Mon Dec 22 00:25:06 2008 -0800
-@@ -824,6 +824,7 @@
- %token PAGE_SYM
- %token PARTIAL
- %token PASSWORD
-+%token PATCHES
- %token PARAM_MARKER
- %token PHASE_SYM
- %token POINTFROMTEXT
-@@ -8019,7 +8020,7 @@
- ;
-
- show_param:
-- DATABASES wild_and_where
-+ DATABASES wild_and_where
- {
- LEX *lex= Lex;
- lex->sql_command= SQLCOM_SELECT;
-@@ -8119,6 +8120,10 @@
- LEX *lex=Lex;
- lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
-+ }
-+ | PATCHES
-+ {
-+ Lex->sql_command= SQLCOM_SHOW_PATCHES;
- }
- | opt_storage ENGINES_SYM
- {
-@@ -9554,6 +9559,7 @@
- | PAGE_SYM {}
- | PARTIAL {}
- | PASSWORD {}
-+ | PATCHES {}
- | PHASE_SYM {}
- | POINT_SYM {}
- | POLYGON {}
diff --git a/percona/5.0.87-b20-20100217/userstatv2.patch b/percona/5.0.87-b20-20100217/userstatv2.patch
deleted file mode 100644
index 474eb49..0000000
--- a/percona/5.0.87-b20-20100217/userstatv2.patch
+++ /dev/null
@@ -1,4394 +0,0 @@
-diff -r 592f6c3641ba BUILD/Makefile.in
---- a/BUILD/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/BUILD/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Docs/Makefile.in
---- a/Docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba Makefile.in
---- a/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba SSL/Makefile.in
---- a/SSL/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/SSL/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba client/Makefile.in
---- a/client/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/client/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -247,6 +247,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/Makefile.in
---- a/cmd-line-utils/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -157,6 +157,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/libedit/Makefile.in
---- a/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/libedit/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -166,6 +166,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba cmd-line-utils/readline/Makefile.in
---- a/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/cmd-line-utils/readline/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -173,6 +173,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba configure
---- a/configure Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure Wed Jul 29 13:34:11 2009 -0700
-@@ -35347,7 +35347,91 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+
-+echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-+echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
-+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
-+ echo $ECHO_N "(cached) $ECHO_C" >&6
-+else
-+ ac_check_lib_save_LIBS=$LIBS
-+LIBS="-lrt $LIBS"
-+cat >conftest.$ac_ext <<_ACEOF
-+/* confdefs.h. */
-+_ACEOF
-+cat confdefs.h >>conftest.$ac_ext
-+cat >>conftest.$ac_ext <<_ACEOF
-+/* end confdefs.h. */
-+
-+/* Override any gcc2 internal prototype to avoid an error. */
-+#ifdef __cplusplus
-+extern "C"
-+#endif
-+/* We use char because int might match the return type of a gcc2
-+ builtin and then its argument prototype would still apply. */
-+char clock_gettime ();
-+int
-+main ()
-+{
-+clock_gettime ();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+rm -f conftest.$ac_objext conftest$ac_exeext
-+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-+ (eval $ac_link) 2>conftest.er1
-+ ac_status=$?
-+ grep -v '^ *+' conftest.er1 >conftest.err
-+ rm -f conftest.er1
-+ cat conftest.err >&5
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); } &&
-+ { ac_try='test -z "$ac_c_werror_flag"
-+ || test ! -s conftest.err'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; } &&
-+ { ac_try='test -s conftest$ac_exeext'
-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-+ (eval $ac_try) 2>&5
-+ ac_status=$?
-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
-+ (exit $ac_status); }; }; then
-+ ac_cv_lib_rt_clock_gettime=yes
-+else
-+ echo "$as_me: failed program was:" >&5
-+sed 's/^/| /' conftest.$ac_ext >&5
-+
-+ac_cv_lib_rt_clock_gettime=no
-+fi
-+rm -f conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+LIBS=$ac_check_lib_save_LIBS
-+fi
-+echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-+echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
-+if test $ac_cv_lib_rt_clock_gettime = yes; then
-+ cat >>confdefs.h <<_ACEOF
-+#define HAVE_LIBRT 1
-+_ACEOF
-+
-+ LIBS="-lrt $LIBS"
-+
-+fi
-+
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+
-+
-+ LIBS="$LIBS $LIBRT"
-+
- for ac_func in clock_gettime
- do
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-@@ -38791,7 +38875,7 @@
-
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
-
-
-diff -r 592f6c3641ba configure.in
---- a/configure.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/configure.in Wed Jul 29 13:34:11 2009 -0700
-@@ -2136,7 +2136,18 @@
- # We also disable for SCO for the time being, the headers for the
- # thread library we use conflicts with other headers.
- ;;
-- *) AC_CHECK_FUNCS(clock_gettime)
-+*)
-+ # most systems require the program be linked with librt library to use
-+ # the function clock_gettime
-+ my_save_LIBS="$LIBS"
-+ LIBS=""
-+ AC_CHECK_LIB(rt,clock_gettime)
-+ LIBRT=$LIBS
-+ LIBS="$my_save_LIBS"
-+ AC_SUBST(LIBRT)
-+
-+ LIBS="$LIBS $LIBRT"
-+ AC_CHECK_FUNCS(clock_gettime)
- ;;
- esac
-
-@@ -2772,7 +2783,7 @@
- AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
- fi
-
--CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
-+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
-
- AC_SUBST(CLIENT_LIBS)
- AC_SUBST(NON_THREADED_LIBS)
-diff -r 592f6c3641ba dbug/Makefile.in
---- a/dbug/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/dbug/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/Makefile.in
---- a/extra/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -240,6 +240,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/Makefile.in
---- a/extra/yassl/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/src/Makefile.in
---- a/extra/yassl/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/Makefile.in
---- a/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -142,6 +142,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/benchmark/Makefile.in
---- a/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/benchmark/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/src/Makefile.in
---- a/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -164,6 +164,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/taocrypt/test/Makefile.in
---- a/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/taocrypt/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -153,6 +153,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba extra/yassl/testsuite/Makefile.in
---- a/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/extra/yassl/testsuite/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba heap/Makefile.in
---- a/heap/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/heap/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -202,6 +202,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/Makefile.in
---- a/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -160,6 +160,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba include/mysql_com.h
---- a/include/mysql_com.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/include/mysql_com.h Wed Jul 29 13:34:11 2009 -0700
-@@ -25,6 +25,7 @@
- #define USERNAME_LENGTH 16
- #define SERVER_VERSION_LENGTH 60
- #define SQLSTATE_LENGTH 5
-+#define LIST_PROCESS_HOST_LEN 64
-
- /*
- USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
-@@ -106,6 +107,11 @@
- thread */
- #define REFRESH_MASTER 128 /* Remove all bin logs in the index
- and truncate the index */
-+#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
-+#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
-+#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
-+#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
-+#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
-
- /* The following can't be set with mysql_refresh() */
- #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
-diff -r 592f6c3641ba libmysql/Makefile.in
---- a/libmysql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -224,6 +224,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysql_r/Makefile.in
---- a/libmysql_r/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysql_r/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -221,6 +221,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/Makefile.in
---- a/libmysqld/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -246,6 +246,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba libmysqld/examples/Makefile.in
---- a/libmysqld/examples/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/libmysqld/examples/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -192,6 +192,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba man/Makefile.in
---- a/man/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/man/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -151,6 +151,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisam/Makefile.in
---- a/myisam/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisam/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -235,6 +235,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba myisammrg/Makefile.in
---- a/myisammrg/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/myisammrg/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -183,6 +183,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/Makefile.in
---- a/mysql-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -161,6 +161,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/ndb/Makefile.in
---- a/mysql-test/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -147,6 +147,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba mysql-test/r/information_schema.result
---- a/mysql-test/r/information_schema.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema.result Wed Jul 29 13:34:11 2009 -0700
-@@ -37,10 +37,12 @@
- select * from v1;
- c
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -50,8 +52,10 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- columns_priv
- db
-@@ -83,6 +87,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -102,6 +107,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -121,6 +127,7 @@
- TABLES TABLES
- TABLE_CONSTRAINTS TABLE_CONSTRAINTS
- TABLE_PRIVILEGES TABLE_PRIVILEGES
-+TABLE_STATISTICS TABLE_STATISTICS
- TRIGGERS TRIGGERS
- tables_priv tables_priv
- time_zone time_zone
-@@ -594,12 +601,13 @@
- where table_schema='information_schema' limit 2;
- TABLE_NAME TABLE_TYPE ENGINE
- CHARACTER_SETS SYSTEM VIEW MEMORY
--COLLATIONS SYSTEM VIEW MEMORY
-+CLIENT_STATISTICS SYSTEM VIEW MEMORY
- show tables from information_schema like "T%";
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database information_schema;
- ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
-@@ -609,6 +617,7 @@
- TABLES SYSTEM VIEW
- TABLE_CONSTRAINTS SYSTEM VIEW
- TABLE_PRIVILEGES SYSTEM VIEW
-+TABLE_STATISTICS SYSTEM VIEW
- TRIGGERS SYSTEM VIEW
- create table t1(a int);
- ERROR 42S02: Unknown table 't1' in information_schema
-@@ -621,6 +630,7 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- select table_name from tables where table_name='user';
- table_name
-@@ -730,7 +740,7 @@
- CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
- CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
- count(*)
--102
-+106
- drop view a2, a1;
- drop table t_crashme;
- select table_schema,table_name, column_name from
-@@ -790,18 +800,20 @@
- TABLE_NAME COLUMN_NAME PRIVILEGES
- COLUMNS TABLE_NAME select
- COLUMN_PRIVILEGES TABLE_NAME select
-+INDEX_STATISTICS TABLE_NAME select
- KEY_COLUMN_USAGE TABLE_NAME select
- STATISTICS TABLE_NAME select
- TABLES TABLE_NAME select
- TABLE_CONSTRAINTS TABLE_NAME select
- TABLE_PRIVILEGES TABLE_NAME select
-+TABLE_STATISTICS TABLE_NAME select
- VIEWS TABLE_NAME select
- delete from mysql.user where user='mysqltest_4';
- delete from mysql.db where user='mysqltest_4';
- flush privileges;
- SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
- table_schema count(*)
--information_schema 17
-+information_schema 21
- mysql 17
- create table t1 (i int, j int);
- create trigger trg1 before insert on t1 for each row
-@@ -1187,10 +1199,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1200,8 +1214,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
-@@ -1219,10 +1235,12 @@
- );
- table_name column_name
- CHARACTER_SETS CHARACTER_SET_NAME
-+CLIENT_STATISTICS CLIENT
- COLLATIONS COLLATION_NAME
- COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
- COLUMNS TABLE_SCHEMA
- COLUMN_PRIVILEGES TABLE_SCHEMA
-+INDEX_STATISTICS TABLE_SCHEMA
- KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
- PROFILING QUERY_ID
- ROUTINES ROUTINE_SCHEMA
-@@ -1232,8 +1250,10 @@
- TABLES TABLE_SCHEMA
- TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
- TABLE_PRIVILEGES TABLE_SCHEMA
-+TABLE_STATISTICS TABLE_SCHEMA
- TRIGGERS TRIGGER_SCHEMA
- USER_PRIVILEGES GRANTEE
-+USER_STATISTICS USER
- VIEWS TABLE_SCHEMA
- SELECT MAX(table_name) FROM information_schema.tables;
- MAX(table_name)
-@@ -1302,10 +1322,12 @@
- group by t.table_name order by num1, t.table_name;
- table_name group_concat(t.table_schema, '.', t.table_name) num1
- CHARACTER_SETS information_schema.CHARACTER_SETS 1
-+CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
- COLLATIONS information_schema.COLLATIONS 1
- COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
- COLUMNS information_schema.COLUMNS 1
- COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
-+INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
- KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
- PROFILING information_schema.PROFILING 1
- ROUTINES information_schema.ROUTINES 1
-@@ -1315,8 +1337,10 @@
- TABLES information_schema.TABLES 1
- TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
- TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
-+TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
- TRIGGERS information_schema.TRIGGERS 1
- USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
-+USER_STATISTICS information_schema.USER_STATISTICS 1
- VIEWS information_schema.VIEWS 1
- create table t1(f1 int);
- create view v1 as select f1+1 as a from t1;
-diff -r 592f6c3641ba mysql-test/r/information_schema_db.result
---- a/mysql-test/r/information_schema_db.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/information_schema_db.result Wed Jul 29 13:34:11 2009 -0700
-@@ -6,10 +6,12 @@
- show tables;
- Tables_in_information_schema
- CHARACTER_SETS
-+CLIENT_STATISTICS
- COLLATIONS
- COLLATION_CHARACTER_SET_APPLICABILITY
- COLUMNS
- COLUMN_PRIVILEGES
-+INDEX_STATISTICS
- KEY_COLUMN_USAGE
- PROFILING
- ROUTINES
-@@ -19,14 +21,17 @@
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- USER_PRIVILEGES
-+USER_STATISTICS
- VIEWS
- show tables from INFORMATION_SCHEMA like 'T%';
- Tables_in_information_schema (T%)
- TABLES
- TABLE_CONSTRAINTS
- TABLE_PRIVILEGES
-+TABLE_STATISTICS
- TRIGGERS
- create database `inf%`;
- create database mbase;
-diff -r 592f6c3641ba mysql-test/r/mysqlshow.result
---- a/mysql-test/r/mysqlshow.result Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysql-test/r/mysqlshow.result Wed Jul 29 13:34:11 2009 -0700
-@@ -80,10 +80,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -93,8 +95,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Database: INFORMATION_SCHEMA
-@@ -102,10 +106,12 @@
- | Tables |
- +---------------------------------------+
- | CHARACTER_SETS |
-+| CLIENT_STATISTICS |
- | COLLATIONS |
- | COLLATION_CHARACTER_SET_APPLICABILITY |
- | COLUMNS |
- | COLUMN_PRIVILEGES |
-+| INDEX_STATISTICS |
- | KEY_COLUMN_USAGE |
- | PROFILING |
- | ROUTINES |
-@@ -115,8 +121,10 @@
- | TABLES |
- | TABLE_CONSTRAINTS |
- | TABLE_PRIVILEGES |
-+| TABLE_STATISTICS |
- | TRIGGERS |
- | USER_PRIVILEGES |
-+| USER_STATISTICS |
- | VIEWS |
- +---------------------------------------+
- Wildcard: inf_rmation_schema
-diff -r 592f6c3641ba mysys/Makefile.in
---- a/mysys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/mysys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -228,6 +228,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/Makefile.in
---- a/ndb/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/docs/Makefile.in
---- a/ndb/docs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/docs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -149,6 +149,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/include/Makefile.in
---- a/ndb/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -179,6 +179,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/Makefile.in
---- a/ndb/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/Makefile.in
---- a/ndb/src/common/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -174,6 +174,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/Makefile.in
---- a/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/debugger/signaldata/Makefile.in
---- a/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/debugger/signaldata/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/logger/Makefile.in
---- a/ndb/src/common/logger/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/logger/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/mgmcommon/Makefile.in
---- a/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/mgmcommon/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -211,6 +211,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/portlib/Makefile.in
---- a/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/portlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -222,6 +222,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/transporter/Makefile.in
---- a/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/transporter/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/common/util/Makefile.in
---- a/ndb/src/common/util/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/common/util/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -217,6 +217,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/Makefile.in
---- a/ndb/src/cw/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/cw/cpcd/Makefile.in
---- a/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/cw/cpcd/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/Makefile.in
---- a/ndb/src/kernel/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -227,6 +227,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/Makefile.in
---- a/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/backup/Makefile.in
---- a/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/backup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/cmvmi/Makefile.in
---- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbacc/Makefile.in
---- a/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdict/Makefile.in
---- a/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbdih/Makefile.in
---- a/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -203,6 +203,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dblqh/Makefile.in
---- a/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtc/Makefile.in
---- a/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtup/Makefile.in
---- a/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -204,6 +204,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbtux/Makefile.in
---- a/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/dbutil/Makefile.in
---- a/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbcntr/Makefile.in
---- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/ndbfs/Makefile.in
---- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -197,6 +197,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/qmgr/Makefile.in
---- a/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/suma/Makefile.in
---- a/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/suma/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/blocks/trix/Makefile.in
---- a/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/blocks/trix/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/error/Makefile.in
---- a/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/error/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -206,6 +206,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/kernel/vm/Makefile.in
---- a/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/kernel/vm/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -207,6 +207,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmapi/Makefile.in
---- a/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmclient/Makefile.in
---- a/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmclient/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -216,6 +216,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/mgmsrv/Makefile.in
---- a/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/mgmsrv/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/src/ndbapi/Makefile.in
---- a/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/src/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -215,6 +215,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/Makefile.in
---- a/ndb/test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/Makefile.in
---- a/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -595,6 +595,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/ndbapi/bank/Makefile.in
---- a/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/ndbapi/bank/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -282,6 +282,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/run-test/Makefile.in
---- a/ndb/test/run-test/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/run-test/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -243,6 +243,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/src/Makefile.in
---- a/ndb/test/src/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/src/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -213,6 +213,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/test/tools/Makefile.in
---- a/ndb/test/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/test/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba ndb/tools/Makefile.in
---- a/ndb/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/ndb/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -344,6 +344,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba netware/Makefile.in
---- a/netware/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/netware/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -199,6 +199,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/Makefile.in
---- a/os2/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/Makefile.in
---- a/os2/include/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -156,6 +156,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba os2/include/sys/Makefile.in
---- a/os2/include/sys/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/os2/include/sys/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba patch_info/userstats.info
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/patch_info/userstats.info Wed Jul 29 13:34:11 2009 -0700
-@@ -0,0 +1,14 @@
-+File=userstatsv2.patch
-+Name=SHOW USER/TABLE/INDEX statistics
-+Version=V2
-+Author=Google
-+License=GPL
-+Comment=Added INFORMATION_SCHEMA.*_STATISTICS
-+2008-12-01
-+YK: fix behavior for prepared statements
-+
-+2008-11-26
-+YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
-+
-+2008-12-09
-+YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
-diff -r 592f6c3641ba pstack/Makefile.in
---- a/pstack/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -196,6 +196,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba pstack/aout/Makefile.in
---- a/pstack/aout/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/pstack/aout/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -134,6 +134,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba regex/Makefile.in
---- a/regex/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/regex/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -180,6 +180,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba scripts/Makefile.in
---- a/scripts/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/scripts/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/Makefile.in
---- a/server-tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -155,6 +155,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba server-tools/instance-manager/Makefile.in
---- a/server-tools/instance-manager/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/server-tools/instance-manager/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -205,6 +205,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/Makefile.in
---- a/sql/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -274,6 +274,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/ha_innodb.cc
---- a/sql/ha_innodb.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_innodb.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -3341,6 +3341,8 @@
-
- error = row_insert_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- if (error == DB_SUCCESS && auto_inc_used) {
-
- /* Fetch the value that was set in the autoincrement field */
-@@ -3613,6 +3615,8 @@
- }
- }
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -3661,6 +3665,8 @@
-
- error = row_update_for_mysql((byte*) record, prebuilt);
-
-+ if (error == DB_SUCCESS) rows_changed++;
-+
- innodb_srv_conc_exit_innodb(prebuilt->trx);
-
- error = convert_error_code_to_mysql(error, user_thd);
-@@ -4092,6 +4098,9 @@
- if (ret == DB_SUCCESS) {
- error = 0;
- table->status = 0;
-+ rows_read++;
-+ if (active_index >= 0 && active_index < MAX_KEY)
-+ index_rows_read[active_index]++;
-
- } else if (ret == DB_RECORD_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
-diff -r 592f6c3641ba sql/ha_myisam.cc
---- a/sql/ha_myisam.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/ha_myisam.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -670,7 +670,9 @@
- if ((error= update_auto_increment()))
- return error;
- }
-- return mi_write(file,buf);
-+ int error=mi_write(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
-@@ -1521,13 +1523,17 @@
- statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
-- return mi_update(file,old_data,new_data);
-+ int error=mi_update(file,old_data,new_data);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::delete_row(const byte * buf)
- {
- statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
-- return mi_delete(file,buf);
-+ int error=mi_delete(file,buf);
-+ if (!error) rows_changed++;
-+ return error;
- }
-
- int ha_myisam::index_read(byte * buf, const byte * key,
-@@ -1538,6 +1544,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1548,6 +1561,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,index, key, key_len, find_flag);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1558,6 +1578,13 @@
- &LOCK_status);
- int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1568,6 +1595,13 @@
- &LOCK_status);
- int error=mi_rnext(file,buf,active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1578,6 +1612,13 @@
- &LOCK_status);
- int error=mi_rprev(file,buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1588,6 +1629,13 @@
- &LOCK_status);
- int error=mi_rfirst(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1598,6 +1646,13 @@
- &LOCK_status);
- int error=mi_rlast(file, buf, active_index);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1614,6 +1669,13 @@
- error= mi_rnext_same(file,buf);
- } while (error == HA_ERR_RECORD_DELETED);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) {
-+ rows_read++;
-+
-+ int inx = (active_index == -1) ? file->lastinx : active_index;
-+ if (inx >= 0 && inx < MAX_KEY)
-+ index_rows_read[inx]++;
-+ }
- return error;
- }
-
-@@ -1631,6 +1693,7 @@
- &LOCK_status);
- int error=mi_scan(file, buf);
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-@@ -1645,6 +1708,7 @@
- &LOCK_status);
- int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
- table->status=error ? STATUS_NOT_FOUND: 0;
-+ if (!error) rows_read++;
- return error;
- }
-
-diff -r 592f6c3641ba sql/handler.cc
---- a/sql/handler.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -726,6 +726,8 @@
- if (cookie)
- tc_log->unlog(cookie, xid);
- DBUG_EXECUTE_IF("crash_commit_after", abort(););
-+ if (is_real_trans)
-+ thd->diff_commit_trans++;
- end:
- if (is_real_trans)
- start_waiting_global_read_lock(thd);
-@@ -783,6 +785,7 @@
- thd->transaction.cleanup();
- }
- }
-+ thd->diff_rollback_trans++;
- #endif /* USING_TRANSACTIONS */
- DBUG_RETURN(error);
- }
-@@ -1223,6 +1226,7 @@
- statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
- *ht=0; // keep it conveniently zero-filled
- }
-+ thd->diff_rollback_trans++;
- DBUG_RETURN(error);
- }
-
-@@ -1453,6 +1457,8 @@
- else
- dupp_ref=ref+ALIGN_SIZE(ref_length);
- }
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
- DBUG_RETURN(error);
- }
-
-@@ -2287,6 +2293,111 @@
- return error;
- }
-
-+// Updates the global table stats with the TABLE this handler represents.
-+void handler::update_global_table_stats() {
-+ if (!opt_userstat_running) {
-+ rows_read = rows_changed = 0;
-+ return;
-+ }
-+
-+ if (!rows_read && !rows_changed) return; // Nothing to update.
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ TABLE_STATS* table_stats;
-+ char key[NAME_LEN * 2 + 2];
-+ // [db] + '.' + [table]
-+ sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ // Gets the global table stats, creating one if necessary.
-+ if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(table_stats = ((TABLE_STATS*)
-+ my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating table stats failed.");
-+ goto end;
-+ }
-+ strncpy(table_stats->table, key, sizeof(table_stats->table));
-+ table_stats->rows_read = 0;
-+ table_stats->rows_changed = 0;
-+ table_stats->rows_changed_x_indexes = 0;
-+ table_stats->engine_type = (int) ht->db_type;
-+
-+ if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting table stats failed.");
-+ my_free((char*)table_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global table stats.
-+ table_stats->rows_read += rows_read;
-+ table_stats->rows_changed += rows_changed;
-+ table_stats->rows_changed_x_indexes +=
-+ rows_changed * (table->s->keys ? table->s->keys : 1);
-+ current_thd->diff_total_read_rows += rows_read;
-+ rows_read = rows_changed = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+}
-+
-+// Updates the global index stats with this handler's accumulated index reads.
-+void handler::update_global_index_stats() {
-+ // table_cache_key is db_name + '\0' + table_name + '\0'.
-+ if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
-+
-+ if (!opt_userstat_running) {
-+ for (int x = 0; x < table->s->keys; x++) {
-+ index_rows_read[x] = 0;
-+ }
-+ return;
-+ }
-+
-+ for (int x = 0; x < table->s->keys; x++) {
-+ if (index_rows_read[x]) {
-+ // Rows were read using this index.
-+ KEY* key_info = &table->key_info[x];
-+
-+ if (!key_info->name) continue;
-+
-+ INDEX_STATS* index_stats;
-+ char key[NAME_LEN * 3 + 3];
-+ // [db] + '.' + [table] + '.' + [index]
-+ sprintf(key, "%s.%s.%s", table->s->table_cache_key,
-+ table->s->table_name, key_info->name);
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ // Gets the global index stats, creating one if necessary.
-+ if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
-+ (byte*)key,
-+ strlen(key)))) {
-+ if (!(index_stats = ((INDEX_STATS*)
-+ my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
-+ // Out of memory.
-+ sql_print_error("Allocating index stats failed.");
-+ goto end;
-+ }
-+ strncpy(index_stats->index, key, sizeof(index_stats->index));
-+ index_stats->rows_read = 0;
-+
-+ if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
-+ // Out of memory.
-+ sql_print_error("Inserting index stats failed.");
-+ my_free((char*)index_stats, 0);
-+ goto end;
-+ }
-+ }
-+ // Updates the global index stats.
-+ index_stats->rows_read += index_rows_read[x];
-+ index_rows_read[x] = 0;
-+end:
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ }
-+}
-
- /****************************************************************************
- ** Some general functions that isn't in the handler class
-diff -r 592f6c3641ba sql/handler.h
---- a/sql/handler.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/handler.h Wed Jul 29 13:34:11 2009 -0700
-@@ -32,6 +32,10 @@
- #define USING_TRANSACTIONS
- #endif
-
-+#if MAX_KEY > 128
-+#error MAX_KEY is too large. Values up to 128 are supported.
-+#endif
-+
- // the following is for checking tables
-
- #define HA_ADMIN_ALREADY_DONE 1
-@@ -604,6 +608,9 @@
- bool auto_increment_column_changed;
- bool implicit_emptied; /* Can be !=0 only if HEAP */
- const COND *pushed_cond;
-+ ulonglong rows_read;
-+ ulonglong rows_changed;
-+ ulonglong index_rows_read[MAX_KEY];
-
- handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
- ht(ht_arg),
-@@ -615,8 +622,10 @@
- ref_length(sizeof(my_off_t)), block_size(0),
- raid_type(0), ft_handler(0), inited(NONE),
- locked(FALSE), implicit_emptied(0),
-- pushed_cond(NULL)
-- {}
-+ pushed_cond(NULL), rows_read(0), rows_changed(0)
-+ {
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
- virtual handler *clone(MEM_ROOT *mem_root);
- int ha_open(const char *name, int mode, int test_if_locked);
-@@ -625,7 +634,11 @@
- virtual void print_error(int error, myf errflag);
- virtual bool get_error_message(int error, String *buf);
- uint get_dup_key(int error);
-- void change_table_ptr(TABLE *table_arg) { table=table_arg; }
-+ void change_table_ptr(TABLE *table_arg) {
-+ table=table_arg;
-+ rows_read = rows_changed = 0;
-+ memset(index_rows_read, 0, sizeof(index_rows_read));
-+ }
- virtual double scan_time()
- { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
- virtual double read_time(uint index, uint ranges, ha_rows rows)
-@@ -886,6 +899,9 @@
- virtual bool is_crashed() const { return 0; }
- virtual bool auto_repair() const { return 0; }
-
-+ void update_global_table_stats();
-+ void update_global_index_stats();
-+
- /*
- default rename_table() and delete_table() rename/delete files with a
- given name and extensions from bas_ext()
-diff -r 592f6c3641ba sql/lex.h
---- a/sql/lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -109,6 +109,7 @@
- { "CHECKSUM", SYM(CHECKSUM_SYM)},
- { "CIPHER", SYM(CIPHER_SYM)},
- { "CLIENT", SYM(CLIENT_SYM)},
-+ { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
- { "CLOSE", SYM(CLOSE_SYM)},
- { "CODE", SYM(CODE_SYM)},
- { "COLLATE", SYM(COLLATE_SYM)},
-@@ -238,6 +239,7 @@
- { "IN", SYM(IN_SYM)},
- { "INDEX", SYM(INDEX_SYM)},
- { "INDEXES", SYM(INDEXES)},
-+ { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
- { "INFILE", SYM(INFILE)},
- { "INNER", SYM(INNER_SYM)},
- { "INNOBASE", SYM(INNOBASE_SYM)},
-@@ -443,6 +445,7 @@
- { "SIGNED", SYM(SIGNED_SYM)},
- { "SIMPLE", SYM(SIMPLE_SYM)},
- { "SLAVE", SYM(SLAVE)},
-+ { "SLOW", SYM(SLOW_SYM)},
- { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
- { "SMALLINT", SYM(SMALLINT)},
- { "SOME", SYM(ANY_SYM)},
-@@ -488,6 +491,7 @@
- { "TABLE", SYM(TABLE_SYM)},
- { "TABLES", SYM(TABLES)},
- { "TABLESPACE", SYM(TABLESPACE)},
-+ { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
- { "TEMPORARY", SYM(TEMPORARY)},
- { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
- { "TERMINATED", SYM(TERMINATED)},
-@@ -525,6 +529,7 @@
- { "USE", SYM(USE_SYM)},
- { "USER", SYM(USER)},
- { "USER_RESOURCES", SYM(RESOURCES)},
-+ { "USER_STATISTICS", SYM(USER_STATS_SYM)},
- { "USE_FRM", SYM(USE_FRM)},
- { "USING", SYM(USING)},
- { "UTC_DATE", SYM(UTC_DATE_SYM)},
-diff -r 592f6c3641ba sql/log.cc
---- a/sql/log.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/log.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -1958,18 +1958,24 @@
- thd->current_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->insert_id_used)
- {
- Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->rand_used)
- {
- Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- if (thd->user_var_events.elements)
- {
-@@ -1985,6 +1991,8 @@
- user_var_event->charset_number);
- if (e.write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += e.data_written;
- }
- }
- }
-@@ -1995,6 +2003,8 @@
-
- if (event_info->write(file))
- goto err;
-+ if (file == &log_file)
-+ thd->binlog_bytes_written += event_info->data_written;
-
- if (file == &log_file) // we are writing to the real log (disk)
- {
-@@ -2117,6 +2127,7 @@
- */
- if (qinfo.write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += qinfo.data_written;
-
- /* Read from the file used to cache the queries .*/
- if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
-@@ -2163,6 +2174,7 @@
- /* write the first half of the split header */
- if (my_b_write(&log_file, header, carry))
- goto err;
-+ thd->binlog_bytes_written += carry;
-
- /*
- copy fixed second half of header to cache so the correct
-@@ -2231,6 +2243,8 @@
- /* Write data to the binary log file */
- if (my_b_write(&log_file, cache->read_pos, length))
- goto err;
-+ thd->binlog_bytes_written += length;
-+
- cache->read_pos=cache->read_end; // Mark buffer used up
- DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
- } while ((length=my_b_fill(cache)));
-@@ -2239,6 +2253,8 @@
-
- if (commit_event->write(&log_file))
- goto err;
-+ thd->binlog_bytes_written += commit_event->data_written;
-+
- #ifndef DBUG_OFF
- DBUG_skip_commit:
- #endif
-diff -r 592f6c3641ba sql/mysql_priv.h
---- a/sql/mysql_priv.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysql_priv.h Wed Jul 29 13:34:11 2009 -0700
-@@ -837,7 +837,15 @@
- bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
- void init_max_user_conn(void);
- void init_update_queries(void);
-+void init_global_user_stats(void);
-+void init_global_table_stats(void);
-+void init_global_index_stats(void);
-+void init_global_client_stats(void);
- void free_max_user_conn(void);
-+void free_global_user_stats(void);
-+void free_global_table_stats(void);
-+void free_global_index_stats(void);
-+void free_global_client_stats(void);
- pthread_handler_t handle_one_connection(void *arg);
- pthread_handler_t handle_bootstrap(void *arg);
- void end_thread(THD *thd,bool put_in_cache);
-@@ -1416,6 +1424,7 @@
- extern ulong max_connections,max_connect_errors, connect_timeout;
- extern ulong slave_net_timeout, slave_trans_retries;
- extern uint max_user_connections;
-+extern ulonglong denied_connections;
- extern ulong what_to_log,flush_time;
- extern ulong query_buff_size, thread_stack;
- extern ulong max_prepared_stmt_count, prepared_stmt_count;
-@@ -1446,6 +1455,7 @@
- extern my_bool opt_safe_show_db, opt_local_infile;
- extern my_bool opt_slave_compressed_protocol, use_temp_pool;
- extern my_bool opt_readonly, lower_case_file_system;
-+extern my_bool opt_userstat_running;
- extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
- extern my_bool opt_secure_auth;
- extern char* opt_secure_file_priv;
-@@ -1493,6 +1503,14 @@
- extern struct system_variables max_system_variables;
- extern struct system_status_var global_status_var;
- extern struct rand_struct sql_rand;
-+extern HASH global_user_stats;
-+extern HASH global_client_stats;
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+extern HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+extern HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+extern pthread_mutex_t LOCK_stats;
-
- extern const char *opt_date_time_formats[];
- extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-diff -r 592f6c3641ba sql/mysqld.cc
---- a/sql/mysqld.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/mysqld.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -417,6 +417,7 @@
- uint opt_large_page_size= 0;
- my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
- char* opt_slow_logname= 0;
-+my_bool opt_userstat_running= 0;
- /*
- True if there is at least one per-hour limit for some user, so we should
- check them before each query (and possibly reset counters when hour is
-@@ -453,6 +454,7 @@
- ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
- ulong max_connections, max_connect_errors;
- uint max_user_connections= 0;
-+ulonglong denied_connections = 0;
- /*
- Limit of the total number of prepared statements in the server.
- Is necessary to protect the server against out-of-memory attacks.
-@@ -555,6 +557,10 @@
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
- LOCK_global_system_variables,
- LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
-+pthread_mutex_t LOCK_stats;
-+pthread_mutex_t LOCK_global_user_client_stats;
-+pthread_mutex_t LOCK_global_table_stats;
-+pthread_mutex_t LOCK_global_index_stats;
- /*
- The below lock protects access to two global server variables:
- max_prepared_stmt_count and prepared_stmt_count. These variables
-@@ -1196,6 +1202,10 @@
- x_free(opt_secure_file_priv);
- bitmap_free(&temp_pool);
- free_max_user_conn();
-+ free_global_user_stats();
-+ free_global_client_stats();
-+ free_global_table_stats();
-+ free_global_index_stats();
- #ifdef HAVE_REPLICATION
- end_slave_list();
- free_list(&replicate_do_db);
-@@ -1310,6 +1320,10 @@
- (void) pthread_cond_destroy(&COND_thread_cache);
- (void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
-+ (void) pthread_mutex_destroy(&LOCK_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_table_stats);
-+ (void) pthread_mutex_destroy(&LOCK_global_index_stats);
- }
-
- #endif /*EMBEDDED_LIBRARY*/
-@@ -3157,6 +3171,10 @@
- (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
- (void) pthread_cond_init(&COND_rpl_status, NULL);
- #endif
-+ (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
-+ (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
- sp_cache_init();
- /* Parameter for threads created for connections */
- (void) pthread_attr_init(&connection_attrib);
-@@ -3428,6 +3446,10 @@
- sql_print_error("Out of memory");
- unireg_abort(1);
- }
-+
-+ init_global_table_stats();
-+ init_global_index_stats();
-+
- if (ha_init())
- {
- sql_print_error("Can't init databases");
-@@ -3510,6 +3532,8 @@
-
- init_max_user_conn();
- init_update_queries();
-+ init_global_user_stats();
-+ init_global_client_stats();
- DBUG_RETURN(0);
- }
-
-@@ -4236,6 +4260,7 @@
- {
- DBUG_PRINT("error",("Too many connections"));
- close_connection(thd, ER_CON_COUNT_ERROR, 1);
-+ statistic_increment(denied_connections, &LOCK_status);
- delete thd;
- DBUG_VOID_RETURN;
- }
-@@ -5056,6 +5081,7 @@
- OPT_PROFILING_USE_GETRUSAGE,
- OPT_SLOW_LOG,
- OPT_SLOW_QUERY_LOG_FILE,
-+ OPT_USERSTAT_RUNNING,
- OPT_USE_GLOBAL_LONG_QUERY_TIME,
- OPT_INNODB_ROLLBACK_ON_TIMEOUT,
- OPT_SECURE_FILE_PRIV,
-@@ -6523,6 +6549,10 @@
- (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
- REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
- 0, 1, 0},
-+ {"userstat_running", OPT_USERSTAT_RUNNING,
-+ "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
-+ (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
-+ 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
- {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
- };
-
-diff -r 592f6c3641ba sql/set_var.cc
---- a/sql/set_var.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/set_var.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -325,6 +325,7 @@
- sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
- &SV::read_buff_size);
- sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
-+sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
- sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
- &SV::read_rnd_buff_size);
- sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
-@@ -837,6 +838,7 @@
- &sys_trans_alloc_block_size,
- &sys_trans_prealloc_size,
- &sys_tx_isolation,
-+ &sys_userstat_running,
- &sys_version,
- #ifdef HAVE_BERKELEY_DB
- &sys_version_bdb,
-@@ -1190,6 +1192,7 @@
- {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
- {sys_updatable_views_with_limit.name,
- (char*) &sys_updatable_views_with_limit,SHOW_SYS},
-+ {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
- {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
- {sys_version.name, (char*) &sys_version, SHOW_SYS},
- #ifdef HAVE_BERKELEY_DB
-diff -r 592f6c3641ba sql/share/Makefile.in
---- a/sql/share/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/share/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba sql/sql_base.cc
---- a/sql/sql_base.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_base.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -624,6 +624,12 @@
- DBUG_ENTER("close_thread_table");
- DBUG_ASSERT(table->key_read == 0);
- DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
-+
-+ if(table->file)
-+ {
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
-+ }
-
- *table_ptr=table->next;
- if (table->needs_reopen_or_name_lock() ||
-@@ -670,6 +676,9 @@
- {
- DBUG_ENTER("close_temporary");
- char path[FN_REFLEN];
-+
-+ table->file->update_global_table_stats();
-+ table->file->update_global_index_stats();
- db_type table_type=table->s->db_type;
- strmov(path,table->s->path);
- free_io_cache(table);
-diff -r 592f6c3641ba sql/sql_class.cc
---- a/sql/sql_class.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -239,6 +239,13 @@
- bzero(ha_data, sizeof(ha_data));
- mysys_var=0;
- binlog_evt_union.do_union= FALSE;
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- #ifndef DBUG_OFF
- dbug_sentry=THD_SENTRY_MAGIC;
- #endif
-@@ -378,6 +385,88 @@
- total_warn_count= 0;
- update_charset();
- bzero((char *) &status_var, sizeof(status_var));
-+ reset_stats();
-+}
-+
-+// Resets stats in a THD.
-+void THD::reset_stats(void) {
-+ current_connect_time = time(NULL);
-+ last_global_update_time = current_connect_time;
-+ reset_diff_stats();
-+}
-+
-+// Resets the 'diff' stats, which are used to update global stats.
-+void THD::reset_diff_stats(void) {
-+ diff_total_busy_time = 0;
-+ diff_total_cpu_time = 0;
-+ diff_total_bytes_received = 0;
-+ diff_total_bytes_sent = 0;
-+ diff_total_binlog_bytes_written = 0;
-+ diff_total_sent_rows = 0;
-+ diff_total_updated_rows = 0;
-+ diff_total_read_rows = 0;
-+ diff_select_commands = 0;
-+ diff_update_commands = 0;
-+ diff_other_commands = 0;
-+ diff_commit_trans = 0;
-+ diff_rollback_trans = 0;
-+ diff_denied_connections = 0;
-+ diff_lost_connections = 0;
-+ diff_access_denied_errors = 0;
-+ diff_empty_queries = 0;
-+}
-+
-+// Updates 'diff' stats of a THD.
-+void THD::update_stats(bool ran_command) {
-+ if (opt_userstat_running) {
-+ diff_total_busy_time += busy_time;
-+ diff_total_cpu_time += cpu_time;
-+ diff_total_bytes_received += bytes_received;
-+ diff_total_bytes_sent += bytes_sent;
-+ diff_total_binlog_bytes_written += binlog_bytes_written;
-+ diff_total_sent_rows += sent_row_count_2;
-+ diff_total_updated_rows += updated_row_count;
-+ // diff_total_read_rows is updated in handler.cc.
-+
-+ if (ran_command) {
-+ // The replication thread has the COM_CONNECT command.
-+ if ((old_command == COM_QUERY || command == COM_CONNECT) &&
-+ (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
-+ // A SQL query.
-+ if (lex->sql_command == SQLCOM_SELECT) {
-+ if (lex->orig_sql_command == SQLCOM_END) {
-+ diff_select_commands++;
-+ if (!sent_row_count_2)
-+ diff_empty_queries++;
-+ } else {
-+ // 'SHOW ' commands become SQLCOM_SELECT.
-+ diff_other_commands++;
-+ // 'SHOW ' commands shouldn't inflate total sent row count.
-+ diff_total_sent_rows -= sent_row_count_2;
-+ }
-+ } else if (is_update_query(lex->sql_command)) {
-+ diff_update_commands++;
-+ } else {
-+ diff_other_commands++;
-+ }
-+ }
-+ }
-+ // diff_commit_trans is updated in handler.cc.
-+ // diff_rollback_trans is updated in handler.cc.
-+ // diff_denied_connections is updated in sql_parse.cc.
-+ // diff_lost_connections is updated in sql_parse.cc.
-+ // diff_access_denied_errors is updated in sql_parse.cc.
-+
-+ /* reset counters to zero to avoid double-counting since values
-+ are already store in diff_total_*. */
-+ }
-+ busy_time = 0;
-+ cpu_time = 0;
-+ bytes_received = 0;
-+ bytes_sent = 0;
-+ binlog_bytes_written = 0;
-+ updated_row_count = 0;
-+ sent_row_count_2 = 0;
- }
-
-
-@@ -907,6 +996,33 @@
- }
- #endif
-
-+char *THD::get_client_host_port(THD *client)
-+{
-+ Security_context *client_sctx= client->security_ctx;
-+ char *client_host= NULL;
-+
-+ if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
-+ security_ctx->host_or_ip[0])
-+ {
-+ if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
-+ my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
-+ "%s:%u", client_sctx->host_or_ip, client->peer_port);
-+ }
-+ else
-+ client_host= this->strdup(client_sctx->host_or_ip[0] ?
-+ client_sctx->host_or_ip :
-+ client_sctx->host ? client_sctx->host : "");
-+
-+ return client_host;
-+}
-+
-+const char *get_client_host(THD *client)
-+{
-+ return client->security_ctx->host_or_ip[0] ?
-+ client->security_ctx->host_or_ip :
-+ client->security_ctx->host ? client->security_ctx->host : "";
-+}
-+
-
- struct Item_change_record: public ilink
- {
-@@ -1082,6 +1198,7 @@
- buffer.set(buff, sizeof(buff), &my_charset_bin);
- }
- thd->sent_row_count++;
-+ thd->sent_row_count_2++;
- if (!thd->vio_ok())
- DBUG_RETURN(0);
- if (!thd->net.report_error)
-@@ -1174,6 +1291,7 @@
- select_export::~select_export()
- {
- thd->sent_row_count=row_count;
-+ thd->sent_row_count_2=row_count;
- }
-
-
-@@ -2108,6 +2226,7 @@
- if (likely(thd != 0))
- { /* current_thd==0 when close_connection() calls net_send_error() */
- thd->status_var.bytes_sent+= length;
-+ thd->bytes_sent+= length;
- }
- }
-
-@@ -2115,6 +2234,7 @@
- void thd_increment_bytes_received(ulong length)
- {
- current_thd->status_var.bytes_received+= length;
-+ current_thd->bytes_received+= length;
- }
-
-
-diff -r 592f6c3641ba sql/sql_class.h
---- a/sql/sql_class.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_class.h Wed Jul 29 13:34:11 2009 -0700
-@@ -1302,6 +1302,8 @@
- first byte of the packet in do_command()
- */
- enum enum_server_command command;
-+ // Used to save the command, before it is set to COM_SLEEP.
-+ enum enum_server_command old_command;
- uint32 server_id;
- uint32 file_id; // for LOAD DATA INFILE
- /*
-@@ -1498,6 +1500,8 @@
- /* variables.transaction_isolation is reset to this after each commit */
- enum_tx_isolation session_tx_isolation;
- enum_check_fields count_cuted_fields;
-+ ha_rows updated_row_count;
-+ ha_rows sent_row_count_2; /* for userstat */
-
- DYNAMIC_ARRAY user_var_events; /* For user variables replication */
- MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
-@@ -1607,6 +1611,49 @@
- */
- LOG_INFO* current_linfo;
- NET* slave_net; // network connection from slave -> m.
-+
-+ /*
-+ Used to update global user stats. The global user stats are updated
-+ occasionally with the 'diff' variables. After the update, the 'diff'
-+ variables are reset to 0.
-+ */
-+ // Time when the current thread connected to MySQL.
-+ time_t current_connect_time;
-+ // Last time when THD stats were updated in global_user_stats.
-+ time_t last_global_update_time;
-+ // Busy (non-idle) time for just one command.
-+ double busy_time;
-+ // Busy time not updated in global_user_stats yet.
-+ double diff_total_busy_time;
-+ // Cpu (non-idle) time for just one thread.
-+ double cpu_time;
-+ // Cpu time not updated in global_user_stats yet.
-+ double diff_total_cpu_time;
-+ /* bytes counting */
-+ ulonglong bytes_received;
-+ ulonglong diff_total_bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong diff_total_bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ulonglong diff_total_binlog_bytes_written;
-+
-+ // Number of rows not reflected in global_user_stats yet.
-+ ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
-+ // Number of commands not reflected in global_user_stats yet.
-+ ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
-+ // Number of transactions not reflected in global_user_stats yet.
-+ ulonglong diff_commit_trans, diff_rollback_trans;
-+ // Number of connection errors not reflected in global_user_stats yet.
-+ ulonglong diff_denied_connections, diff_lost_connections;
-+ // Number of db access denied, not reflected in global_user_stats yet.
-+ ulonglong diff_access_denied_errors;
-+ // Number of queries that return 0 rows
-+ ulonglong diff_empty_queries;
-+
-+ // Per account query delay in miliseconds. When not 0, sleep this number of
-+ // milliseconds before every SQL command.
-+ ulonglong query_delay_millis;
-+
- /* Used by the sys_var class to store temporary values */
- union
- {
-@@ -1662,6 +1709,11 @@
- alloc_root.
- */
- void init_for_queries();
-+ void reset_stats(void);
-+ void reset_diff_stats(void);
-+ // ran_command is true when this is called immediately after a
-+ // command has been run.
-+ void update_stats(bool ran_command);
- void change_user(void);
- void cleanup(void);
- void cleanup_after_query();
-@@ -1891,8 +1943,14 @@
- if (p_db_length)
- *p_db_length= db_length;
- return FALSE;
-+
-+ // Returns string as 'IP:port' for the client-side of the connnection represented
-+ // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
-+ // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
- }
-
-+ char *get_client_host_port(THD *client);
-+
- public:
- /**
- Add an internal error handler to the thread execution context.
-@@ -1935,6 +1993,10 @@
- MEM_ROOT main_mem_root;
- };
-
-+// Returns string as 'IP' for the client-side of the connection represented by
-+// 'client'. Does not allocate memory. May return "".
-+const char *get_client_host(THD *client);
-+
-
- #define tmp_disable_binlog(A) \
- {ulonglong tmp_disable_binlog__save_options= (A)->options; \
-diff -r 592f6c3641ba sql/sql_delete.cc
---- a/sql/sql_delete.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_delete.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -358,6 +358,7 @@
- send_ok(thd,deleted);
- DBUG_PRINT("info",("%ld records deleted",(long) deleted));
- }
-+ thd->updated_row_count += deleted;
- DBUG_RETURN(error >= 0 || thd->net.report_error);
- }
-
-@@ -887,6 +888,7 @@
- thd->row_count_func= deleted;
- ::send_ok(thd, deleted);
- }
-+ thd->updated_row_count += deleted;
- return 0;
- }
-
-diff -r 592f6c3641ba sql/sql_insert.cc
---- a/sql/sql_insert.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_insert.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -990,6 +990,7 @@
- thd->row_count_func= info.copied + info.deleted + updated;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
- }
-+ thd->updated_row_count += thd->row_count_func;
- thd->abort_on_warning= 0;
- DBUG_RETURN(FALSE);
-
-@@ -3094,6 +3095,7 @@
- autoinc_value_of_first_inserted_row : thd->insert_id_used ?
- thd->last_insert_id : 0;
- ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
-+ thd->updated_row_count += thd->row_count_func;
- DBUG_RETURN(0);
- }
-
-diff -r 592f6c3641ba sql/sql_lex.h
---- a/sql/sql_lex.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_lex.h Wed Jul 29 13:34:11 2009 -0700
-@@ -101,6 +101,9 @@
- When a command is added here, be sure it's also added in mysqld.cc
- in "struct show_var_st status_vars[]= {" ...
- */
-+ // TODO(mcallaghan): update status_vars in mysqld to export these
-+ SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
-+ SQLCOM_SHOW_CLIENT_STATS,
- /* This should be the last !!! */
- SQLCOM_END
- };
-diff -r 592f6c3641ba sql/sql_parse.cc
---- a/sql/sql_parse.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_parse.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -78,6 +78,12 @@
- const char *table_name);
- static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
-
-+// Increments connection count for user.
-+static int increment_connection_count(THD* thd, bool use_lock);
-+
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- const char *any_db="*any*"; // Special symbol for check_access
-
- const char *command_name[]={
-@@ -146,6 +152,17 @@
- static bool do_command(THD *thd);
- #endif // EMBEDDED_LIBRARY
-
-+HASH global_user_stats;
-+HASH global_client_stats;
-+// Protects global_user_stats and global_client_stats
-+extern pthread_mutex_t LOCK_global_user_client_stats;
-+
-+HASH global_table_stats;
-+extern pthread_mutex_t LOCK_global_table_stats;
-+
-+HASH global_index_stats;
-+extern pthread_mutex_t LOCK_global_index_stats;
-+
- #ifdef __WIN__
- extern void win_install_sigabrt_handler(void);
- #endif
-@@ -504,6 +521,7 @@
- mysql_log.write(thd,COM_CONNECT,"%s",ER(ER_NOT_SUPPORTED_AUTH_MODE));
- DBUG_RETURN(-1);
- }
-+ thd->diff_access_denied_errors++;
- net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
- thd->main_security_ctx.user,
- thd->main_security_ctx.host_or_ip,
-@@ -536,12 +554,190 @@
- void init_max_user_conn(void)
- {
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
-- (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
-- 0,0,
-- (hash_get_key) get_key_conn, (hash_free_key) free_user,
-- 0);
--#endif
--}
-+ if (hash_init(&hash_user_connections,system_charset_info,max_connections,
-+ 0,0,
-+ (hash_get_key) get_key_conn, (hash_free_key) free_user,
-+ 0)) {
-+ sql_print_error("Initializing hash_user_connections failed.");
-+ exit(1);
-+ }
-+#endif
-+}
-+
-+byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(user_stats->user);
-+ return (byte*)user_stats->user;
-+}
-+
-+void free_user_stats(USER_STATS* user_stats)
-+{
-+ my_free((char*)user_stats, MYF(0));
-+}
-+
-+void init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ DBUG_ENTER("init_user_stats");
-+ DBUG_PRINT("info",
-+ ("Add user_stats entry for user %s - priv_user %s",
-+ user, priv_user));
-+ strncpy(user_stats->user, user, sizeof(user_stats->user));
-+ strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
-+
-+ user_stats->total_connections = total_connections;
-+ user_stats->concurrent_connections = concurrent_connections;
-+ user_stats->connected_time = connected_time;
-+ user_stats->busy_time = busy_time;
-+ user_stats->cpu_time = cpu_time;
-+ user_stats->bytes_received = bytes_received;
-+ user_stats->bytes_sent = bytes_sent;
-+ user_stats->binlog_bytes_written = binlog_bytes_written;
-+ user_stats->rows_fetched = rows_fetched;
-+ user_stats->rows_updated = rows_updated;
-+ user_stats->rows_read = rows_read;
-+ user_stats->select_commands = select_commands;
-+ user_stats->update_commands = update_commands;
-+ user_stats->other_commands = other_commands;
-+ user_stats->commit_trans = commit_trans;
-+ user_stats->rollback_trans = rollback_trans;
-+ user_stats->denied_connections = denied_connections;
-+ user_stats->lost_connections = lost_connections;
-+ user_stats->access_denied_errors = access_denied_errors;
-+ user_stats->empty_queries = empty_queries;
-+ DBUG_VOID_RETURN;
-+}
-+
-+void add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries)
-+{
-+ user_stats->total_connections += total_connections;
-+ user_stats->concurrent_connections += concurrent_connections;
-+ user_stats->connected_time += connected_time;
-+ user_stats->busy_time += busy_time;
-+ user_stats->cpu_time += cpu_time;
-+ user_stats->bytes_received += bytes_received;
-+ user_stats->bytes_sent += bytes_sent;
-+ user_stats->binlog_bytes_written += binlog_bytes_written;
-+ user_stats->rows_fetched += rows_fetched;
-+ user_stats->rows_updated += rows_updated;
-+ user_stats->rows_read += rows_read;
-+ user_stats->select_commands += select_commands;
-+ user_stats->update_commands += update_commands;
-+ user_stats->other_commands += other_commands;
-+ user_stats->commit_trans += commit_trans;
-+ user_stats->rollback_trans += rollback_trans;
-+ user_stats->denied_connections += denied_connections;
-+ user_stats->lost_connections += lost_connections;
-+ user_stats->access_denied_errors += access_denied_errors;
-+ user_stats->empty_queries += empty_queries;
-+}
-+
-+void init_global_user_stats(void)
-+{
-+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_user_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+void init_global_client_stats(void)
-+{
-+ if (hash_init(&global_client_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0)) {
-+ sql_print_error("Initializing global_client_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(table_stats->table);
-+ return (byte*)table_stats->table;
-+}
-+
-+extern "C" void free_table_stats(TABLE_STATS* table_stats)
-+{
-+ my_free((char*)table_stats, MYF(0));
-+}
-+
-+void init_global_table_stats(void)
-+{
-+ if (hash_init(&global_table_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_table_stats,
-+ (hash_free_key)free_table_stats, 0)) {
-+ sql_print_error("Initializing global_table_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-+extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
-+ my_bool not_used __attribute__((unused)))
-+{
-+ *length = strlen(index_stats->index);
-+ return (byte*)index_stats->index;
-+}
-+
-+extern "C" void free_index_stats(INDEX_STATS* index_stats)
-+{
-+ my_free((char*)index_stats, MYF(0));
-+}
-+
-+void init_global_index_stats(void)
-+{
-+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
-+ 0, 0, (hash_get_key)get_key_index_stats,
-+ (hash_free_key)free_index_stats, 0)) {
-+ sql_print_error("Initializing global_index_stats failed.");
-+ exit(1);
-+ }
-+}
-+
-
-
- /*
-@@ -599,7 +795,10 @@
-
- end:
- if (error)
-+ {
-+ statistic_increment(denied_connections, &LOCK_status);
- uc->connections--; // no need for decrease_user_connections() here
-+ }
- (void) pthread_mutex_unlock(&LOCK_user_conn);
- DBUG_RETURN(error);
- }
-@@ -646,6 +845,25 @@
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-
-+void free_global_user_stats(void)
-+{
-+ hash_free(&global_user_stats);
-+}
-+
-+void free_global_table_stats(void)
-+{
-+ hash_free(&global_table_stats);
-+}
-+
-+void free_global_index_stats(void)
-+{
-+ hash_free(&global_index_stats);
-+}
-+
-+void free_global_client_stats(void)
-+{
-+ hash_free(&global_client_stats);
-+}
-
-
- /*
-@@ -698,6 +916,214 @@
- return uc_update_queries[command] != 0;
- }
-
-+// 'mysql_system_user' is used for when the user is not defined for a THD.
-+static char mysql_system_user[] = "#mysql_system#";
-+
-+// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
-+static char* get_valid_user_string(char* user) {
-+ return user ? user : mysql_system_user;
-+}
-+
-+// Increments the global stats connection count for an entry from
-+// global_client_stats or global_user_stats. Returns 0 on success
-+// and 1 on error.
-+static int increment_count_by_name(const char *name, const char *role_name,
-+ HASH *users_or_clients, THD *thd)
-+{
-+ USER_STATS* user_stats;
-+
-+ if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
-+ strlen(name))))
-+ {
-+ // First connection for this user or client
-+ if (!(user_stats = ((USER_STATS*)
-+ my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
-+ {
-+ return 1; // Out of memory
-+ }
-+
-+ init_user_stats(user_stats, name, role_name,
-+ 0, 0, // connections
-+ 0, 0, 0, // time
-+ 0, 0, 0, // bytes sent, received and written
-+ 0, 0, 0, // rows fetched, updated and read
-+ 0, 0, 0, // select, update and other commands
-+ 0, 0, // commit and rollback trans
-+ thd->diff_denied_connections,
-+ 0, // lost connections
-+ 0, // access denied errors
-+ 0); // empty queries
-+
-+ if (my_hash_insert(users_or_clients, (byte*)user_stats))
-+ {
-+ my_free((char*)user_stats, 0);
-+ return 1; // Out of memory
-+ }
-+ }
-+ user_stats->total_connections++;
-+ return 0;
-+}
-+
-+// Increments the global user and client stats connection count. If 'use_lock'
-+// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
-+// 0 on success, 1 on error.
-+static int increment_connection_count(THD* thd, bool use_lock)
-+{
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+ int return_value = 0;
-+
-+ if (!opt_userstat_running)
-+ return return_value;
-+
-+ if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ if (increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+ if (increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd))
-+ {
-+ return_value = 1;
-+ goto end;
-+ }
-+
-+end:
-+ if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ return return_value;
-+}
-+
-+// Used to update the global user and client stats.
-+static void update_global_user_stats_with_user(THD* thd,
-+ USER_STATS* user_stats,
-+ time_t now)
-+{
-+ user_stats->connected_time += now - thd->last_global_update_time;
-+ thd->last_global_update_time = now;
-+ user_stats->busy_time += thd->diff_total_busy_time;
-+ user_stats->cpu_time += thd->diff_total_cpu_time;
-+ user_stats->bytes_received += thd->diff_total_bytes_received;
-+ user_stats->bytes_sent += thd->diff_total_bytes_sent;
-+ user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
-+ user_stats->rows_fetched += thd->diff_total_sent_rows;
-+ user_stats->rows_updated += thd->diff_total_updated_rows;
-+ user_stats->rows_read += thd->diff_total_read_rows;
-+ user_stats->select_commands += thd->diff_select_commands;
-+ user_stats->update_commands += thd->diff_update_commands;
-+ user_stats->other_commands += thd->diff_other_commands;
-+ user_stats->commit_trans += thd->diff_commit_trans;
-+ user_stats->rollback_trans += thd->diff_rollback_trans;
-+ user_stats->denied_connections += thd->diff_denied_connections;
-+ user_stats->lost_connections += thd->diff_lost_connections;
-+ user_stats->access_denied_errors += thd->diff_access_denied_errors;
-+ user_stats->empty_queries += thd->diff_empty_queries;
-+}
-+
-+// Updates the global stats of a user or client
-+void update_global_user_stats(THD* thd, bool create_user, time_t now)
-+{
-+ if (opt_userstat_running) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ const char* client_string = get_client_host(thd);
-+
-+ USER_STATS* user_stats;
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+
-+ // Update by user name
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ // Update by client IP
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found by client IP
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Create the entry
-+ if (create_user) {
-+ increment_count_by_name(client_string,
-+ user_string,
-+ &global_client_stats, thd);
-+ }
-+ }
-+ thd->reset_diff_stats();
-+
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ } else {
-+ thd->reset_diff_stats();
-+ }
-+}
-+
-+// Determines the concurrent number of connections of current threads.
-+static void set_connections_stats()
-+{
-+ USER_STATS* user_stats;
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ pthread_mutex_lock(&LOCK_thread_count);
-+
-+ // Resets all concurrent connections to 0.
-+ for (int i = 0; i < global_user_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+ for (int i = 0; i < global_client_stats.records; ++i) {
-+ user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
-+ user_stats->concurrent_connections = 0;
-+ }
-+
-+ I_List_iterator<THD> it(threads);
-+ THD* thd;
-+ time_t now = time(NULL);
-+ // Iterates through the current threads.
-+ while ((thd = it++)) {
-+ char* user_string = get_valid_user_string(thd->main_security_ctx.user);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
-+ (byte*)user_string,
-+ strlen(user_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // The user name should exist.
-+ if (user_string == mysql_system_user) {
-+ // Only create the user if it is the mysql_system_user
-+ increment_count_by_name(user_string, user_string,
-+ &global_user_stats, thd);
-+ }
-+ }
-+
-+ const char* client_string = get_client_host(thd);
-+ if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
-+ (byte*)client_string,
-+ strlen(client_string)))) {
-+ // Found user.
-+ user_stats->concurrent_connections++;
-+ update_global_user_stats_with_user(thd, user_stats, now);
-+ } else {
-+ // Do nothing, unlike what is done for global_user_stats
-+ }
-+ thd->reset_diff_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_thread_count);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+}
-+
- /*
- Reset per-hour user resource limits when it has been more than
- an hour since they were last checked
-@@ -1184,6 +1610,8 @@
- my_net_set_read_timeout(net, connect_timeout);
- my_net_set_write_timeout(net, connect_timeout);
-
-+ bool create_user = true;
-+
- if ((error=check_connection(thd)))
- { // Wrong permissions
- if (error > 0)
-@@ -1193,8 +1621,22 @@
- my_sleep(1000); /* must wait after eof() */
- #endif
- statistic_increment(aborted_connects,&LOCK_status);
-+ thd->diff_denied_connections++;
-+ if (error == -2) {
-+ // Do not create statistics for a user who does not exist, or failed
-+ // to authenticate.
-+ create_user = false;
-+ }
- goto end_thread;
- }
-+
-+ thd->reset_stats();
-+ // Updates global user connection stats.
-+ if (increment_connection_count(thd, true)) {
-+ net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
-+ goto end_thread;
-+ }
-+
- #ifdef __NETWARE__
- netware_reg_user(sctx->ip, sctx->user, "MySQL");
- #endif
-@@ -1251,6 +1693,7 @@
- (net->vio && net->error && net->report_error))
- {
- statistic_increment(aborted_threads, &LOCK_status);
-+ thd->diff_lost_connections++;
- }
-
- if (net->error && net->vio != 0 && net->report_error)
-@@ -1270,6 +1713,8 @@
-
- end_thread:
- close_connection(thd, 0, 1);
-+ thd->update_stats(false);
-+ update_global_user_stats(thd, create_user, time(NULL));
- end_thread(thd,1);
- /*
- If end_thread returns, we are either running with --one-thread
-@@ -1601,6 +2046,13 @@
-
- thd->clear_error(); // Clear error message
-
-+ thd->updated_row_count=0;
-+ thd->busy_time=0;
-+ thd->cpu_time=0;
-+ thd->bytes_received=0;
-+ thd->bytes_sent=0;
-+ thd->binlog_bytes_written=0;
-+
- net_new_transaction(net);
-
- packet_length= my_net_read(net);
-@@ -1759,6 +2211,9 @@
- }
-
- thd->command=command;
-+ // To increment the corrent command counter for user stats, 'command' must
-+ // be saved because it is set to COM_SLEEP at the end of this function.
-+ thd->old_command = command;
- /*
- Commands which always take a long time are logged into
- the slow log only if opt_log_slow_admin_statements is set.
-@@ -4539,6 +4994,15 @@
- if (check_global_access(thd,RELOAD_ACL))
- goto error;
-
-+ if(lex->type & REFRESH_SLOW_QUERY_LOG) {
-+ /* We are only flushing slow query log */
-+ mysql_slow_log.new_file(1);
-+
-+ send_ok(thd);
-+ break;
-+ }
-+
-+
- /*
- reload_acl_and_cache() will tell us if we are allowed to write to the
- binlog or not.
-@@ -4847,6 +5311,7 @@
- {
- if (check_global_access(thd, SUPER_ACL))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
- goto create_sp_error;
- }
-@@ -5691,6 +6156,7 @@
- if (!no_errors)
- {
- const char *db_name= db ? db : thd->db;
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host, db_name);
- }
-@@ -5726,6 +6192,7 @@
- { // We can never grant this
- DBUG_PRINT("error",("No possible access"));
- if (!no_errors)
-+ thd->diff_access_denied_errors++;
- my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host,
-@@ -5758,11 +6225,15 @@
-
- DBUG_PRINT("error",("Access denied"));
- if (!no_errors)
-+ {
-+ // increment needs !no_errors condition, otherwise double counting.
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- (db ? db : (thd->db ?
- thd->db :
- "unknown"))); /* purecov: tested */
-+ }
- DBUG_RETURN(TRUE); /* purecov: tested */
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
- }
-@@ -5796,6 +6267,7 @@
- if ((thd->security_ctx->master_access & want_access))
- return 0;
- get_privilege_desc(command, sizeof(command), want_access);
-+ thd->diff_access_denied_errors++;
- my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
- return 1;
- #endif /* NO_EMBEDDED_ACCESS_CHECKS */
-@@ -5828,6 +6300,7 @@
-
- if (!thd->col_access && check_grant_db(thd, dst_db_name))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- thd->security_ctx->priv_user,
- thd->security_ctx->priv_host,
-@@ -5859,6 +6332,12 @@
- check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
- }
-
-+
-+ case SCH_USER_STATS:
-+ case SCH_CLIENT_STATS:
-+ return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
-+ case SCH_TABLE_STATS:
-+ case SCH_INDEX_STATS:
- case SCH_OPEN_TABLES:
- case SCH_VARIABLES:
- case SCH_STATUS:
-@@ -5912,8 +6391,8 @@
- #ifndef NO_EMBEDDED_ACCESS_CHECKS
- TABLE_LIST *org_tables= tables;
- #endif
-+ Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
-- Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
- /*
- The check that first_not_own_table is not reached is for the case when
- the given table list refers to the list for prelocking (contains tables
-@@ -5930,9 +6409,12 @@
- (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
- {
- if (!no_errors)
-+ {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->priv_host,
- INFORMATION_SCHEMA_NAME.str);
-+ }
- return TRUE;
- }
- /*
-@@ -6442,6 +6924,30 @@
- lex_start(thd);
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
- {
- LEX *lex= thd->lex;
-@@ -6520,6 +7026,43 @@
- *found_semicolon= NULL;
- }
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -7531,8 +8074,35 @@
- pthread_mutex_unlock(&LOCK_active_mi);
- }
- #endif
-- if (options & REFRESH_USER_RESOURCES)
-- reset_mqh((LEX_USER *) NULL);
-+ if (options & REFRESH_TABLE_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ free_global_table_stats();
-+ init_global_table_stats();
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ }
-+ if (options & REFRESH_INDEX_STATS)
-+ {
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ free_global_index_stats();
-+ init_global_index_stats();
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ }
-+ if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
-+ {
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ if (options & REFRESH_USER_STATS)
-+ {
-+ free_global_user_stats();
-+ init_global_user_stats();
-+ }
-+ if (options & REFRESH_CLIENT_STATS)
-+ {
-+ free_global_client_stats();
-+ init_global_client_stats();
-+ }
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ }
- *write_to_binlog= tmp_write_to_binlog;
- return result;
- }
-diff -r 592f6c3641ba sql/sql_prepare.cc
---- a/sql/sql_prepare.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_prepare.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -81,6 +81,9 @@
- #include <mysql_com.h>
- #endif
-
-+// Uses the THD to update the global stats by user name and client IP
-+void update_global_user_stats(THD* thd, bool create_user, time_t now);
-+
- /* A result class used to send cursor rows using the binary protocol. */
-
- class Select_fetch_protocol_prep: public select_send
-@@ -1910,8 +1913,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
-- DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
-+ goto end; /* out of memory: error is set in Sql_alloc */
-
- if (thd->stmt_map.insert(thd, stmt))
- {
-@@ -1919,7 +1946,7 @@
- The error is set in the insert. The statement itself
- will be also deleted there (this is how the hash works).
- */
-- DBUG_VOID_RETURN;
-+ goto end;
- }
-
- /* Reset warnings from previous command */
-@@ -1941,6 +1968,44 @@
- thd->stmt_map.erase(stmt);
- }
- /* check_prepared_statemnt sends the metadata packet in case of success */
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2281,8 +2346,32 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
-- DBUG_VOID_RETURN;
-+ goto end;
-
- #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
- thd->profiling.set_query_source(stmt->query, stmt->query_length);
-@@ -2325,11 +2414,50 @@
- test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
- if (!(specialflag & SPECIAL_NO_PRIOR))
- my_pthread_setprio(pthread_self(), WAIT_PRIOR);
-- DBUG_VOID_RETURN;
-+ goto end;
-
- set_params_data_err:
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
- reset_stmt_params(stmt);
-+
-+end:
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2423,6 +2551,31 @@
-
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-+
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
- DBUG_VOID_RETURN;
-@@ -2455,6 +2608,43 @@
- thd->restore_backup_statement(stmt, &stmt_backup);
- thd->stmt_arena= thd;
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-@@ -2487,6 +2677,30 @@
- /* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd);
-
-+ int start_time_error = 0;
-+ int end_time_error = 0;
-+ struct timeval start_time, end_time;
-+ double start_usecs = 0;
-+ double end_usecs = 0;
-+ /* cpu time */
-+ int cputime_error = 0;
-+ struct timespec tp;
-+ double start_cpu_nsecs = 0;
-+ double end_cpu_nsecs = 0;
-+
-+ if (opt_userstat_running) {
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get start cputime */
-+ if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+
-+ // Gets the start time, in order to measure how long this command takes.
-+ if (!(start_time_error = gettimeofday(&start_time, NULL))) {
-+ start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
-+ }
-+ }
-+
- statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
- if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
- DBUG_VOID_RETURN;
-@@ -2503,6 +2717,43 @@
-
- send_ok(thd);
-
-+ if (opt_userstat_running) {
-+ // Gets the end time.
-+ if (!(end_time_error = gettimeofday(&end_time, NULL))) {
-+ end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
-+ }
-+
-+ // Calculates the difference between the end and start times.
-+ if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
-+ thd->busy_time = (end_usecs - start_usecs) / 1000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->busy_time > 2629743) {
-+ thd->busy_time = 0;
-+ }
-+ } else {
-+ // end time went back in time, or gettimeofday() failed.
-+ thd->busy_time = 0;
-+ }
-+
-+#ifdef HAVE_CLOCK_GETTIME
-+ /* get end cputime */
-+ if (!cputime_error &&
-+ !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
-+ end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
-+#endif
-+ if (start_cpu_nsecs && !cputime_error) {
-+ thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
-+ // In case there are bad values, 2629743 is the #seconds in a month.
-+ if (thd->cpu_time > 2629743) {
-+ thd->cpu_time = 0;
-+ }
-+ } else
-+ thd->cpu_time = 0;
-+ }
-+ // Updates THD stats and the global user stats.
-+ thd->update_stats(true);
-+ update_global_user_stats(thd, true, time(NULL));
-+
- DBUG_VOID_RETURN;
- }
-
-diff -r 592f6c3641ba sql/sql_show.cc
---- a/sql/sql_show.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_show.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -540,6 +540,7 @@
- sctx->master_access);
- if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
- {
-+ thd->diff_access_denied_errors++;
- my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user, sctx->host_or_ip, dbname);
- mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
-@@ -1890,6 +1891,300 @@
- DBUG_RETURN(FALSE);
- }
-
-+/*
-+ Aggregate values for mapped_user entries by their role.
-+
-+ SYNOPSIS
-+ aggregate_user_stats
-+ all_user_stats - input to aggregate
-+ agg_user_stats - returns aggregated values
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+static int
-+aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
-+{
-+ DBUG_ENTER("aggregate_user_stats");
-+ if (hash_init(agg_user_stats, system_charset_info,
-+ max(all_user_stats->records, 1),
-+ 0, 0, (hash_get_key)get_key_user_stats,
-+ (hash_free_key)free_user_stats, 0))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
-+ USER_STATS *agg_user;
-+ if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
-+ (byte*)user->priv_user,
-+ strlen(user->priv_user))))
-+ {
-+ // First entry for this role.
-+ if (!(agg_user =
-+ (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
-+ {
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+
-+ init_user_stats(agg_user, user->priv_user, user->priv_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+
-+ if (my_hash_insert(agg_user_stats, (byte*)agg_user))
-+ {
-+ // Out of memory.
-+ my_free((char*)agg_user, 0);
-+ sql_print_error("Malloc in aggregate_user_stats failed");
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ else
-+ {
-+ // Aggregate with existing values for this role.
-+ add_user_stats(agg_user,
-+ user->total_connections, user->concurrent_connections,
-+ user->connected_time, user->busy_time, user->cpu_time,
-+ user->bytes_received, user->bytes_sent,
-+ user->binlog_bytes_written,
-+ user->rows_fetched, user->rows_updated, user->rows_read,
-+ user->select_commands, user->update_commands,
-+ user->other_commands,
-+ user->commit_trans, user->rollback_trans,
-+ user->denied_connections, user->lost_connections,
-+ user->access_denied_errors, user->empty_queries);
-+ }
-+ }
-+ DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
-+ all_user_stats->records, agg_user_stats->records));
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Write result to network for SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ send_user_stats
-+ all_user_stats - values to return
-+ table - I_S table
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
-+{
-+ DBUG_ENTER("send_user_stats");
-+ for (int i = 0; i < all_user_stats->records; ++i) {
-+ restore_record(table, s->default_values);
-+ USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
-+ table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
-+ table->field[1]->store((longlong)user_stats->total_connections);
-+ table->field[2]->store((longlong)user_stats->concurrent_connections);
-+ table->field[3]->store((longlong)user_stats->connected_time);
-+ table->field[4]->store((longlong)user_stats->busy_time);
-+ table->field[5]->store((longlong)user_stats->cpu_time);
-+ table->field[6]->store((longlong)user_stats->bytes_received);
-+ table->field[7]->store((longlong)user_stats->bytes_sent);
-+ table->field[8]->store((longlong)user_stats->binlog_bytes_written);
-+ table->field[9]->store((longlong)user_stats->rows_fetched);
-+ table->field[10]->store((longlong)user_stats->rows_updated);
-+ table->field[11]->store((longlong)user_stats->rows_read);
-+ table->field[12]->store((longlong)user_stats->select_commands);
-+ table->field[13]->store((longlong)user_stats->update_commands);
-+ table->field[14]->store((longlong)user_stats->other_commands);
-+ table->field[15]->store((longlong)user_stats->commit_trans);
-+ table->field[16]->store((longlong)user_stats->rollback_trans);
-+ table->field[17]->store((longlong)user_stats->denied_connections);
-+ table->field[18]->store((longlong)user_stats->lost_connections);
-+ table->field[19]->store((longlong)user_stats->access_denied_errors);
-+ table->field[20]->store((longlong)user_stats->empty_queries);
-+ if (schema_table_store_record(thd, table))
-+ {
-+ DBUG_PRINT("error", ("store record error"));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ DBUG_RETURN(0);
-+}
-+
-+/*
-+ Process SHOW USER_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_user_stats
-+ thd - current thread
-+ wild - limit results to the entry for this user
-+ with_roles - when true, display role for mapped users
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_user_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_user_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+/*
-+ Process SHOW CLIENT_STATISTICS
-+
-+ SYNOPSIS
-+ mysqld_show_client_stats
-+ thd - current thread
-+ wild - limit results to the entry for this client
-+
-+ RETURN
-+ 0 - OK
-+ 1 - error
-+ */
-+
-+
-+int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_client_stats");
-+
-+ if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
-+ DBUG_RETURN(1);
-+
-+ // Iterates through all the global stats and sends them to the client.
-+ // Pattern matching on the client IP is supported.
-+
-+ pthread_mutex_lock(&LOCK_global_user_client_stats);
-+ int result= send_user_stats(thd, &global_client_stats, table);
-+ pthread_mutex_unlock(&LOCK_global_user_client_stats);
-+ if (result)
-+ goto err;
-+
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
-+ DBUG_RETURN(0);
-+
-+ err:
-+ DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
-+ DBUG_RETURN(1);
-+}
-+
-+
-+// Sends the global table stats back to the client.
-+int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_table_stats");
-+ char *table_full_name, *table_schema;
-+
-+ pthread_mutex_lock(&LOCK_global_table_stats);
-+ for (int i = 0; i < global_table_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ TABLE_STATS *table_stats =
-+ (TABLE_STATS*)hash_element(&global_table_stats, i);
-+
-+ table_full_name= thd->strdup(table_stats->table);
-+ table_schema= strsep(&table_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_full_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
-+ table->field[2]->store((longlong)table_stats->rows_read, TRUE);
-+ table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
-+ table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_table_stats);
-+ DBUG_RETURN(0);
-+}
-+
-+// Sends the global index stats back to the client.
-+int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
-+{
-+ TABLE *table= tables->table;
-+ DBUG_ENTER("fill_schema_index_stats");
-+ char *index_full_name, *table_schema, *table_name;
-+
-+ pthread_mutex_lock(&LOCK_global_index_stats);
-+ for (int i = 0; i < global_index_stats.records; ++i) {
-+ restore_record(table, s->default_values);
-+ INDEX_STATS *index_stats =
-+ (INDEX_STATS*)hash_element(&global_index_stats, i);
-+
-+ index_full_name= thd->strdup(index_stats->index);
-+ table_schema= strsep(&index_full_name, ".");
-+ table_name= strsep(&index_full_name, ".");
-+
-+ TABLE_LIST tmp_table;
-+ bzero((char*) &tmp_table,sizeof(tmp_table));
-+ tmp_table.table_name= table_name;
-+ tmp_table.db= table_schema;
-+ tmp_table.grant.privilege= 0;
-+ if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
-+ &tmp_table.grant.privilege, 0, 0,
-+ is_schema_db(table_schema)) ||
-+ grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
-+ continue;
-+
-+ table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
-+ table->field[1]->store(table_name, strlen(table_name), system_charset_info);
-+ table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
-+ table->field[3]->store((longlong)index_stats->rows_read, TRUE);
-+
-+ if (schema_table_store_record(thd, table))
-+ {
-+ VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
-+ DBUG_RETURN(1);
-+ }
-+ }
-+ pthread_mutex_unlock(&LOCK_global_index_stats);
-+ DBUG_RETURN(0);
-+}
-
- /* collect status for all running threads */
-
-@@ -4500,6 +4795,77 @@
- {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
- };
-
-+ST_FIELD_INFO user_stats_fields_info[]=
-+{
-+ {"USER", USERNAME_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO client_stats_fields_info[]=
-+{
-+ {"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client"},
-+ {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
-+ {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
-+ {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
-+ {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
-+ {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
-+ {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
-+ {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
-+ {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
-+ {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
-+ {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
-+ {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
-+ {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
-+ {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
-+ {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
-+ {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
-+ {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
-+ {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
-+ {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
-+ {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
-+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+
-+ST_FIELD_INFO table_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
-+ {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-+
-+ST_FIELD_INFO index_stats_fields_info[]=
-+{
-+ {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
-+ {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
-+ {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
-+ {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
-+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
-+};
-
- /*
- Description of ST_FIELD_INFO in table.h
-@@ -4509,6 +4875,8 @@
- {
- {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
- fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
-+ {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
-+ fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
- {"COLLATIONS", collation_fields_info, create_schema_table,
- fill_schema_collation, make_old_format, 0, -1, -1, 0},
- {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-@@ -4517,6 +4885,8 @@
- get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
- {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
- fill_schema_column_privileges, 0, 0, -1, -1, 0},
-+ {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
-+ fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
- {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
- get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
- {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-@@ -4542,10 +4912,14 @@
- get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
- {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
- fill_schema_table_privileges, 0, 0, -1, -1, 0},
-+ {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
-+ fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
- {"TRIGGERS", triggers_fields_info, create_schema_table,
- get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
- {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
- fill_schema_user_privileges, 0, 0, -1, -1, 0},
-+ {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
-+ fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
- {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
- make_old_format, 0, -1, -1, 1},
- {"VIEWS", view_fields_info, create_schema_table,
-diff -r 592f6c3641ba sql/sql_update.cc
---- a/sql/sql_update.cc Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_update.cc Wed Jul 29 13:34:11 2009 -0700
-@@ -601,7 +601,8 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-- DBUG_PRINT("info",("%ld records updated", (long) updated));
-+ thd->updated_row_count += thd->row_count_func;
-+ DBUG_PRINT("info",("%d records updated",updated));
- }
- thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
- thd->abort_on_warning= 0;
-@@ -1832,5 +1833,6 @@
- (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
- ::send_ok(thd, (ulong) thd->row_count_func,
- thd->insert_id_used ? thd->last_insert_id : 0L,buff);
-+ thd->updated_row_count += thd->row_count_func;
- return FALSE;
- }
-diff -r 592f6c3641ba sql/sql_yacc.yy
---- a/sql/sql_yacc.yy Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/sql_yacc.yy Wed Jul 29 13:34:11 2009 -0700
-@@ -523,6 +523,7 @@
- %token CHECK_SYM
- %token CIPHER_SYM
- %token CLIENT_SYM
-+%token CLIENT_STATS_SYM
- %token CLOSE_SYM
- %token COALESCE
- %token CODE_SYM
-@@ -680,6 +681,7 @@
- %token IMPORT
- %token INDEXES
- %token INDEX_SYM
-+%token INDEX_STATS_SYM
- %token INFILE
- %token INNER_SYM
- %token INNOBASE_SYM
-@@ -909,6 +911,7 @@
- %token SIGNED_SYM
- %token SIMPLE_SYM
- %token SLAVE
-+%token SLOW_SYM
- %token SMALLINT
- %token SNAPSHOT_SYM
- %token SOUNDS_SYM
-@@ -949,6 +952,7 @@
- %token TABLES
- %token TABLESPACE
- %token TABLE_SYM
-+%token TABLE_STATS_SYM
- %token TEMPORARY
- %token TEMPTABLE_SYM
- %token TERMINATED
-@@ -991,6 +995,7 @@
- %token UPGRADE_SYM
- %token USAGE
- %token USER
-+%token USER_STATS_SYM
- %token USE_FRM
- %token USE_SYM
- %token USING
-@@ -8255,6 +8260,38 @@
- {
- Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
- }
-+ | CLIENT_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ Lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | USER_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command = SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | TABLE_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
-+ MYSQL_YYABORT;
-+ }
-+ | INDEX_STATS_SYM wild_and_where
-+ {
-+ LEX *lex= Lex;
-+ lex->sql_command= SQLCOM_SELECT;
-+ lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
-+ if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
-+ MYSQL_YYABORT;
-+ }
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
-@@ -8459,9 +8496,14 @@
- | LOGS_SYM { Lex->type|= REFRESH_LOG; }
- | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
- | SLAVE { Lex->type|= REFRESH_SLAVE; }
-+ | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
- | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
- | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
-- | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
-+ | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
-+ | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
-+ | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
-+ | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
-+ | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
-
- opt_table_list:
- /* empty */ {;}
-@@ -9450,6 +9492,7 @@
- | CHAIN_SYM {}
- | CHANGED {}
- | CIPHER_SYM {}
-+ | CLIENT_STATS_SYM {}
- | CLIENT_SYM {}
- | CODE_SYM {}
- | COLLATION_SYM {}
-@@ -9502,6 +9545,7 @@
- | HOSTS_SYM {}
- | HOUR_SYM {}
- | IDENTIFIED_SYM {}
-+ | INDEX_STATS_SYM {}
- | INVOKER_SYM {}
- | IMPORT {}
- | INDEXES {}
-@@ -9611,6 +9655,7 @@
- | SIMPLE_SYM {}
- | SHARE_SYM {}
- | SHUTDOWN {}
-+ | SLOW_SYM {}
- | SNAPSHOT_SYM {}
- | SOUNDS_SYM {}
- | SOURCE_SYM {}
-@@ -9627,6 +9672,7 @@
- | SUSPEND_SYM {}
- | SWAPS_SYM {}
- | SWITCHES_SYM {}
-+ | TABLE_STATS_SYM {}
- | TABLES {}
- | TABLESPACE {}
- | TEMPORARY {}
-@@ -9647,6 +9693,7 @@
- | UNKNOWN_SYM {}
- | UNTIL_SYM {}
- | USER {}
-+ | USER_STATS_SYM {}
- | USE_FRM {}
- | VARIABLES {}
- | VIEW_SYM {}
-diff -r 592f6c3641ba sql/structs.h
---- a/sql/structs.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/structs.h Wed Jul 29 13:34:11 2009 -0700
-@@ -273,6 +273,98 @@
- time_t intime;
- } USER_CONN;
-
-+typedef struct st_user_stats {
-+ char user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ // Account name the user is mapped to when this is a user from mapped_user.
-+ // Otherwise, the same value as user.
-+ char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
-+ uint total_connections;
-+ uint concurrent_connections;
-+ time_t connected_time; // in seconds
-+ double busy_time; // in seconds
-+ double cpu_time; // in seconds
-+ ulonglong bytes_received;
-+ ulonglong bytes_sent;
-+ ulonglong binlog_bytes_written;
-+ ha_rows rows_fetched, rows_updated, rows_read;
-+ ulonglong select_commands, update_commands, other_commands;
-+ ulonglong commit_trans, rollback_trans;
-+ ulonglong denied_connections, lost_connections;
-+ ulonglong access_denied_errors;
-+ ulonglong empty_queries;
-+} USER_STATS;
-+
-+/* Lookup function for hash tables with USER_STATS entries */
-+extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
-+ my_bool not_used __attribute__((unused)));
-+
-+/* Free all memory for a hash table with USER_STATS entries */
-+extern void free_user_stats(USER_STATS* user_stats);
-+
-+/* Intialize an instance of USER_STATS */
-+extern void
-+init_user_stats(USER_STATS *user_stats,
-+ const char *user,
-+ const char *priv_user,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+/* Increment values of an instance of USER_STATS */
-+extern void
-+add_user_stats(USER_STATS *user_stats,
-+ uint total_connections,
-+ uint concurrent_connections,
-+ time_t connected_time,
-+ double busy_time,
-+ double cpu_time,
-+ ulonglong bytes_received,
-+ ulonglong bytes_sent,
-+ ulonglong binlog_bytes_written,
-+ ha_rows rows_fetched,
-+ ha_rows rows_updated,
-+ ha_rows rows_read,
-+ ulonglong select_commands,
-+ ulonglong update_commands,
-+ ulonglong other_commands,
-+ ulonglong commit_trans,
-+ ulonglong rollback_trans,
-+ ulonglong denied_connections,
-+ ulonglong lost_connections,
-+ ulonglong access_denied_errors,
-+ ulonglong empty_queries);
-+
-+typedef struct st_table_stats {
-+ char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
-+ ulonglong rows_read, rows_changed;
-+ ulonglong rows_changed_x_indexes;
-+ /* Stores enum db_type, but forward declarations cannot be done */
-+ int engine_type;
-+} TABLE_STATS;
-+
-+typedef struct st_index_stats {
-+ char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
-+ ulonglong rows_read;
-+} INDEX_STATS;
-+
-+
- /* Bits in form->update */
- #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
- #define REG_NEW_RECORD 2 /* Write a new record if not found */
-diff -r 592f6c3641ba sql/table.h
---- a/sql/table.h Wed Jul 29 13:33:34 2009 -0700
-+++ b/sql/table.h Wed Jul 29 13:34:11 2009 -0700
-@@ -371,10 +371,12 @@
- enum enum_schema_tables
- {
- SCH_CHARSETS= 0,
-+ SCH_CLIENT_STATS,
- SCH_COLLATIONS,
- SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
- SCH_COLUMNS,
- SCH_COLUMN_PRIVILEGES,
-+ SCH_INDEX_STATS,
- SCH_KEY_COLUMN_USAGE,
- SCH_OPEN_TABLES,
- SCH_PROFILES,
-@@ -387,8 +389,10 @@
- SCH_TABLE_CONSTRAINTS,
- SCH_TABLE_NAMES,
- SCH_TABLE_PRIVILEGES,
-+ SCH_TABLE_STATS,
- SCH_TRIGGERS,
- SCH_USER_PRIVILEGES,
-+ SCH_USER_STATS,
- SCH_VARIABLES,
- SCH_VIEWS
- };
-diff -r 592f6c3641ba strings/Makefile.in
---- a/strings/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/strings/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -342,6 +342,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/MacOSX/Makefile.in
---- a/support-files/MacOSX/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/MacOSX/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -148,6 +148,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/Makefile.in
---- a/support-files/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -171,6 +171,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba support-files/RHEL4-SElinux/Makefile.in
---- a/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/support-files/RHEL4-SElinux/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -146,6 +146,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tests/Makefile.in
---- a/tests/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tests/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -193,6 +193,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @CLIENT_LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba tools/Makefile.in
---- a/tools/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/tools/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -167,6 +167,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba vio/Makefile.in
---- a/vio/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/vio/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -176,6 +176,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba win/Makefile.in
---- a/win/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/win/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -144,6 +144,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = @LIBS@
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
-diff -r 592f6c3641ba zlib/Makefile.in
---- a/zlib/Makefile.in Wed Jul 29 13:33:34 2009 -0700
-+++ b/zlib/Makefile.in Wed Jul 29 13:34:11 2009 -0700
-@@ -187,6 +187,7 @@
- LIBDL = @LIBDL@
- LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
- LIBOBJS = @LIBOBJS@
-+LIBRT = @LIBRT@
- LIBS = $(NON_THREADED_LIBS)
- LIBTOOL = @LIBTOOL@
- LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@